@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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/connection/pool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAgC,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAA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ACrB,QAAQ,GAAG,IAAI,CAAC;YAEhB,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;YAChB,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC;gBAAE,OAAO;YAE3B,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC7B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK;oBAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC1D,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;gBACzB,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEjB,mEAAmE;YAClE,KAAK,CAAC,KAAgC,CAAC,KAAK,EAAE,EAAE,CAAC;QACnD,CAAC;KACD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IAC1B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;YAAE,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzD,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["/**\n * A reconnecting, shareable connection: one origin and one reconnect loop per relay URL.\n *\n * @module\n */\nimport { Effect, type GetPromise, type Getter, Once, Signal } from \"@moq/signals\";\nimport * as Announce from \"../announced.ts\";\nimport type { Handle } from \"../bandwidth.ts\";\nimport * as Origin from \"../origin.ts\";\nimport * as Path from \"../path.ts\";\nimport * as Time from \"../time.ts\";\nimport { type AcceptProps as AcceptPropsType, accept } from \"./accept.ts\";\nimport { isWebTransportSupported } from \"./browser.ts\";\nimport {\n\ttype CertificateHash as CertificateHashType,\n\ttype ConnectProps as ConnectPropsType,\n\tcertificateHash,\n\tconnect,\n\ttype WebSocketProps as WebSocketPropsType,\n\ttype WebTransportProps as WebTransportPropsType,\n} from \"./connect.ts\";\nimport type { Established as EstablishedType } from \"./established.ts\";\nimport type { GoawayProps, Redirect as RedirectType } from \"./goaway.ts\";\nimport { Reload, type ReloadDelay, type ReloadStatus } from \"./reload.ts\";\nimport type { Probe as ProbeType, Stats as StatsType } from \"./stats.ts\";\nimport type { Transport as TransportType } from \"./transport.ts\";\n\n/** How long an unreferenced shared connection lingers before it actually closes. */\nconst LINGER_MS = Time.Milli(2000);\n\n/** Options for {@link Connection}. */\nexport interface ConnectionProps {\n\t/** The relay to connect to; pass a `Signal` to switch relays live. */\n\turl?: URL | Signal<URL | undefined>;\n\n\t/** Whether to connect at all (default: true); pass a `Signal` to toggle live. */\n\tenabled?: boolean | Signal<boolean>;\n\n\t/**\n\t * How long the underlying connection outlives its last handle (default: 2000ms).\n\t *\n\t * The window is what makes moving an element around the DOM free: the connection and\n\t * everything it discovered are still warm when the new owner asks for them. The longest\n\t * linger requested by any handle sharing the connection wins.\n\t */\n\tlinger?: Time.Milli;\n\n\t/**\n\t * Share a pooled transport keyed on the URL. By default, options specific to this\n\t * handle use a private reconnect loop; otherwise connections share by URL.\n\t * Explicit `true` refuses options a pool cannot honor.\n\t */\n\tshare?: boolean;\n\n\t/** WebTransport options applied to each connection attempt (not reactive). */\n\twebtransport?: WebTransportPropsType;\n\n\t/** WebSocket fallback options applied to each connection attempt (not reactive). */\n\twebsocket?: WebSocketPropsType;\n\n\t/** Whether the relay supports broadcast discovery. */\n\tdiscovery?: boolean;\n\n\t/** The origin whose broadcasts are served, spanning reconnects. Implies a private loop. */\n\tpublish?: Origin.Consumer;\n\n\t/** The origin fed with the peer's announced broadcasts, spanning reconnects. Implies a private loop. */\n\tconsume?: Origin.Producer;\n\n\t/** Backoff settings for the reconnect loop; an unset field uses its default. */\n\tdelay?: ReloadDelay;\n\n\t/**\n\t * How to react to the relay's GOAWAY; an unset field uses its default. Every connection\n\t * migrates on GOAWAY, dialing the replacement while the old session finishes its groups.\n\t * This only tunes where it may go and for how long the old session serves.\n\t */\n\tgoaway?: GoawayProps;\n\n\t/** A Connection owns the abort signal for each connection attempt. */\n\tsignal?: never;\n\n\t/** A one-shot transport cannot be reused by the reconnect loop; call {@link Connection.connect} instead. */\n\ttransport?: never;\n}\n\n/**\n * A cloneable handle on a MoQ connection: `new Connection({ url })` reconnects and, by\n * default, shares one origin and one reconnect loop with every other handle on that URL.\n *\n * The shared {@link origin} is wired to both directions. Everything the relay announces\n * lands in it, a publish into it is announced to the relay, and a page that publishes and\n * watches the same path resolves it locally with no round trip.\n *\n * {@link close} releases this handle; the connection survives its last handle by a short\n * linger window (see {@link ConnectionProps.linger}), so a component torn down and rebuilt\n * reuses the warm connection instead of redialing.\n *\n * The loop reconnects for as long as a handle holds it, so an outage of any length recovers\n * on its own. An auth rejection stops retrying those credentials and retires the shared\n * connection so the next handle dials fresh; a new URL on this handle starts another\n * sequence. {@link closed} settles only when this handle is released.\n *\n * A relay's GOAWAY migrates rather than drops: the replacement dials at once while the old\n * session finishes its groups, and the handle and its origin carry across. A redirect the\n * {@link ConnectionProps.goaway} policy refuses stops the loop like an auth rejection does.\n *\n * Options the pool cannot honor (transport options, discovery, delay, goaway, a pinned\n * certificate, caller-owned origins) use a private loop. An explicit `share: true`\n * refuses them. A supplied transport cannot reconnect at all; pass it to {@link Connection.connect}\n * instead.\n *\n * @public\n */\nexport class Connection {\n\t/** Establish a one-shot session; a supplied transport belongs here, not in the reconnect loop. */\n\tstatic readonly connect = connect;\n\n\t/** Accept a one-shot session on an already-open transport. */\n\tstatic readonly accept = accept;\n\n\t/** SHA-256 of a certificate, for pinning via `webtransport.serverCertificateHashes`. */\n\tstatic readonly certificateHash = certificateHash;\n\n\t/** Whether this runtime can connect with WebTransport. */\n\tstatic readonly isWebTransportSupported = isWebTransportSupported;\n\n\t/** Relay URL to connect to; updating it reconnects to that URL. */\n\turl: Signal<URL | undefined>;\n\n\t/** Whether to hold a connection at all; clearing it releases this handle's share. */\n\tenabled: Signal<boolean>;\n\n\t/** Current status of the connection. */\n\treadonly status: Getter<ReloadStatus>;\n\n\t/**\n\t * The failure that stopped retrying the current URL, or undefined while the loop is live.\n\t *\n\t * Set on an auth rejection or when a private retry window expires. Cleared when a new URL\n\t * or a disable/re-enable starts another sequence, not on a page hide/show.\n\t */\n\treadonly error: Getter<Error | undefined>;\n\n\t/**\n\t * The wire transport the current session runs over, or undefined while disconnected.\n\t *\n\t * The session itself is deliberately not exposed: it is shared, so no handle may close\n\t * or reconfigure it, and everything else it offers is reachable through {@link origin}.\n\t */\n\treadonly transport: Getter<TransportType | undefined>;\n\n\t/** The current connection's PROBE estimates, or undefined while disconnected. */\n\treadonly probe: Getter<ProbeType | undefined>;\n\n\t/**\n\t * The send-side bandwidth allocator for the current URL, or undefined\n\t * while disabled or URL-less.\n\t *\n\t * Every handle on this URL shares the same instance, so publishers reserve\n\t * against one registry. Borrowed, not owned: the type has no close, since\n\t * closing it would starve every other handle.\n\t */\n\treadonly bandwidth: Getter<Handle | undefined>;\n\n\t/**\n\t * The origin for the current URL, or undefined while disabled or URL-less.\n\t *\n\t * Publish into it or consume from it; a shared handle's origin is the same one every\n\t * other handle on this URL uses, and it spans the connection's reconnects. Borrowed,\n\t * not owned: the type has no close, since closing it would tear the origin down under\n\t * every other handle.\n\t */\n\treadonly origin: Getter<Origin.Table | undefined>;\n\n\t/**\n\t * Settles once this handle is released via {@link close}: `null` on a clean close, or\n\t * the abort {@link Error}. Peek it synchronously (`undefined` while open), observe it\n\t * reactively, or `await` it. Attempt failures live on {@link error} instead.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#closed;\n\t}\n\n\t#closed = new Once<Error | null>();\n\treadonly #status = new Signal<ReloadStatus>(\"disconnected\");\n\treadonly #established = new Signal<EstablishedType | undefined>(undefined);\n\treadonly #probe = new Signal<ProbeType | undefined>(undefined);\n\treadonly #origin = new Signal<Origin.Producer | undefined>(undefined);\n\treadonly #bandwidth = new Signal<Handle | undefined>(undefined);\n\treadonly #error = new Signal<Error | undefined>(undefined);\n\t#signals: Effect;\n\n\t/**\n\t * Take a handle on the connection for {@link ConnectionProps.url}.\n\t *\n\t * Dials immediately when a URL is given and `enabled` is not false; otherwise waits for\n\t * the signals to say go. The handle owns nothing but its own share: {@link close}\n\t * releases it, and the underlying connection and origin live for as long as any handle\n\t * (plus the linger window) wants them.\n\t */\n\tconstructor(props?: ConnectionProps) {\n\t\trefuse(props);\n\t\tthis.#signals = new Effect();\n\n\t\tthis.url = Signal.from(props?.url);\n\t\tthis.enabled = Signal.from(props?.enabled ?? true);\n\t\tthis.status = this.#status;\n\t\tthis.error = this.#error;\n\t\tthis.probe = this.#probe;\n\t\tthis.origin = this.#origin;\n\t\tthis.bandwidth = this.#bandwidth;\n\t\tthis.transport = this.#signals.computed((effect) => effect.get(this.#established)?.transport);\n\n\t\tconst linger = props?.linger;\n\n\t\t// Key on the serialized URL: URL objects use identity equality, and an equivalent\n\t\t// instance must not release and redial.\n\t\tconst href = this.#signals.computed((effect) => effect.get(this.url)?.href);\n\n\t\tif (props && (props.share === false || requiresPrivate(props))) {\n\t\t\tthis.#runPrivate(props, href);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#signals.run((effect) => {\n\t\t\tif (!effect.get(this.enabled)) return;\n\t\t\tconst key = effect.get(href);\n\t\t\tif (!key) return;\n\n\t\t\tconst lease = acquire(key, linger);\n\t\t\teffect.cleanup(lease.release);\n\n\t\t\teffect.set(this.#origin, lease.origin, undefined);\n\t\t\teffect.set(this.#bandwidth, lease.connection.bandwidth, undefined);\n\n\t\t\t// Proxy the shared loop's outputs, so this handle reads like its own connection.\n\t\t\teffect.run((nested) => nested.set(this.#status, nested.get(lease.connection.status), \"disconnected\"));\n\t\t\teffect.run((nested) => nested.set(this.#established, nested.get(lease.connection.established), undefined));\n\t\t\teffect.run((nested) => nested.set(this.#probe, nested.get(lease.connection.probe), undefined));\n\t\t\teffect.run((nested) => nested.set(this.#error, nested.get(lease.connection.error), undefined));\n\t\t});\n\t}\n\n\t#runPrivate(props: ConnectionProps, href: Getter<string | undefined>): void {\n\t\tconst owned = props.consume === undefined;\n\t\tconst origin = props.consume ?? new Origin.Producer();\n\t\tif (owned) this.#signals.cleanup(() => origin.close());\n\n\t\tconst loop = new Reload({\n\t\t\turl: this.url,\n\t\t\tenabled: this.enabled,\n\t\t\tpublish: props.publish ?? (owned ? origin.consume() : undefined),\n\t\t\tconsume: origin,\n\t\t\twebtransport: props.webtransport,\n\t\t\twebsocket: props.websocket,\n\t\t\tdiscovery: props.discovery,\n\t\t\t// A handle nobody watches wants unlimited retries; an auth rejection still\n\t\t\t// stops this URL, and a new one starts another sequence.\n\t\t\tdelay: { timeout: Time.Milli(0), ...props.delay },\n\t\t\tgoaway: props.goaway,\n\t\t});\n\t\tthis.#signals.cleanup(() => loop.close());\n\n\t\tthis.#signals.run((effect) => {\n\t\t\tif (!effect.get(this.enabled) || !effect.get(href)) return;\n\t\t\teffect.set(this.#origin, origin, undefined);\n\t\t\teffect.set(this.#bandwidth, loop.bandwidth, undefined);\n\t\t});\n\t\tthis.#signals.run((effect) => effect.set(this.#status, effect.get(loop.status), \"disconnected\"));\n\t\tthis.#signals.run((effect) => effect.set(this.#established, effect.get(loop.established), undefined));\n\t\tthis.#signals.run((effect) => effect.set(this.#probe, effect.get(loop.probe), undefined));\n\t\tthis.#signals.run((effect) => effect.set(this.#error, effect.get(loop.error), undefined));\n\t}\n\n\t/**\n\t * Subscribe to broadcast announcements matching `scope`, spanning reconnects\n\t * and URL switches: a switch retracts everything from\n\t * the old relay's origin, then the new one's arrivals stream in.\n\t */\n\tannounced(scope: Path.Pattern = Path.Pattern.all(), options?: Announce.Options): Announce.Consumer {\n\t\tconst producer = new Announce.Producer();\n\t\tconst consumer = producer.consume();\n\n\t\t// Closing the consumer closes the shared state, so stop appending after that.\n\t\tlet closed = false;\n\t\tvoid consumer.closed.then(() => {\n\t\t\tclosed = true;\n\t\t});\n\n\t\t// A child of this handle's scope rather than a standalone Effect it merely cleans up\n\t\t// after: the disposer run() hands back also drops itself from the parent, so opening\n\t\t// and closing announcement streams repeatedly does not pile up dead pumps that live\n\t\t// until the whole handle closes.\n\t\tconst stop = this.#signals.run((effect) => {\n\t\t\tconst origin = effect.get(this.#origin);\n\t\t\tif (!origin) return;\n\n\t\t\tconst upstream = origin.announced(scope, options);\n\t\t\teffect.cleanup(() => upstream.close());\n\n\t\t\t// Track what this origin announced so a URL switch retracts it; the last\n\t\t\t// event rides along for the retraction.\n\t\t\tconst active = new Map<Path.Valid, Announce.Update>();\n\n\t\t\teffect.spawn(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tfor (;;) {\n\t\t\t\t\t\tconst entry = await effect.race(upstream.next());\n\t\t\t\t\t\tif (!entry) break;\n\t\t\t\t\t\tif (Announce.isActive(entry.kind)) active.set(entry.prefix, entry);\n\t\t\t\t\t\telse active.delete(entry.prefix);\n\t\t\t\t\t\tproducer.append(entry);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (!closed) {\n\t\t\t\t\t\tfor (const entry of active.values()) {\n\t\t\t\t\t\t\tproducer.append({ ...entry, kind: \"retracted\" });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tvoid consumer.closed.then(stop);\n\n\t\treturn consumer;\n\t}\n\n\t/** Snapshot the live connection's transport counters, or undefined while disconnected. */\n\tasync stats(): Promise<StatsType | undefined> {\n\t\treturn this.#established.peek()?.stats();\n\t}\n\n\t/**\n\t * Release this handle. The shared connection closes once its last handle is gone and\n\t * the linger window passes; other handles on the URL are unaffected. Idempotent.\n\t */\n\tclose(abort?: Error): void {\n\t\tthis.#signals.close();\n\t\tif (this.#closed.peek() === undefined) this.#closed.set(abort ?? null);\n\t}\n}\n\n/** Types on {@link Connection}: the handle is the class, these are its associated types. */\nexport namespace Connection {\n\t/** Options for {@link Connection}. */\n\texport type Props = ConnectionProps;\n\t/** Options for {@link Connection.connect}. */\n\texport type ConnectProps = ConnectPropsType;\n\t/** Options for {@link Connection.accept}. */\n\texport type AcceptProps = AcceptPropsType;\n\t/** Backoff settings for a private reconnect loop. */\n\texport type Backoff = ReloadDelay;\n\t/** How a connection reacts to the relay's GOAWAY. */\n\texport type Goaway = GoawayProps;\n\t/** What to do with the URI a relay names in its GOAWAY. */\n\texport type Redirect = RedirectType;\n\t/** Current state of a {@link Connection}. */\n\texport type Status = ReloadStatus;\n\t/** The current connection's PROBE estimates. */\n\texport type Probe = ProbeType;\n\t/** A point-in-time snapshot of the transport's counters. */\n\texport type Stats = StatsType;\n\t/** The wire transport a session runs over. */\n\texport type Transport = TransportType;\n\t/** Tuning for the WebSocket fallback. */\n\texport type WebSocketProps = WebSocketPropsType;\n\t/** WebTransport options, including friendlier certificate pinning. */\n\texport type WebTransportProps = WebTransportPropsType;\n\t/** A server certificate hash used to pin a self-signed server. */\n\texport type CertificateHash = CertificateHashType;\n\t/** An established one-shot session. */\n\texport type Established = EstablishedType;\n}\n\n/** Throw if `props` cannot be honored, rather than silently dropping them. */\nfunction refuse(props?: ConnectionProps): void {\n\tif (!props) return;\n\n\tconst extra = props as ConnectionProps & { transport?: unknown; signal?: unknown };\n\tif (extra.transport) {\n\t\tthrow new Error(\"a supplied transport cannot reconnect; call Connection.connect() instead\");\n\t}\n\tif (extra.signal) {\n\t\tthrow new Error(\"a Connection owns its abort signal; do not pass one\");\n\t}\n\tif (props.share !== true || !requiresPrivate(props)) return;\n\n\tif (props.publish || props.consume) {\n\t\tthrow new Error(\"caller-owned origins cannot be shared; pass share: false\");\n\t}\n\tconst hashes = props.webtransport?.serverCertificateHashes?.length ?? 0;\n\tif (props.webtransport?.serverCertificate !== undefined || hashes > 0) {\n\t\tthrow new Error(\"a pinned certificate cannot be shared; pass share: false\");\n\t}\n\tif (props.webtransport !== undefined) {\n\t\tthrow new Error(\"webtransport options cannot be shared; pass share: false\");\n\t}\n\tif (props.websocket !== undefined) {\n\t\tthrow new Error(\"websocket options cannot be shared; pass share: false\");\n\t}\n\tif (props.discovery !== undefined) {\n\t\tthrow new Error(\"discovery cannot be shared; pass share: false\");\n\t}\n\tif (props.delay !== undefined) {\n\t\tthrow new Error(\"delay cannot be shared; pass share: false\");\n\t}\n\tif (props.goaway !== undefined) {\n\t\tthrow new Error(\"goaway cannot be shared; pass share: false\");\n\t}\n}\n\n/** Options tied to one handle cannot be represented by a URL-keyed shared entry. */\nfunction requiresPrivate(props: ConnectionProps): boolean {\n\treturn (\n\t\tprops.webtransport !== undefined ||\n\t\tprops.websocket !== undefined ||\n\t\tprops.discovery !== undefined ||\n\t\tprops.delay !== undefined ||\n\t\tprops.goaway !== undefined ||\n\t\tprops.publish !== undefined ||\n\t\tprops.consume !== undefined\n\t);\n}\n\n/** One shared connection and the handles keeping it alive. */\ninterface Entry {\n\t/** The pool key: the dialed URL, which a GOAWAY redirect moves. */\n\tkey: string;\n\torigin: Origin.Producer;\n\tconnection: Reload;\n\trefs: number;\n\tlinger: Time.Milli;\n\ttimer?: ReturnType<typeof setTimeout>;\n}\n\n/** The process-wide pool backing {@link Connection}. */\nconst pool = new Map<string, Entry>();\n\n/** Take a reference on the shared entry for `key`, creating it on first use. */\nfunction acquire(key: string, linger?: Time.Milli): Entry & { release: () => void } {\n\tlet entry = pool.get(key);\n\tif (!entry) {\n\t\tconst origin = new Origin.Producer();\n\t\tconst connection = new Reload({\n\t\t\turl: new URL(key),\n\t\t\tenabled: true,\n\t\t\tpublish: origin.consume(),\n\t\t\tconsume: origin,\n\t\t\t// Nobody observes a shared loop's `closed`, so giving up would strand every handle\n\t\t\t// on this URL offline until the page reloads. Retry for as long as the entry lives\n\t\t\t// instead; an auth rejection still stops this URL, and evicts below.\n\t\t\tdelay: { timeout: Time.Milli(0) },\n\t\t});\n\n\t\tconst created: Entry = { key, origin, connection, refs: 0, linger: linger ?? LINGER_MS };\n\n\t\t// The loop only stops on a peer saying these credentials will never work, or on a\n\t\t// GOAWAY redirect it refused. Drop the entry so a later handle dials fresh rather\n\t\t// than joining a loop that has stopped; handles already on it keep it until they\n\t\t// release.\n\t\tconnection.error.subscribe((err) => {\n\t\t\tif (err !== undefined && pool.get(created.key) === created) pool.delete(created.key);\n\t\t});\n\n\t\t// An accepted redirect moves the entry to the URL it now dials, so a later handle\n\t\t// configured with that URL shares it, and one asking for the old URL dials fresh.\n\t\t// A live entry already at the target wins: this one leaves the pool and serves only\n\t\t// the handles it has until they release it.\n\t\tconnection.redirect.subscribe((redirect) => {\n\t\t\tif (!redirect || redirect.href === created.key) return;\n\t\t\tif (pool.get(created.key) === created) pool.delete(created.key);\n\t\t\tcreated.key = redirect.href;\n\t\t\tif (!pool.has(created.key)) pool.set(created.key, created);\n\t\t});\n\n\t\tentry = created;\n\t\tpool.set(key, created);\n\t}\n\n\tconst taken = entry;\n\ttaken.linger = Time.Milli(Math.max(taken.linger, linger ?? LINGER_MS));\n\ttaken.refs += 1;\n\tif (taken.timer !== undefined) {\n\t\tclearTimeout(taken.timer);\n\t\ttaken.timer = undefined;\n\t}\n\n\tlet released = false;\n\treturn {\n\t\t...taken,\n\t\trelease: () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\n\t\t\ttaken.refs -= 1;\n\t\t\tif (taken.refs > 0) return;\n\n\t\t\ttaken.timer = setTimeout(() => {\n\t\t\t\tif (pool.get(taken.key) === taken) pool.delete(taken.key);\n\t\t\t\ttaken.connection.close();\n\t\t\t\ttaken.origin.close();\n\t\t\t}, taken.linger);\n\n\t\t\t// Don't hold a Node process open for a connection nobody is using.\n\t\t\t(taken.timer as { unref?: () => void }).unref?.();\n\t\t},\n\t};\n}\n\n/**\n * Close every shared connection immediately, so the next handle dials fresh.\n *\n * Exists for tests, which otherwise share connections across cases.\n *\n * @internal\n */\nexport function resetShared(): void {\n\tconst entries = [...pool.values()];\n\tpool.clear();\n\tfor (const entry of entries) {\n\t\tif (entry.timer !== undefined) clearTimeout(entry.timer);\n\t\tentry.connection.close();\n\t\tentry.origin.close();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/connection/pool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAgC,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3F,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,IAAI,EAAe,MAAM,iBAAiB,CAAC;AAGlF,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAuC,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAGN,eAAe,EACf,aAAa,EACb,OAAO,EACP,iBAAiB,GAGjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,IAAI,UAAU,EAAyB,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAA+B,aAAa,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAKpG,oFAAoF;AACpF,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AA4ErC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,UAAU;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,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,OAAO;QACN,GAAG,KAAK;QACR,OAAO,EAAE,GAAG,EAAE;YACb,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAEhB,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;YAChB,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC;gBAAE,OAAO;YAE3B,mEAAmE;YACnE,KAAK,CAAC,KAAK,GAAG,KAAK,CAClB,MAAM,EACN,GAAG,EAAE;gBACJ,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK;oBAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC1D,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;gBACzB,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,CAAC,EACD,EAAE,GAAG,EAAE,KAAK,EAAE,CACd,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IAC1B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QAChB,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["/**\n * A reconnecting, shareable connection: one origin and reconnect loop per URL and version list.\n *\n * @module\n */\n\nimport { Duration } from \"@moq/clock\";\nimport { Derived, Effect, type GetPromise, type Getter, Once, Signal } from \"@moq/signals\";\nimport type * as Announce from \"../announce.ts\";\nimport { Producer as AnnounceProducer, list, type Routes } from \"../announced.ts\";\nimport type * as Auth from \"../auth.ts\";\nimport type { Handle, Viewers } from \"../bandwidth.ts\";\nimport * as Origin from \"../origin.ts\";\nimport * as Path from \"../path.ts\";\nimport { closeUnwanted } from \"../util/announce.ts\";\nimport { Follow } from \"../util/observed.ts\";\nimport { after } from \"../util/timer.ts\";\nimport { type AcceptProps as AcceptPropsType, accept } from \"./accept.ts\";\nimport { isWebTransportSupported } from \"./browser.ts\";\nimport {\n\ttype CertificateHash as CertificateHashType,\n\ttype ConnectProps as ConnectPropsType,\n\tcertificateHash,\n\tcheckVersions,\n\tconnect,\n\tnormalizeVersions,\n\ttype WebSocketProps as WebSocketPropsType,\n\ttype WebTransportProps as WebTransportPropsType,\n} from \"./connect.ts\";\nimport { Dials as DialsClass, type Dial as DialType } from \"./dials.ts\";\nimport { DISCOVERY_REMOVED } from \"./forward.ts\";\nimport type { Goaway as GoawayType, Handover as HandoverType, Redirect as RedirectType } from \"./goaway.ts\";\nimport type { Liveness as LivenessType } from \"./liveness.ts\";\nimport { type Backoff as BackoffType, pumpAnnounced, Reload, type ReloadStatus } from \"./reload.ts\";\nimport type { Session as SessionType } from \"./session.ts\";\nimport type { Probe as ProbeType, Sample as SampleType, Stats as StatsType } from \"./stats.ts\";\nimport type { Transport as TransportType } from \"./transport.ts\";\n\n/** How long an unreferenced shared connection lingers before it actually closes. */\nconst LINGER = Duration.millis(2000);\n\n/** Options for {@link Connection}. */\nexport interface ConnectionProps {\n\t/** The relay to connect to; pass a `Signal` to switch relays live. */\n\turl?: URL | Signal<URL | undefined>;\n\n\t/** Whether to connect at all (default: true); pass a `Signal` to toggle live. */\n\tenabled?: boolean | Signal<boolean>;\n\n\t/**\n\t * Share a pooled transport keyed on the URL and ordered versions. By default, options specific to this\n\t * handle use a private reconnect loop; otherwise connections share by URL and versions.\n\t * Explicit `true` refuses options a pool cannot honor.\n\t */\n\tshare?: boolean;\n\n\t/**\n\t * Protocol versions to offer, most preferred first, spelled like `moq-lite-06`; connections pool by\n\t * URL and this list. Pass a `Signal` to switch versions live.\n\t */\n\tversions?: readonly string[] | Signal<readonly string[] | undefined>;\n\n\t/** WebTransport options applied to each connection attempt (not reactive). */\n\twebtransport?: WebTransportPropsType;\n\n\t/** WebSocket fallback options applied to each connection attempt (not reactive). */\n\twebsocket?: WebSocketPropsType;\n\n\t/** The origin whose broadcasts are served, spanning reconnects. Implies a private loop. */\n\tpublish?: Origin.Consumer;\n\n\t/** The origin fed with the peer's announced broadcasts, spanning reconnects. Implies a private loop. */\n\tconsume?: Origin.Producer;\n\n\t/** Price each session's link; see {@link ConnectProps.cost}. Implies a private loop. */\n\tcost?: Origin.Cost;\n\n\t/** Backoff settings for the reconnect loop; an unset field uses its default. */\n\tbackoff?: BackoffType;\n\n\t/**\n\t * Credentials to present, kept apart from the URL; see {@link ConnectProps.tokens}. Pass a\n\t * `Signal` to replace them before they expire, or {@link Connection.Dials} to sign a set for\n\t * each dial when it starts, which serves one connection: passing it to another throws.\n\t * Implies a private loop.\n\t */\n\ttokens?: readonly string[] | Signal<readonly string[]> | DialsClass;\n\n\t/**\n\t * Carry the connection credential, the first token, in the URL's `auth` query parameter\n\t * instead of SETUP and `jwt`; see {@link ConnectProps.urlAuth}. Implies a private loop.\n\t */\n\turlAuth?: boolean;\n\n\t/**\n\t * Maximum time for each connection attempt, the dial and the MoQ handshake (default:\n\t * 30 s; `null` waits forever). An attempt that outlives it is retried like any other\n\t * failure. The same bound as the `timeout` option of {@link Connection.connect}.\n\t */\n\ttimeout?: Duration | null;\n\n\t/**\n\t * How to react to the relay's GOAWAY; an unset field uses its default. Every connection\n\t * migrates on GOAWAY, dialing the replacement while the old session finishes its groups.\n\t * This only tunes where it may go and for how long the old session serves.\n\t */\n\tgoaway?: HandoverType;\n\n\t/** A Connection owns the abort signal for each connection attempt. */\n\tsignal?: never;\n\n\t/** A one-shot transport cannot be reused by the reconnect loop; call {@link Connection.connect} instead. */\n\ttransport?: never;\n}\n\n/**\n * A cloneable handle on a MoQ connection: `new Connection({ url })` reconnects and, by\n * default, shares one origin and reconnect loop with handles using the same URL and versions.\n *\n * The shared {@link origin} is wired to both directions. Everything the relay announces\n * lands in it, a publish into it is announced to the relay, and a page that publishes and\n * watches the same path resolves it locally with no round trip.\n *\n * {@link close} releases this handle; the connection survives its last handle by a two-second\n * linger window, so a component torn down and rebuilt reuses the warm connection instead of redialing.\n *\n * The loop reconnects for as long as a handle holds it, so an outage of any length recovers\n * on its own. An auth rejection stops retrying those credentials and retires the shared\n * connection so the next handle dials fresh; a new URL on this handle starts another\n * key. {@link closed} settles only when this handle is released.\n *\n * A relay's GOAWAY migrates rather than drops: the replacement dials at once while the old\n * session finishes its groups, and the handle and its origin carry across. A redirect the\n * `goaway` policy refuses stops the loop like an auth rejection does.\n *\n * Options the pool cannot honor (transport options, backoff, timeout, goaway, tokens, a credential\n * in the URL, a pinned certificate, caller-owned origins) use a private loop. An explicit `share: true`\n * refuses them. A supplied transport cannot reconnect at all; pass it to {@link Connection.connect}\n * instead.\n *\n * @public\n */\nexport class Connection {\n\t/** Tokens a connection asks for at each dial: pass one as `tokens` and answer its {@link Dials.next} dials. */\n\t// fallow-ignore-next-line unused-class-member\n\tstatic readonly Dials = DialsClass;\n\n\t/** Establish a one-shot session; a supplied transport belongs here, not in the reconnect loop. */\n\tstatic readonly connect = connect;\n\n\t/** Accept a one-shot session on an already-open transport. */\n\tstatic readonly accept = accept;\n\n\t/** SHA-256 of a certificate, for pinning via `webtransport.serverCertificateHashes`. */\n\tstatic readonly certificateHash = certificateHash;\n\n\t/** Whether this runtime can connect with WebTransport. */\n\tstatic readonly isWebTransportSupported = isWebTransportSupported;\n\n\t/** Copy a version list that can be offered, throwing a `TypeError` if it is empty or has an unsupported or duplicate name. */\n\tstatic readonly checkVersions = checkVersions;\n\n\t/** Relay URL to connect to; updating it reconnects to that URL. */\n\turl: Signal<URL | undefined>;\n\n\t/** Protocol versions to offer, or undefined for the defaults; updating it reconnects with that list. */\n\tversions: Signal<readonly string[] | undefined>;\n\n\t/** Whether to hold a connection at all; clearing it releases this handle's share. */\n\tenabled: Signal<boolean>;\n\n\t/** Current status of the connection. */\n\treadonly status: Getter<ReloadStatus>;\n\n\t/**\n\t * The failure that stopped retrying the current URL, or undefined while the loop is live.\n\t *\n\t * Set on an auth rejection, when a private retry window expires, or when {@link versions} names\n\t * one this build cannot offer. Cleared when a new URL or version list, or a disable/re-enable,\n\t * starts another key, not on a page hide/show.\n\t */\n\treadonly error: Getter<Error | undefined>;\n\n\t/**\n\t * Why the connection is retrying: how its last attempt or session ended, cleared once a\n\t * session serves again or a new URL starts. Mirrors Rust's `Monitor::failure()`.\n\t */\n\treadonly failure: Getter<Error | undefined>;\n\n\t/**\n\t * The wire transport the current session runs over, or undefined while disconnected.\n\t *\n\t * The session itself is deliberately not exposed: it is shared, so no handle may close\n\t * or reconfigure it, and everything else it offers is reachable through {@link origin}.\n\t */\n\treadonly transport: Getter<TransportType | undefined>;\n\n\t/** Receive estimates while observed, or undefined while disconnected; peek does not request them. */\n\treadonly probe: Getter<ProbeType | undefined>;\n\n\t/** The latest transport counters, sampled while observed on a connection supporting getStats. */\n\treadonly sample: Getter<SampleType | undefined>;\n\n\t/** The current session's liveness, or undefined on a transport that can't probe its peer (WebTransport, qmux-00) or while disconnected. */\n\treadonly liveness: Getter<LivenessType | undefined>;\n\n\t/**\n\t * The send-side bandwidth allocator for the current URL, or undefined\n\t * while disabled or URL-less.\n\t *\n\t * Every handle on this URL shares the same identity, so publishers reserve\n\t * against one registry. Borrowed, not owned: the type has no close, since\n\t * closing it would starve every other handle.\n\t */\n\treadonly allocator: Getter<Handle | undefined>;\n\n\t/**\n\t * The receive-side registry for the current URL, or undefined while disabled or URL-less.\n\t *\n\t * Every handle on this URL shares the same identity, so players watching over one\n\t * connection split its receive estimate instead of each selecting against all of it,\n\t * and their ceilings summed are the PROBE target. Borrowed, not owned: it has no close.\n\t */\n\treadonly viewers: Getter<Pick<Viewers, \"watch\" | \"setTarget\" | \"target\"> | undefined>;\n\n\t/**\n\t * The origin for the current URL, or undefined while disabled or URL-less.\n\t *\n\t * Publish into it or consume from it; a shared handle's origin is the same one every\n\t * other handle on this URL uses, and it spans the connection's reconnects. Borrowed,\n\t * not owned: the type has no close, since closing it would tear the origin down under\n\t * every other handle.\n\t */\n\treadonly origin: Getter<Origin.Table | undefined>;\n\n\t/**\n\t * The auth handle every session presents, or undefined while disabled or URL-less.\n\t *\n\t * Every session the connection makes presents the tokens it holds, so a route naming one\n\t * keeps it across a reconnect, and its grant follows the live session. A private\n\t * connection keeps one handle across URL changes, so its tokens go to the new URL, and\n\t * starts another when `versions` changes. A shared connection's is the one every other\n\t * handle on its URL uses, since they share the session.\n\t */\n\treadonly auth: Getter<Auth.Handle | undefined>;\n\n\t/**\n\t * Settles once this handle is released via {@link close}: `null` on a clean close, or\n\t * the abort {@link Error}. Peek it synchronously (`undefined` while open), observe it\n\t * reactively, or `await` it. Attempt failures live on {@link error} instead.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#closed;\n\t}\n\n\t#closed = new Once<Error | null>();\n\t// Ended with this handle, so whoever answers its dials stops.\n\treadonly #dials?: DialsClass;\n\treadonly #status = new Signal<ReloadStatus>(\"disconnected\");\n\treadonly #established = new Signal<SessionType | undefined>(undefined);\n\treadonly #probe = new Signal<Getter<ProbeType | undefined> | undefined>(undefined);\n\treadonly #origin = new Signal<Origin.Producer | undefined>(undefined);\n\treadonly #allocator = new Signal<Handle | undefined>(undefined);\n\treadonly #viewers = new Signal<Pick<Viewers, \"watch\" | \"setTarget\" | \"target\"> | undefined>(undefined);\n\treadonly #auth = new Signal<Auth.Handle | undefined>(undefined);\n\treadonly #loop = new Signal<Reload | undefined>(undefined);\n\treadonly #error = new Signal<Error | undefined>(undefined);\n\treadonly #failure = new Signal<Error | undefined>(undefined);\n\t#signals: Effect;\n\n\t/**\n\t * Take a handle on the connection for the `url` option.\n\t *\n\t * Dials immediately when a URL is given and `enabled` is not false; otherwise waits for\n\t * the signals to say go. The handle owns nothing but its own share: {@link close}\n\t * releases it, and the underlying connection and origin live for as long as any handle\n\t * (plus the linger window) wants them.\n\t */\n\tconstructor(props?: ConnectionProps) {\n\t\tconst given = props?.versions;\n\t\t// A plain list is checked and copied now, so a bad name throws here and mutating the array\n\t\t// later changes nothing. A live list is checked as it changes, failing on `error`.\n\t\tconst fixed = normalizeVersions({ ...props, versions: Array.isArray(given) ? given : undefined });\n\t\trefuse(props);\n\t\tthis.#signals = new Effect();\n\t\tif (props?.tokens instanceof DialsClass) {\n\t\t\t// One connection answers them: another would sign for this one's dials.\n\t\t\tif (props.tokens.claimed) throw new TypeError(\"these dials already serve another connection\");\n\t\t\tthis.#dials = props.tokens;\n\t\t}\n\n\t\tthis.url = Signal.from(props?.url);\n\t\tthis.versions = Signal.from(Array.isArray(given) ? fixed : given);\n\t\tthis.enabled = Signal.from(props?.enabled ?? true);\n\t\tthis.status = this.#status;\n\t\tthis.error = this.#error;\n\t\tthis.failure = this.#failure;\n\t\tthis.probe = new Follow(this.#probe);\n\t\tthis.sample = new Follow(new Derived([this.#loop], (loop) => loop?.sample));\n\t\tthis.origin = this.#origin;\n\t\tthis.allocator = this.#allocator;\n\t\tthis.viewers = this.#viewers;\n\t\tthis.auth = this.#auth;\n\t\tthis.transport = this.#signals.computed((effect) => effect.get(this.#established)?.transport);\n\t\tthis.liveness = this.#signals.computed((effect) => {\n\t\t\tconst liveness = effect.get(this.#established)?.liveness;\n\t\t\treturn liveness && effect.get(liveness);\n\t\t});\n\n\t\t// Key on the serialized URL: URL objects use identity equality, and an equivalent\n\t\t// instance must not release and redial.\n\t\tconst href = this.#signals.computed((effect) => effect.get(this.url)?.href);\n\n\t\tif (props && (props.share === false || requiresPrivate(props))) {\n\t\t\tthis.#runPrivate(props, href);\n\t\t\t// Only once nothing above threw, so a rejected config leaves the dials free.\n\t\t\tthis.#dials?.claim();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#signals.run((effect) => {\n\t\t\tif (!effect.get(this.enabled)) return;\n\t\t\tconst key = effect.get(href);\n\t\t\tif (!key) return;\n\t\t\tconst versions = offered(effect.get(this.versions));\n\t\t\tif (versions instanceof TypeError) {\n\t\t\t\teffect.set(this.#error, versions, undefined);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst lease = acquire(key, versions);\n\t\t\teffect.cleanup(lease.release);\n\n\t\t\teffect.set(this.#origin, lease.origin, undefined);\n\t\t\teffect.set(this.#allocator, lease.connection.allocator, undefined);\n\t\t\teffect.set(this.#viewers, lease.connection.viewers, undefined);\n\t\t\teffect.set(this.#auth, lease.connection.auth, undefined);\n\t\t\teffect.set(this.#loop, lease.connection, undefined);\n\n\t\t\t// Proxy the shared loop's outputs, so this handle reads like its own connection.\n\t\t\teffect.run((nested) => nested.set(this.#status, nested.get(lease.connection.status), \"disconnected\"));\n\t\t\teffect.run((nested) => nested.set(this.#established, nested.get(lease.connection.established), undefined));\n\t\t\teffect.run((nested) => nested.set(this.#probe, lease.connection.probe, undefined));\n\t\t\teffect.run((nested) => nested.set(this.#error, nested.get(lease.connection.error), undefined));\n\t\t\teffect.run((nested) => nested.set(this.#failure, nested.get(lease.connection.failure), undefined));\n\t\t});\n\t}\n\n\t#runPrivate(props: ConnectionProps, href: Getter<string | undefined>): void {\n\t\tconst owned = props.consume === undefined;\n\t\tconst origin = props.consume ?? new Origin.Producer();\n\t\tif (owned) this.#signals.cleanup(() => origin.close());\n\n\t\tconst publish = props.publish ?? (owned ? origin.consume() : undefined);\n\n\t\t// The origin spans version changes; only the loop dialing it is replaced. Each loop is built\n\t\t// synchronously, not in an effect a microtask later, so its hold on `consume` is in place\n\t\t// before a watcher created alongside could sync on an empty table.\n\t\tlet stop: (() => void) | undefined;\n\t\tconst start = (list: readonly string[] | undefined) => {\n\t\t\tstop?.();\n\t\t\tconst signals = new Effect();\n\t\t\tstop = () => signals.close();\n\n\t\t\tconst versions = offered(list);\n\t\t\tif (versions instanceof TypeError) {\n\t\t\t\tsignals.run((effect) => effect.set(this.#error, versions, undefined));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst loop = new Reload({\n\t\t\t\turl: this.url,\n\t\t\t\tenabled: this.enabled,\n\t\t\t\tpublish,\n\t\t\t\tconsume: origin,\n\t\t\t\tversions,\n\t\t\t\twebtransport: props.webtransport,\n\t\t\t\twebsocket: props.websocket,\n\t\t\t\tbackoff: props.backoff,\n\t\t\t\ttimeout: props.timeout,\n\t\t\t\tcost: props.cost,\n\t\t\t\tgoaway: props.goaway,\n\t\t\t\ttokens: props.tokens,\n\t\t\t\turlAuth: props.urlAuth,\n\t\t\t});\n\t\t\tsignals.cleanup(() => loop.close());\n\n\t\t\tsignals.run((effect) => {\n\t\t\t\tif (!effect.get(this.enabled) || !effect.get(href)) return;\n\t\t\t\teffect.set(this.#origin, origin, undefined);\n\t\t\t\teffect.set(this.#allocator, loop.allocator, undefined);\n\t\t\t\teffect.set(this.#viewers, loop.viewers, undefined);\n\t\t\t\teffect.set(this.#auth, loop.auth, undefined);\n\t\t\t\teffect.set(this.#loop, loop, undefined);\n\t\t\t});\n\t\t\tsignals.run((effect) => effect.set(this.#status, effect.get(loop.status), \"disconnected\"));\n\t\t\tsignals.run((effect) => effect.set(this.#established, effect.get(loop.established), undefined));\n\t\t\tsignals.run((effect) => effect.set(this.#probe, loop.probe, undefined));\n\t\t\tsignals.run((effect) => effect.set(this.#error, effect.get(loop.error), undefined));\n\t\t\tsignals.run((effect) => effect.set(this.#failure, effect.get(loop.failure), undefined));\n\t\t};\n\t\tstart(this.versions.peek());\n\t\tthis.#signals.cleanup(this.versions.subscribe(start));\n\t\tthis.#signals.cleanup(() => stop?.());\n\t}\n\n\t/**\n\t * Subscribe to broadcast announcements at or beneath `prefix`, spanning reconnects\n\t * and URL switches: a switch retracts everything from\n\t * the old relay's origin, then the new one's arrivals stream in.\n\t */\n\tannounced(prefix: Path.Valid = Path.empty(), options?: Announce.Options): Announce.Consumer {\n\t\treturn list(this.routes(prefix, options));\n\t}\n\n\t/**\n\t * Every route change at or beneath `prefix`, spanning reconnects like {@link announced}.\n\t *\n\t * @internal\n\t */\n\troutes(prefix: Path.Valid = Path.empty(), options?: Announce.Options): Routes {\n\t\t// Throw here: inside the effect below, a refused prefix would leave the listing open and empty.\n\t\tPath.Prefix.parse(prefix);\n\t\tPath.encode(prefix);\n\t\tconst producer = new AnnounceProducer();\n\t\tconst consumer = producer.consume();\n\n\t\t// A child of this handle's scope rather than a standalone Effect it merely cleans up\n\t\t// after: the disposer run() hands back also drops itself from the parent, so opening\n\t\t// and closing announcement streams repeatedly does not pile up dead pumps that live\n\t\t// until the whole handle closes.\n\t\tconst stop = this.#signals.run((effect) => {\n\t\t\tconst origin = effect.get(this.#origin);\n\t\t\tif (!origin) {\n\t\t\t\t// Like a reconnecting loop's origin: behind while enabled with nothing to deliver.\n\t\t\t\tif (effect.get(this.enabled)) producer.behind();\n\t\t\t\telse producer.synced();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet routes: Routes;\n\t\t\ttry {\n\t\t\t\troutes = origin.routes(prefix, options);\n\t\t\t} catch (err) {\n\t\t\t\t// The origin's root can still push the prefix past the wire limits: end the listing with why.\n\t\t\t\tproducer.close(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// A URL switch retracts what the old origin announced.\n\t\t\tpumpAnnounced(effect, routes, producer);\n\t\t});\n\n\t\tcloseUnwanted(producer);\n\t\tvoid producer.closed.then(stop);\n\n\t\treturn consumer;\n\t}\n\n\t/** Snapshot the live connection's transport counters, or undefined while disconnected. */\n\t// fallow-ignore-next-line unused-class-member\n\tasync stats(): Promise<StatsType | undefined> {\n\t\treturn this.#established.peek()?.stats();\n\t}\n\n\t/**\n\t * Resolve once the peer first answers the latest {@link ConnectionProps.tokens}, as Rust's\n\t * `Tokens::poll_answered` does: each token the latest set newly presented, or the initial\n\t * ones before any set, is granted in band, or is the connection credential a dial carried and\n\t * the peer accepted. A token the set kept, the connection credential included, counts only\n\t * once the peer refuses it, and nothing is re-checked after the answer. A set replaced before\n\t * its answer moves the wait to the new one, and a connection with no tokens answers at once.\n\t *\n\t * An app that re-signs its credential for each dial can end the connection on a refusal by\n\t * aborting its {@link auth} handle, which makes the loop give up with that error.\n\t *\n\t * Waits while no connection is held, such as before a URL is set.\n\t *\n\t * @throws The peer's refusal, an `Unsupported` error when the session cannot carry a token in\n\t * band, the connection's end such as an abort of its auth handle, or the failure that stopped\n\t * it retrying its URL while no session answered, such as a refused first dial.\n\t */\n\tasync answered(): Promise<void> {\n\t\tfor (;;) {\n\t\t\tconst closed = this.#closed.peek();\n\t\t\tif (closed !== undefined) throw closed ?? new Error(\"connection closed\");\n\t\t\tconst loop = this.#loop.peek();\n\t\t\t// A new loop, such as one a version change built, restarts the wait.\n\t\t\tconst { promise: moved, resolve } = Promise.withResolvers<\"moved\">();\n\t\t\tconst stop = this.#loop.changed(() => resolve(\"moved\"));\n\t\t\t// Closing this handle ends the wait, even with no loop to notice.\n\t\t\tconst closing = this.#closed.changed(() => resolve(\"moved\"));\n\t\t\ttry {\n\t\t\t\tconst answered = loop?.answered().then(() => \"answered\" as const);\n\t\t\t\tif ((await Promise.race(answered ? [answered, moved] : [moved])) === \"answered\") return;\n\t\t\t} finally {\n\t\t\t\tstop();\n\t\t\t\tclosing();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Release this handle. The shared connection drains and closes once its last handle is\n\t * gone and the linger window passes; other handles on the URL are unaffected. Idempotent.\n\t */\n\tclose(abort?: Error): void {\n\t\tthis.#signals.close();\n\t\tthis.#dials?.close();\n\t\tif (this.#closed.peek() === undefined) this.#closed.set(abort ?? null);\n\t}\n}\n\n/** Types on {@link Connection}: the handle is the class, these are its associated types. */\n// fallow-ignore-file unused-namespace-member\nexport namespace Connection {\n\t/** Options for {@link Connection}. @reexport */\n\texport type Props = ConnectionProps;\n\t/** Options for {@link Connection.connect}. @reexport */\n\texport type ConnectProps = ConnectPropsType;\n\t/** Options for {@link Connection.accept}. @reexport */\n\texport type AcceptProps = AcceptPropsType;\n\t/** Backoff settings for a private reconnect loop. @reexport */\n\texport type Backoff = BackoffType;\n\t/** How a connection hands over to a new session after the relay's GOAWAY. @reexport */\n\texport type Handover = HandoverType;\n\t/** What to do with the URI a relay names in its GOAWAY. @reexport */\n\texport type Redirect = RedirectType;\n\t/** A relay's GOAWAY as a session received it. @reexport */\n\texport type Goaway = GoawayType;\n\t/** Current state of a {@link Connection}. @reexport */\n\texport type Status = ReloadStatus;\n\t/** The current connection's PROBE estimates. @reexport */\n\texport type Probe = ProbeType;\n\t/** A point-in-time snapshot of the transport's counters. @reexport */\n\texport type Stats = StatsType;\n\t/** Transport counters with their sampling instant. @reexport */\n\texport type Sample = SampleType;\n\t/** The wire transport a session runs over. @reexport */\n\texport type Transport = TransportType;\n\t/** Tuning for the WebSocket fallback. @reexport */\n\texport type WebSocketProps = WebSocketPropsType;\n\t/** Whether a session heard from its peer within twice its probe interval. @reexport */\n\texport type Liveness = LivenessType;\n\t/** WebTransport options, including friendlier certificate pinning. @reexport */\n\texport type WebTransportProps = WebTransportPropsType;\n\t/** A server certificate hash used to pin a self-signed server. @reexport */\n\texport type CertificateHash = CertificateHashType;\n\t/** An established MoQ session, as a one-shot connect or accept returns it. @reexport */\n\texport type Session = SessionType;\n\t/** Tokens a connection asks for at each dial. @reexport */\n\texport type Dials = DialsClass;\n\t/** One dial waiting for its tokens. @reexport */\n\texport type Dial = DialType;\n}\n\n/** The checked copy of `versions` to dial with, or why it cannot be offered. */\nfunction offered(versions: readonly string[] | undefined): string[] | undefined | TypeError {\n\ttry {\n\t\treturn versions === undefined ? undefined : checkVersions(versions);\n\t} catch (err) {\n\t\tif (err instanceof TypeError) return err;\n\t\tthrow err;\n\t}\n}\n\n/** Throw if `props` cannot be honored, rather than silently dropping them. */\nfunction refuse(props?: ConnectionProps): void {\n\tif (!props) return;\n\n\tconst extra = props as ConnectionProps & { transport?: unknown; signal?: unknown };\n\tif (\"discovery\" in props) throw new TypeError(DISCOVERY_REMOVED);\n\tif (extra.transport) {\n\t\tthrow new Error(\"a supplied transport cannot reconnect; call Connection.connect() instead\");\n\t}\n\tif (extra.signal) {\n\t\tthrow new Error(\"a Connection owns its abort signal; do not pass one\");\n\t}\n\tif (props.share !== true || !requiresPrivate(props)) return;\n\n\tif (props.publish || props.consume) {\n\t\tthrow new Error(\"caller-owned origins cannot be shared; pass share: false\");\n\t}\n\tconst hashes = props.webtransport?.serverCertificateHashes?.length ?? 0;\n\tif (props.webtransport?.serverCertificate !== undefined || hashes > 0) {\n\t\tthrow new Error(\"a pinned certificate cannot be shared; pass share: false\");\n\t}\n\tif (props.webtransport !== undefined) {\n\t\tthrow new Error(\"webtransport options cannot be shared; pass share: false\");\n\t}\n\tif (props.websocket !== undefined) {\n\t\tthrow new Error(\"websocket options cannot be shared; pass share: false\");\n\t}\n\tif (props.backoff !== undefined) {\n\t\tthrow new Error(\"backoff cannot be shared; pass share: false\");\n\t}\n\tif (props.tokens !== undefined) {\n\t\tthrow new Error(\"tokens cannot be shared; pass share: false\");\n\t}\n\tif (props.urlAuth) {\n\t\tthrow new Error(\"urlAuth cannot be shared; pass share: false\");\n\t}\n\tif (props.timeout !== undefined) {\n\t\tthrow new Error(\"timeout cannot be shared; pass share: false\");\n\t}\n\tif (props.goaway !== undefined) {\n\t\tthrow new Error(\"goaway cannot be shared; pass share: false\");\n\t}\n\tif (props.cost !== undefined) {\n\t\tthrow new Error(\"cost cannot be shared; pass share: false\");\n\t}\n}\n\n/** Options tied to one handle cannot be represented by a URL-keyed shared entry. */\nfunction requiresPrivate(props: ConnectionProps): boolean {\n\treturn (\n\t\tprops.webtransport !== undefined ||\n\t\tprops.websocket !== undefined ||\n\t\tprops.backoff !== undefined ||\n\t\tprops.tokens !== undefined ||\n\t\tprops.urlAuth === true ||\n\t\tprops.timeout !== undefined ||\n\t\tprops.goaway !== undefined ||\n\t\tprops.cost !== undefined ||\n\t\tprops.publish !== undefined ||\n\t\tprops.consume !== undefined\n\t);\n}\n\n/** One shared connection and the handles keeping it alive. */\ninterface Entry {\n\t/** The pool key: the dialed URL and versions, moved together on GOAWAY. */\n\tkey: string;\n\torigin: Origin.Producer;\n\tconnection: Reload;\n\trefs: number;\n\ttimer?: () => void;\n}\n\n/** The process-wide pool backing {@link Connection}. */\nconst pool = new Map<string, Entry>();\n\n// Preserve the ordered versions when a redirect moves the URL.\nfunction poolKey(url: string, versions?: readonly string[]): string {\n\treturn JSON.stringify([url, versions]);\n}\n\n/** Take a reference on the shared entry, creating it on first use. */\nfunction acquire(url: string, versions?: readonly string[]): Entry & { release: () => void } {\n\tconst key = poolKey(url, versions);\n\tlet entry = pool.get(key);\n\tif (!entry) {\n\t\tconst origin = new Origin.Producer();\n\t\tconst connection = new Reload({\n\t\t\turl: new URL(url),\n\t\t\tversions,\n\t\t\tenabled: true,\n\t\t\tpublish: origin.consume(),\n\t\t\tconsume: origin,\n\t\t});\n\n\t\tconst created: Entry = { key, origin, connection, refs: 0 };\n\n\t\t// The loop only stops on a peer saying these credentials will never work, or on a\n\t\t// GOAWAY redirect it refused. Drop the entry so a later handle dials fresh rather\n\t\t// than joining a loop that has stopped; handles already on it keep it until they\n\t\t// release.\n\t\tconnection.error.subscribe((err) => {\n\t\t\tif (err !== undefined && pool.get(created.key) === created) pool.delete(created.key);\n\t\t});\n\n\t\t// The entry follows the URL its loop dials: an accepted redirect moves it to the\n\t\t// target, so a later handle configured with that URL shares it and one asking for\n\t\t// the old URL dials fresh, and a dead target's dropped redirect moves it back to the\n\t\t// configured URL. A live entry already at the new key wins: this one leaves the pool\n\t\t// and serves only the handles it has until they release it.\n\t\tconst configured = key;\n\t\tconnection.redirect.subscribe((redirect) => {\n\t\t\tconst key = redirect ? poolKey(redirect.href, versions) : configured;\n\t\t\tif (key === created.key) return;\n\t\t\tif (pool.get(created.key) === created) pool.delete(created.key);\n\t\t\tcreated.key = key;\n\t\t\tif (!pool.has(created.key)) pool.set(created.key, created);\n\t\t});\n\n\t\tentry = created;\n\t\tpool.set(key, created);\n\t}\n\n\tconst taken = entry;\n\ttaken.refs += 1;\n\tif (taken.timer !== undefined) {\n\t\ttaken.timer();\n\t\ttaken.timer = undefined;\n\t}\n\n\tlet released = false;\n\treturn {\n\t\t...taken,\n\t\trelease: () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\n\t\t\ttaken.refs -= 1;\n\t\t\tif (taken.refs > 0) return;\n\n\t\t\t// Don't hold a Node process open for a connection nobody is using.\n\t\t\ttaken.timer = after(\n\t\t\t\tLINGER,\n\t\t\t\t() => {\n\t\t\t\t\tif (pool.get(taken.key) === taken) pool.delete(taken.key);\n\t\t\t\t\ttaken.connection.close();\n\t\t\t\t\ttaken.origin.close();\n\t\t\t\t},\n\t\t\t\t{ ref: false },\n\t\t\t);\n\t\t},\n\t};\n}\n\n/**\n * Close every shared connection immediately, so the next handle dials fresh.\n *\n * Exists for tests, which otherwise share connections across cases.\n *\n * @internal\n */\nexport function resetShared(): void {\n\tconst entries = [...pool.values()];\n\tpool.clear();\n\tfor (const entry of entries) {\n\t\tentry.timer?.();\n\t\tentry.connection.close();\n\t\tentry.origin.close();\n\t}\n}\n"]}
|
package/connection/reload.d.ts
CHANGED
|
@@ -1,25 +1,73 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Duration } from "@moq/clock";
|
|
2
2
|
/**
|
|
3
3
|
* Exponential backoff settings for the reconnect loop.
|
|
4
4
|
*
|
|
5
5
|
* The delays carry jitter, so a fleet of tabs knocked offline together doesn't reconnect in
|
|
6
|
-
* lockstep.
|
|
7
|
-
*
|
|
6
|
+
* lockstep. Nothing retries until a session to the current URL has been established: the peer
|
|
7
|
+
* accepts the connection credential (its SETUP, or on moq-lite-07 the AUTH_OK to the
|
|
8
|
+
* connection's own credential) or drains the session with a GOAWAY, which no refusal sends. On
|
|
9
|
+
* moq-lite 03/04, which answer the credential with nothing, staying up past
|
|
10
|
+
* {@link Backoff.healthy} establishes it too; a version with an answer waits for it however long
|
|
11
|
+
* the session stays up. An attempt failing, or a session closing sooner, stops that
|
|
12
|
+
* URL with its error. That covers a relay refusing a live session, as it does a rejected token
|
|
13
|
+
* on moq-lite 03 or later. After that, every failure is retried,
|
|
14
|
+
* including an attempt that outlives {@link ConnectProps.timeout}, until
|
|
15
|
+
* {@link Backoff.timeout} runs out, whatever the error, an auth rejection included; only a
|
|
16
|
+
* refused GOAWAY redirect stops the current URL sooner. A new URL or a disable/re-enable starts another sequence.
|
|
17
|
+
* Tokens from {@link Dials} fail fast the same way, with the failure on the connection's `error`
|
|
18
|
+
* rather than a dial; once a session was established, each redial asks the app, which reads why
|
|
19
|
+
* the last one failed on {@link Dial.failure} and stops the URL by failing the dial.
|
|
20
|
+
*
|
|
21
|
+
* A GOAWAY off a session that outlived {@link Backoff.healthy} migrates at once, unless it
|
|
22
|
+
* sends the connection back to an endpoint that already redirected it elsewhere and the
|
|
23
|
+
* session lived less than {@link Backoff.max} (or {@link Backoff.healthy} when
|
|
24
|
+
* uncapped). Two peers redirecting to each other thus
|
|
25
|
+
* wait out this backoff and count against the timeout.
|
|
8
26
|
*/
|
|
9
|
-
export type
|
|
10
|
-
/** The delay before reconnecting (default: 1000ms). */
|
|
11
|
-
initial?:
|
|
12
|
-
/** The multiplier for the delay (default: 2). */
|
|
27
|
+
export type Backoff = {
|
|
28
|
+
/** The delay before reconnecting (default: 1000ms; zero retries at once). */
|
|
29
|
+
initial?: Duration;
|
|
30
|
+
/** The multiplier for the delay after each failure (default: 2; below 1 keeps it constant). */
|
|
13
31
|
multiplier?: number;
|
|
14
|
-
/**
|
|
15
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The maximum delay (default: 5000ms; `null` leaves it uncapped; zero retries at once). A cap
|
|
34
|
+
* below `initial` caps the first delay too.
|
|
35
|
+
*/
|
|
36
|
+
max?: Duration | null;
|
|
37
|
+
/**
|
|
38
|
+
* How long a session must stay up to count as healthy (default: 1000ms; must be positive).
|
|
39
|
+
*
|
|
40
|
+
* Where the peer never answers the connection credential, as on moq-lite 03/04, the first
|
|
41
|
+
* healthy session establishes the URL. Elsewhere only the peer's answer or a GOAWAY does,
|
|
42
|
+
* however long a session stays up.
|
|
43
|
+
* A healthy session's end resets the delay and the timeout. One that ends sooner is a
|
|
44
|
+
* failed attempt, so a peer that accepts and then drops every session still escalates the
|
|
45
|
+
* delay and exhausts the timeout.
|
|
46
|
+
*/
|
|
47
|
+
healthy?: Duration;
|
|
16
48
|
/**
|
|
17
49
|
* Maximum total time to spend retrying the current URL before giving up
|
|
18
|
-
* (default:
|
|
19
|
-
* disable/re-enable.
|
|
50
|
+
* (default: `null`, unlimited; zero gives up at the first failure). Counts from the first dial, and restarts after a healthy session
|
|
51
|
+
* outside a redirect loop, a URL change, or a disable/re-enable. It decides whether another
|
|
52
|
+
* attempt starts and never cuts one that is running, so giving up can take up to one attempt
|
|
53
|
+
* longer than the window; {@link ConnectProps.timeout} bounds each attempt. A peer that
|
|
54
|
+
* restarts, draining each session with a GOAWAY naming no URI, restarts it too.
|
|
20
55
|
*/
|
|
21
|
-
timeout?:
|
|
56
|
+
timeout?: Duration | null;
|
|
22
57
|
};
|
|
23
58
|
/** Current state of a reconnecting connection. */
|
|
24
59
|
export type ReloadStatus = "connecting" | "connected" | "disconnected";
|
|
60
|
+
/**
|
|
61
|
+
* A run of GOAWAY redirects, and whether it has revisited an endpoint. The peer picks every
|
|
62
|
+
* hop, so remembering them all would grow without bound. Brent's cycle detection instead keeps
|
|
63
|
+
* one departed endpoint, replaced at doubling intervals, and catches a cycle of any length
|
|
64
|
+
* within a few laps of it. Once caught, the run stays a loop until reset.
|
|
65
|
+
*/
|
|
66
|
+
export declare class Redirects {
|
|
67
|
+
#private;
|
|
68
|
+
/** Record leaving `from` for a different endpoint `to`, and return whether this run loops. */
|
|
69
|
+
move(from: string, to: string): boolean;
|
|
70
|
+
/** Start a new run. */
|
|
71
|
+
reset(): void;
|
|
72
|
+
}
|
|
25
73
|
//# sourceMappingURL=reload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload.d.ts","sourceRoot":"","sources":["../../src/connection/reload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reload.d.ts","sourceRoot":"","sources":["../../src/connection/reload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA4B,MAAM,YAAY,CAAC;AA6ChE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,OAAO,GAAG;IACrB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB,+FAA+F;IAC/F,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEtB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC1B,CAAC;AAsGF,kDAAkD;AAClD,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,CAAC;AA4lCvE;;;;;GAKG;AACH,qBAAa,SAAS;;IAMrB,8FAA8F;IAC9F,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAQtC;IAED,uBAAuB;IACvB,KAAK,IAAI,IAAI,CAKZ;CACD"}
|