@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/fill.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill.js","sourceRoot":"","sources":["../src/fill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAgC,MAAM,EAAE,MAAM,cAAc,CAAC;AAIpE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,QA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C,CAAC;IAC5C,CAAC;IAED,0CAA0C;IAC1C,CAAC,MAAM,CAAC,OAAO,CAAC;QACf,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC;CACD","sourcesContent":["/**\n * Serving the groups a track's readers miss: the on-demand request surface. Mirrors the Rust\n * `track::Requests` and `track::FillGroups` (`rs/moq-net/src/model/track/fill.rs`).\n *\n * A reader misses a group its ranges name that the track no longer caches, or never did, below\n * the newest group the producer wrote: nothing above it is a miss, since it arrives live. While a\n * {@link Requests} handle is open, each run of misses queues a {@link FillGroups} for it to serve, and\n * readers missing the same groups join the one fill rather than asking twice. With none open, a\n * miss is given up as it always was. A handle is also the only writer of a group below the newest\n * one, so the last one closing skips what the track's own publisher left unproduced there.\n *\n * @module\n */\nimport { type GetPromise, type Getter, Signal } from \"@moq/signals\";\nimport type { Skipped, TimestampMismatch } from \"./error.ts\";\nimport type { Info as FrameInfo, Producer as FrameProducer } from \"./frame.ts\";\nimport type { Frame, Producer as GroupProducer } from \"./group.ts\";\nimport { cutRun, hooks, insertRun, runGaps, runsFrom } from \"./internal.ts\";\nimport type { Info, Order } from \"./track.ts\";\nimport { checkEnd, checkKey, max, min } from \"./util/key.ts\";\n\n// A half-open run of group keys, as `internal.ts` has it, kept local so the published\n// declarations never reach the package internals.\ntype Run = { start: bigint; end: bigint };\n\n/**\n * What the fills need from the track they serve.\n *\n * @internal\n */\nexport interface FillTrack {\n\t/** The track's name. */\n\treadonly name: string;\n\t/** Insert group `key` into the cache, committing `info` first if the track has none. */\n\taccept(key: bigint, info: Info | undefined): GroupProducer;\n\t/** Record `[start, end)` as never to be delivered: the source does not have them. */\n\tdrop(start: bigint, end: bigint): void;\n\t/**\n\t * Whether the track still caches group `key`, not failed: `\"headless\"` for a copy missing\n\t * its first frames, which a fill from frame 0 replaces.\n\t */\n\tholds(key: bigint): boolean | \"headless\";\n\t/** The group the track caches at `key`, if any. */\n\tcached(key: bigint): GroupProducer | undefined;\n\t/** Whether the track closed, so nothing more can be served. */\n\tclosed(): boolean;\n\t/** Settles once the track closes. */\n\treadonly released: GetPromise<unknown>;\n\t/** Create a group at any key, as {@link Requests.createGroup} does. */\n\tcreateGroup(frame: Frame): GroupProducer;\n\t/** Create a group at any key with its first frame streamed, as {@link Requests.createFrame} does. */\n\tcreateFrame(info: FrameInfo): FrameProducer;\n\t/** Give up `[start, end)` as not found, as {@link Requests.dropGroups} does. */\n\tdropGroups(start: bigint, end: bigint): void;\n\t/** Skip `[start, end)`, as {@link Requests.skipGroups} does. */\n\tskipGroups(start: bigint, end: bigint): void;\n\t/**\n\t * Once no handler is left to create them, skip the keys below the newest group the track's own\n\t * publisher never produced, except `taken`, which a fill already handed out still answers.\n\t */\n\tskipUnclaimed(taken: readonly Run[]): void;\n}\n\n/**\n * A reader waiting on fills.\n *\n * @internal\n */\nexport interface Asker {\n\t/** The parts of `[start, end)` it still reads. */\n\twants(start: bigint, end: bigint): Run[];\n\t/** Its delivery priority. */\n\tpriority(): number;\n\t/** Which end it reads first. */\n\torder(): Order;\n\t/** Stop waiting for `[start, end)`, which a fill refused with `error`, without asking again. */\n\trefuse(start: bigint, end: bigint, error: Error): void;\n}\n\n// The fill operations a handle runs against the state it came from; assigned in its static block.\nlet fillOps: {\n\taccept(state: FillState, pending: Pending, key: bigint, info: Info | undefined): GroupProducer | undefined;\n\tanswerCached(state: FillState, pending: Pending, key: bigint): boolean;\n\tdrop(state: FillState, pending: Pending, start: bigint, end: bigint): void;\n\trefuse(state: FillState, pending: Pending, start: bigint, end: bigint, error: Error): void;\n\tsettle(state: FillState, pending: Pending): void;\n\tname(state: FillState): string;\n\ttrack(state: FillState): FillTrack;\n};\n\n// A part of a fill's run it still owes.\ntype Live = Run & { pending: Pending };\n\n// One fill: a run of groups some readers miss, until each is answered or nobody wants it.\nclass Pending {\n\treadonly start: bigint;\n\treadonly end: bigint;\n\t// The oldest key the first group may start at: below `start` for a time start, whose group is\n\t// the newest one starting at or before it.\n\treadonly floor: bigint;\n\t// A time start's, which no other reader joins: it owes its key while its reader waits on it,\n\t// whatever the reader's window reads, as the Rust `Join` holds its key.\n\treadonly exclusive: boolean;\n\treadonly askers = new Set<Asker>();\n\t// The groups answered: accepted, delivered live, dropped, or refused.\n\treadonly resolved: Run[] = [];\n\t// The groups no reader read any more at some point: withdrawn for good, so a handler that\n\t// stopped serving one is never asked for it again. A reader widening back asks a new fill.\n\treadonly withdrawn: Run[] = [];\n\t// Still in the queue, not yet handed to a handler.\n\tqueued = true;\n\t// Withdrawn or settled: owes nothing more.\n\tdone = false;\n\t// Bumped on every change to what the fill owes, for its handler to wake on.\n\treadonly revision = new Signal(0);\n\t// What a time start's handler answered.\n\tanswer?: TimeStart;\n\n\tconstructor(start: bigint, end: bigint, floor = start, exclusive = false) {\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t\tthis.floor = floor;\n\t\tthis.exclusive = exclusive;\n\t}\n\n\tbump(): void {\n\t\tthis.revision.update((revision) => revision + 1);\n\t}\n\n\t// The parts of `[start, end)` within the fill still unanswered and not withdrawn.\n\tunresolved(start = this.start, end = this.end): Run[] {\n\t\tif (this.done) return [];\n\t\treturn runGaps(this.resolved, max(start, this.start), min(end, this.end)).flatMap((gap) =>\n\t\t\trunGaps(this.withdrawn, gap.start, gap.end),\n\t\t);\n\t}\n\n\t// The parts of `[start, end)` still unanswered that a reader still reads.\n\towed(start = this.start, end = this.end): Run[] {\n\t\tif (this.exclusive) return this.askers.size > 0 ? this.unresolved(start, end) : [];\n\t\tconst owed: Run[] = [];\n\t\tfor (const gap of this.unresolved(start, end)) {\n\t\t\tfor (const asker of this.askers) {\n\t\t\t\tfor (const run of asker.wants(gap.start, gap.end)) insertRun(owed, run.start, run.end);\n\t\t\t}\n\t\t}\n\t\treturn owed;\n\t}\n}\n\n/**\n * The fills of one track: what its readers miss, queued for its {@link Requests} handles. A\n * producer owns one.\n *\n * @internal\n */\nexport class FillState {\n\treadonly #track: FillTrack;\n\t#handlers = 0;\n\t#queue: Pending[] = [];\n\treadonly #queued = new Signal(0);\n\treadonly #pending = new Set<Pending>();\n\t// What each fill still owes, by key: its unanswered, unwithdrawn parts, which no two fills\n\t// share, so a reader's ask or an arrival costs the fills it touches, never every fill out.\n\t#live: Live[] = [];\n\t// The time starts' fills out, by their key, which no live part holds: a group landing there\n\t// answers each, as the Rust `FillGroups::wanted` finds it cached.\n\treadonly #starts = new Map<bigint, Set<Pending>>();\n\t// Bumped as each handler opens, so readers parked on a miss nobody could take ask again.\n\treadonly #opened = new Signal(0);\n\n\tconstructor(track: FillTrack) {\n\t\tthis.#track = track;\n\t\tvoid track.released.then(() => this.#release());\n\t}\n\n\t/** Whether a handler is open to serve a miss now. */\n\tget serving(): boolean {\n\t\treturn this.#handlers > 0 && !this.#track.closed();\n\t}\n\n\t/** Whether a fill is out that a reader could join, handler or not. */\n\tget active(): boolean {\n\t\treturn this.#pending.size > 0;\n\t}\n\n\t/**\n\t * Ask for `[start, end)` for `asker`: join the fills already bringing part of it, and queue the\n\t * rest while a handler is open, as the Rust `FillState::join` does. Returns the parts now\n\t * asked, in order.\n\t */\n\task(start: bigint, end: bigint, asker: Asker): Run[] {\n\t\tif (start >= end || this.#track.closed()) return [];\n\t\tconst asked: Run[] = [];\n\t\tfor (const live of this.#overlapping(start, end)) {\n\t\t\tif (!live.pending.askers.has(asker)) {\n\t\t\t\tlive.pending.askers.add(asker);\n\t\t\t\tlive.pending.bump();\n\t\t\t}\n\t\t\tinsertRun(asked, max(live.start, start), min(live.end, end));\n\t\t}\n\t\tif (this.#handlers === 0) return asked;\n\t\tconst missing = runGaps(asked, start, end);\n\t\tfor (const gap of missing) {\n\t\t\tconst pending = new Pending(gap.start, gap.end);\n\t\t\tpending.askers.add(asker);\n\t\t\tthis.#pending.add(pending);\n\t\t\tthis.#queue.push(pending);\n\t\t\tthis.#live.splice(runsFrom(this.#live, gap.start), 0, { start: gap.start, end: gap.end, pending });\n\t\t\tinsertRun(asked, gap.start, gap.end);\n\t\t}\n\t\tif (missing.length > 0) this.#queued.update((revision) => revision + 1);\n\t\treturn asked;\n\t}\n\n\t/**\n\t * Queue a fill of the group containing `time` for `asker`: the group starting at it, or else the\n\t * newest one before it, starting at or after `floor`, as the Rust `FillState::time_start` does.\n\t * No other reader joins it. Undefined while no handler is open to answer it.\n\t */\n\ttimeStart(time: bigint, floor: bigint, asker: Asker): Lookup | undefined {\n\t\tif (this.#handlers === 0 || this.#track.closed()) return undefined;\n\t\tconst pending = new Pending(time, time + 1n, min(floor, time), true);\n\t\tpending.askers.add(asker);\n\t\tthis.#pending.add(pending);\n\t\tconst starts = this.#starts.get(time) ?? new Set();\n\t\tstarts.add(pending);\n\t\tthis.#starts.set(time, starts);\n\t\tthis.#queue.push(pending);\n\t\tthis.#queued.update((revision) => revision + 1);\n\t\treturn {\n\t\t\tanswer: () => pending.answer,\n\t\t\tdone: () => pending.done,\n\t\t\tchanged: pending.revision,\n\t\t\tleave: () => this.leave(asker, pending),\n\t\t};\n\t}\n\n\t/**\n\t * The parts of `[start, end)` a fill `asker` joined still owes it, merged and in order: only what it still\n\t * reads, as the Rust `Join::held` holds, so a wider fill shared with other readers owes it\n\t * nothing outside its own ranges.\n\t */\n\t*covered(start: bigint, end: bigint, asker: Asker): Generator<Run> {\n\t\t// Walked lazily, so a caller wanting only the first run costs only the fills up to it.\n\t\tlet run: Run | undefined;\n\t\tfor (let i = runsFrom(this.#live, start); i < this.#live.length && this.#live[i].start < end; i++) {\n\t\t\tconst live = this.#live[i];\n\t\t\tif (!live.pending.askers.has(asker)) continue;\n\t\t\tfor (const part of asker.wants(max(live.start, start), min(live.end, end))) {\n\t\t\t\tif (run && run.end === part.start) run.end = part.end;\n\t\t\t\telse {\n\t\t\t\t\tif (run) yield run;\n\t\t\t\t\trun = { ...part };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (run) yield run;\n\t}\n\n\t/** The parts of `[start, end)` a fill out, queued or taken, still owes, in order. */\n\towing(start: bigint, end: bigint): Run[] {\n\t\treturn this.#overlapping(start, end).map((live) => ({\n\t\t\tstart: max(live.start, start),\n\t\t\tend: min(live.end, end),\n\t\t}));\n\t}\n\n\t/** `asker` left `only`, or every fill: the fills it alone waited on are withdrawn. */\n\tleave(asker: Asker, only?: Pending): void {\n\t\tfor (const pending of only ? [only] : this.#pending) {\n\t\t\tif (!pending.askers.delete(asker)) continue;\n\t\t\tthis.#judge(pending);\n\t\t}\n\t}\n\n\t/**\n\t * What `asker` reads in `[start, end)` changed: a fill nobody reads any more is withdrawn. Only\n\t * the fills still owing a group there are judged again, so a change costs what it touches.\n\t */\n\tmoved(asker: Asker, start = 0n, end?: bigint): void {\n\t\tconst judged = new Set<Pending>();\n\t\tfor (const live of end === undefined\n\t\t\t? this.#live.slice(runsFrom(this.#live, start))\n\t\t\t: this.#overlapping(start, end)) {\n\t\t\tif (live.pending.askers.has(asker)) judged.add(live.pending);\n\t\t}\n\t\tfor (const pending of judged) this.#judge(pending);\n\t}\n\n\t/** Group `key` landed in the cache, through a fill or live: it is answered. */\n\tarrived(key: bigint): void {\n\t\tconst [live] = this.#overlapping(key, key + 1n);\n\t\tif (live) this.#resolve(live.pending, key, key + 1n);\n\t\tfor (const pending of this.#starts.get(key) ?? []) {\n\t\t\tpending.answer = { kind: \"group\", group: key };\n\t\t\tthis.#resolve(pending, key, key + 1n);\n\t\t}\n\t}\n\n\t/**\n\t * `[start, end)` was given up, by a fill or otherwise: nobody waits for it from a fill. A head\n\t * of a group the cache holds is left to its own fill, as the Rust `drop_groups` touches no\n\t * fill: a drop of that group, such as an earlier SUBSCRIBE_DROP arriving late, says nothing of\n\t * whether its source can still bring frame 0.\n\t */\n\tdropped(start: bigint, end: bigint): void {\n\t\tconst owing = new Set<Pending>();\n\t\tfor (const live of this.#overlapping(start, end)) {\n\t\t\t// A held group is no miss, so the only fill owing it is its head's, one group wide.\n\t\t\tif (live.end - live.start === 1n && this.#track.holds(live.start) === \"headless\") continue;\n\t\t\towing.add(live.pending);\n\t\t}\n\t\tfor (const pending of owing) this.#resolve(pending, start, end);\n\t}\n\n\t// The keys a fill a handler already took still answers, but `ending`'s. A time start covers no\n\t// key, but until answered may answer any from its floor through its time.\n\t#taken(ending?: Pending): Run[] {\n\t\tconst taken: Run[] = [];\n\t\tfor (const live of this.#live) {\n\t\t\tif (!live.pending.queued && live.pending !== ending) insertRun(taken, live.start, live.end);\n\t\t}\n\t\tfor (const pending of this.#pending) {\n\t\t\tconst open = !pending.queued && !pending.done && pending.answer === undefined;\n\t\t\tif (pending.exclusive && open && pending !== ending) insertRun(taken, pending.floor, pending.end);\n\t\t}\n\t\treturn taken;\n\t}\n\n\t// The live parts overlapping `[start, end)`, lowest first.\n\t#overlapping(start: bigint, end: bigint): Live[] {\n\t\tconst found: Live[] = [];\n\t\tfor (let i = runsFrom(this.#live, start); i < this.#live.length && this.#live[i].start < end; i++)\n\t\t\tfound.push(this.#live[i]);\n\t\treturn found;\n\t}\n\n\t// Take `runs` of `pending` out of the live parts, once it no longer owes them. A time start's\n\t// fill was never among them.\n\t#settled(pending: Pending, runs: readonly Run[]): void {\n\t\tif (pending.exclusive) return;\n\t\tfor (const run of runs) cutRun(this.#live, run.start, run.end);\n\t}\n\n\t/** Bumped as each handler opens: a reader parked on a miss watches it to ask again. */\n\tget opened(): Getter<number> {\n\t\treturn this.#opened;\n\t}\n\n\t/** Open a handler, waking the readers parked on a miss to ask it. */\n\taddHandler(): void {\n\t\tthis.#handlers++;\n\t\tthis.#opened.update((opened) => opened + 1);\n\t}\n\n\t/**\n\t * Close a handler. The last one leaving was the only writer that could create a key below the\n\t * newest group, so what the track's own publisher left unproduced there is skipped first, then\n\t * every queued miss is named dropped, as with none open: a reader waiting on a skipped key sees\n\t * the skip, not the dropped fill. A key a fill already handed out still answers stays with it.\n\t */\n\tremoveHandler(): void {\n\t\tthis.#handlers--;\n\t\tif (this.#handlers > 0) return;\n\t\tthis.#track.skipUnclaimed(this.#taken());\n\t\t// A time start nobody took is left unanswered, as the Rust `release_queued` ends it.\n\t\tfor (const pending of this.#queue.splice(0)) {\n\t\t\tif (pending.exclusive) this.#finish(pending);\n\t\t\telse this.#settle(pending);\n\t\t}\n\t}\n\n\t/**\n\t * The next queued fill, or `undefined` once the track closes with none queued or `closed`, the\n\t * asking handle's, is set.\n\t */\n\tasync next(closed: Signal<boolean>): Promise<Pending | undefined> {\n\t\tfor (;;) {\n\t\t\tif (closed.peek()) return undefined;\n\t\t\tconst pending = this.#queue.shift();\n\t\t\tif (pending) {\n\t\t\t\tpending.queued = false;\n\t\t\t\treturn pending;\n\t\t\t}\n\t\t\tif (this.#track.closed()) return undefined;\n\t\t\tawait Signal.race(this.#queued, this.#track.released, closed);\n\t\t}\n\t}\n\n\t// Withdraw what no reader reads any more for good, and `pending` once that is all of it.\n\t#judge(pending: Pending): void {\n\t\tif (pending.done) return;\n\t\tconst owed = pending.owed();\n\t\tconst withdrawn: Run[] = [];\n\t\tfor (const gap of pending.unresolved()) {\n\t\t\tfor (const run of runGaps(owed, gap.start, gap.end)) {\n\t\t\t\tinsertRun(pending.withdrawn, run.start, run.end);\n\t\t\t\twithdrawn.push(run);\n\t\t\t}\n\t\t}\n\t\tthis.#settled(pending, withdrawn);\n\t\tif (owed.length > 0) {\n\t\t\tpending.bump();\n\t\t\treturn;\n\t\t}\n\t\tthis.#finish(pending);\n\t}\n\n\t// Record `[start, end)` of `pending` answered.\n\t#resolve(pending: Pending, start: bigint, end: bigint): void {\n\t\tconst unresolved = pending.unresolved(start, end);\n\t\tif (unresolved.length === 0) return;\n\t\tfor (const run of unresolved) insertRun(pending.resolved, run.start, run.end);\n\t\tthis.#settled(pending, unresolved);\n\t\tif (pending.unresolved().length === 0) this.#finish(pending);\n\t\telse pending.bump();\n\t}\n\n\t// Answer what `pending` still owes as dropped, then forget it.\n\t#settle(pending: Pending): void {\n\t\tconst owed = pending.owed();\n\t\tif (pending.exclusive && owed.length > 0) pending.answer ??= { kind: \"dropped\" };\n\t\tfor (const run of owed) this.#track.drop(run.start, run.end);\n\t\tthis.#finish(pending);\n\t}\n\n\t// Forget `pending`: it owes nothing more.\n\t#finish(pending: Pending): void {\n\t\tif (pending.done) return;\n\t\tthis.#settled(pending, pending.unresolved());\n\t\tpending.done = true;\n\t\tthis.#pending.delete(pending);\n\t\tconst starts = pending.exclusive ? this.#starts.get(pending.start) : undefined;\n\t\tif (starts?.delete(pending) && starts.size === 0) this.#starts.delete(pending.start);\n\t\tif (pending.queued) this.#queue.splice(this.#queue.indexOf(pending), 1);\n\t\tpending.bump();\n\t}\n\n\t#release(): void {\n\t\tthis.#queue = [];\n\t\tfor (const pending of this.#pending) this.#finish(pending);\n\t\tthis.#live = [];\n\t\tthis.#queued.update((revision) => revision + 1);\n\t}\n\n\tstatic {\n\t\tfillOps = {\n\t\t\taccept: (state, pending, key, info) => {\n\t\t\t\tif (key < pending.floor || key >= pending.end) {\n\t\t\t\t\tthrow new RangeError(`group ${key} is outside the fill ${pending.floor}..${pending.end}`);\n\t\t\t\t}\n\t\t\t\t// A key below the start answers the start, so no other group starts from it through the\n\t\t\t\t// start.\n\t\t\t\tlet answers = key;\n\t\t\t\tif (answers < pending.start) answers = pending.start;\n\t\t\t\tif (pending.resolved.some((run) => run.start <= answers && answers < run.end)) return undefined;\n\t\t\t\t// A copy missing its head is replaced from frame 0, as a bounded reader asked. Landing in\n\t\t\t\t// the cache answers it, as `arrived` records.\n\t\t\t\tconst group = state.#track.holds(key) === true ? undefined : state.#track.accept(key, info);\n\t\t\t\t// A time start's fill is no live part, and a group below its key lands nowhere it owes.\n\t\t\t\tif (pending.exclusive && !pending.done) {\n\t\t\t\t\t// Below the time, it holds the group it names, created or cached, so its End stays known\n\t\t\t\t\t// once the cache lets it go.\n\t\t\t\t\tconst answer = key < pending.start ? (group ?? state.#track.cached(key)) : undefined;\n\t\t\t\t\tpending.answer = { kind: \"group\", group: key, answer };\n\t\t\t\t\tstate.#resolve(pending, pending.start, pending.end);\n\t\t\t\t}\n\t\t\t\treturn group;\n\t\t\t},\n\t\t\t// Answer owed `key` from the cache if the track holds it whole, as an arrival would. Returns\n\t\t\t// whether it did.\n\t\t\tanswerCached: (state, pending, key) => {\n\t\t\t\tif (state.#track.holds(key) !== true) return false;\n\t\t\t\tif (pending.exclusive) {\n\t\t\t\t\tpending.answer = { kind: \"group\", group: key };\n\t\t\t\t\tstate.#resolve(pending, pending.start, pending.end);\n\t\t\t\t} else state.#resolve(pending, key, key + 1n);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tdrop: (state, pending, start, end) => {\n\t\t\t\tconst owed = pending.owed(start, end);\n\t\t\t\tif (pending.exclusive && owed.length > 0) pending.answer ??= { kind: \"dropped\" };\n\t\t\t\tfor (const run of owed) {\n\t\t\t\t\tstate.#track.drop(run.start, run.end);\n\t\t\t\t}\n\t\t\t\tstate.#resolve(pending, start, end);\n\t\t\t},\n\t\t\trefuse: (state, pending, start, end, error) => {\n\t\t\t\t// A time start's refusal reaches its reader through the lookup, as the error its\n\t\t\t\t// reads fail with, not as a group given up.\n\t\t\t\tif (pending.exclusive) {\n\t\t\t\t\tif (pending.unresolved(start, end).length > 0) pending.answer ??= { kind: \"refused\", error };\n\t\t\t\t\tstate.#resolve(pending, start, end);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (const gap of pending.unresolved(start, end)) {\n\t\t\t\t\tfor (const asker of pending.askers) {\n\t\t\t\t\t\tfor (const run of asker.wants(gap.start, gap.end)) asker.refuse(run.start, run.end, error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstate.#resolve(pending, start, end);\n\t\t\t},\n\t\t\tsettle: (state, pending) => {\n\t\t\t\t// The last handler may have left while this fill was out, leaving no one to create what\n\t\t\t\t// it still owes: that is skipped with the rest left unproduced below the newest group,\n\t\t\t\t// as the handler's close would have, before the fill names what remains dropped.\n\t\t\t\tif (state.#handlers === 0) state.#track.skipUnclaimed(state.#taken(pending));\n\t\t\t\tstate.#settle(pending);\n\t\t\t},\n\t\t\tname: (state) => state.#track.name,\n\t\t\ttrack: (state) => state.#track,\n\t\t};\n\t}\n}\n\n/** The still-wanted runs of a fill, in ascending order. @internal */\nexport let wantedRuns: (fill: FillGroups) => Run[];\n/**\n * Wait for a change to the groups or readers of a fill, which a lost {@link race} releases.\n * @internal\n */\nexport let fillChanged: (fill: FillGroups) => GetPromise<unknown>;\n/**\n * What a time start's handler answered: the group containing the time, no group from the floor\n * through it, or a refusal saying nothing of where it falls. Mirrors the Rust `fill::TimeStart`.\n *\n * @internal\n */\nexport type TimeStart =\n\t/**\n\t * The group containing the time, and the group that answered it below the time, held so where it\n\t * ends is known once the cache lets it go.\n\t */\n\t{ kind: \"group\"; group: bigint; answer?: GroupProducer } | { kind: \"dropped\" } | { kind: \"refused\"; error: Error };\n\n/**\n * A reader's time start, from {@link FillState.timeStart}.\n *\n * @internal\n */\nexport interface Lookup {\n\t/** What its handler answered, undefined until it does, or when it closed unanswered. */\n\tanswer(): TimeStart | undefined;\n\t/** Whether it is over: answered, or closed unanswered. */\n\tdone(): boolean;\n\t/** Bumped as it changes. */\n\treadonly changed: Getter<number>;\n\t/** Stop waiting on it, withdrawing it once nobody does. */\n\tleave(): void;\n}\n\n// Constructs the public handles from within this module; assigned in their static blocks.\nlet makeGroups: (state: FillState, pending: Pending) => FillGroups;\nlet makeRequests: (state: FillState) => Requests;\n\n// The most urgent delivery priority among the readers waiting on `pending` now.\nfunction priorityOf(pending: Pending): number {\n\tlet priority: number | undefined;\n\tfor (const asker of pending.askers) priority = Math.max(priority ?? asker.priority(), asker.priority());\n\treturn priority ?? 0;\n}\n\n/**\n * A {@link Requests} handle on `state`, for a producer's `requests()`.\n *\n * @internal\n */\nexport function requestsOf(state: FillState): Requests {\n\treturn makeRequests(state);\n}\n\n/**\n * Serves the groups a track's readers miss: from {@link Producer.requests}. Mirrors the Rust\n * `track::Requests`.\n *\n * Most tracks never serve old content, so this lives on its own handle rather than the producer:\n * a publisher backed by storage opens one to serve groups its live cache no longer holds, or\n * never held. While at least one is open, a reader missing a run of groups queues a\n * {@link FillGroups} here; with none open, the miss is given up. {@link close} it once done, and keep\n * taking fills until then: a reader waits on its fill until it is answered or closed, so a handle\n * left open but unread stalls that reader.\n *\n * It is also the only way to create a group below the newest one, with {@link createGroup}, as a\n * store replaying history or an end-to-end copy does: the producer itself only appends.\n *\n * @public\n */\nexport class Requests {\n\t#state: FillState;\n\t#closed = new Signal(false);\n\n\tprivate constructor(state: FillState) {\n\t\tthis.#state = state;\n\t\tstate.addHandler();\n\t}\n\n\tstatic {\n\t\tmakeRequests = (state) => new Requests(state);\n\t}\n\n\t/** The track's name, unique within its broadcast. */\n\t// fallow-ignore-next-line unused-class-member\n\tget name(): string {\n\t\treturn fillOps.name(this.#state);\n\t}\n\n\t/**\n\t * Wait until readers miss a run of groups, returning the {@link FillGroups} to serve, including\n\t * the group containing a reader's time start that no cached group places (see\n\t * {@link FillGroups.floor}). Resolves `undefined` once the track closes with nothing queued, or\n\t * this handle closes, even while it waits.\n\t */\n\tasync requestedFill(): Promise<FillGroups | undefined> {\n\t\tconst pending = await this.#state.next(this.#closed);\n\t\tif (!pending) return undefined;\n\t\treturn makeGroups(this.#state, pending);\n\t}\n\n\t/**\n\t * Create a group whose first frame is `frame`: the group starts at its timestamp, its key on the\n\t * track, converted as {@link Producer.appendGroup} converts it. Unlike that, it may start below\n\t * the newest group. Mirrors the Rust `Requests::create_group`.\n\t *\n\t * It says nothing about the keys around it. A key below it the track's own publisher never\n\t * produced stays owed while a handle lives, since that handle may still create it: an ordered\n\t * reader waits on it, locally or through a relay. Once the last handle closes, every such key is\n\t * skipped, except those a fill already handed out still answers. A key already skipped throws\n\t * {@link Skipped}, a timestamp that doesn't match the track {@link TimestampMismatch}, and the\n\t * reserved key 2^64-1 a `RangeError`.\n\t *\n\t * A key another group holds is replaced: the new group takes the slot, and readers already\n\t * draining the old one keep it. The same broadcast, track, and group key always name the same\n\t * content, and nothing checks it, as with {@link Producer.appendGroup}.\n\t */\n\tcreateGroup(frame: Frame): GroupProducer {\n\t\tthis.#open();\n\t\treturn fillOps.track(this.#state).createGroup(frame);\n\t}\n\n\t/**\n\t * {@link createGroup} with its first frame streamed: the group exists once this returns, and\n\t * {@link FrameProducer.finish} hands it back to write the rest. Mirrors the Rust `create_frame`.\n\t */\n\tcreateFrame(info: FrameInfo): FrameProducer {\n\t\tthis.#open();\n\t\treturn fillOps.track(this.#state).createFrame(info);\n\t}\n\n\t/**\n\t * Record that the publisher does not have `[start, end)`, at any key: a reader waiting on one\n\t * moves past it as not found, the declared end does not wait for them, and a relay serving this\n\t * track forwards the drop. Unlike a skip it is not permanent: a group created there later is\n\t * served, but only to a reader that has not yet moved past it. A reader the drop already\n\t * settled, here or through a relay, never sees it: the same broadcast, track, and group key\n\t * always name the same content, so a publisher that re-creates a group it dropped breaks that\n\t * for its own broadcast alone. For a producer that knows a group existed but cannot produce it,\n\t * such as a replay whose copy was pruned; one that never will produce it says so with\n\t * {@link skipGroups}. Once the track declared its end, naming any key at or past it throws and\n\t * records nothing. Mirrors the Rust\n\t * `Requests::drop_groups`.\n\t */\n\tdropGroups(start: bigint, end: bigint): void {\n\t\tcheckKey(start);\n\t\tcheckEnd(end);\n\t\tthis.#open();\n\t\tfillOps.track(this.#state).dropGroups(start, end);\n\t}\n\n\t/**\n\t * Declare that the track will never hold `[start, end)`, at any key. A skip is final: creating a group there throws\n\t * {@link Skipped}. A group that finished here keeps what it is, since it was produced after all;\n\t * one still arriving, or aborted, ends for good, as `GroupProducer.skip` ends one. Mirrors the\n\t * Rust `Requests::skip_groups`.\n\t */\n\tskipGroups(start: bigint, end: bigint): void {\n\t\tcheckKey(start);\n\t\tcheckEnd(end);\n\t\tthis.#open();\n\t\tfillOps.track(this.#state).skipGroups(start, end);\n\t}\n\n\t// Refuse a write through a closed handle: the close already skipped what it left unproduced.\n\t#open(): void {\n\t\tif (this.#closed.peek()) throw new Error(\"requests handle is closed\");\n\t}\n\n\t/**\n\t * Stop serving. The last handle closing skips every key below the newest group the track's own\n\t * publisher never produced, since no handle is left to create it, except those a fill already\n\t * handed out still answers; then it names every miss still queued dropped, so its readers stop\n\t * waiting. A fill already handed out keeps its own handle. Idempotent.\n\t */\n\tclose(): void {\n\t\tif (this.#closed.peek()) return;\n\t\tthis.#closed.set(true);\n\t\tthis.#state.removeHandler();\n\t}\n\n\t[Symbol.dispose](): void {\n\t\tthis.close();\n\t}\n}\n\n/**\n * A run of groups readers miss, from {@link Requests.requestedFill}: `start` up to the exclusive\n * `end`. Mirrors the Rust `track::FillGroups`. A reader's time start that no cached group places\n * asks for the group containing that time as a fill one key wide, from the time, whose first group\n * may start below it: see {@link floor}.\n *\n * Its {@link priority} and {@link order} follow its readers as they change, so\n * read them as each group is served. Call {@link accept} for each group the source has, writing\n * its frames into the returned producer, and {@link dropGroups} for those it does not. Readers\n * that leave, or narrow their ranges past a group, stop wanting it: serve {@link wanted} until it\n * is `undefined`, which {@link wantedChanged} waits on. {@link close} the fill once done; closing\n * names whatever is still wanted dropped rather than leaving its readers waiting.\n *\n * Groups keep their key, so an accepted group should hold the frames, payloads, and\n * boundaries it had when it was first published: a fill replays the track, never a new version.\n *\n * @public\n */\nexport class FillGroups {\n\t/** The first group to fill. */\n\treadonly start: bigint;\n\t/** The exclusive end group. */\n\treadonly end: bigint;\n\t/**\n\t * The oldest group the first group may start at: {@link start}, unless that is a reader's time\n\t * start no cached group places. Then the first group is the one containing that time: the group\n\t * starting at it, or else the newest one starting before it, at or after the floor; once that\n\t * group ends whole at or before the time, the reader starts past it, at its End. A handler\n\t * knowing its groups only by key serves that key as any other; one that can tell which group\n\t * holds the time, as from an index, may {@link accept} that group instead, or\n\t * {@link dropGroups} the key when none does. The reader starts where the answer says, never\n\t * where the cached groups happen to say: a drop, or the fill closed unanswered, says no group\n\t * starts from the floor through the time, so it starts at the group just below the floor (at its\n\t * End once the time is past that group's span), or past the time when the floor is 0. A\n\t * {@link refuseGroups refusal} fails the reader with its error until its ranges change.\n\t */\n\treadonly floor: bigint;\n\n\t#state: FillState;\n\t#pending: Pending;\n\t// The value `wantedChanged` last returned, or unset before it returned any.\n\t#prev?: { wanted: bigint | undefined };\n\n\tprivate constructor(state: FillState, pending: Pending) {\n\t\tthis.#state = state;\n\t\tthis.#pending = pending;\n\t\tthis.start = pending.start;\n\t\tthis.end = pending.end;\n\t\tthis.floor = pending.floor;\n\t}\n\n\tstatic {\n\t\tmakeGroups = (state, pending) => new FillGroups(state, pending);\n\t\twantedRuns = (fill) => fill.#pending.owed();\n\t\tfillChanged = (fill) => Signal.race(fill.#pending.revision);\n\t}\n\n\t/** The most urgent delivery priority among the readers waiting on it now. */\n\tget priority(): number {\n\t\treturn priorityOf(this.#pending);\n\t}\n\n\t/** Which end to fill first now: `\"descending\"`, newest first, if any reader asks it. */\n\tget order(): Order {\n\t\tfor (const asker of this.#pending.askers) if (asker.order() === \"descending\") return \"descending\";\n\t\treturn this.#pending.askers.size > 0 ? \"ascending\" : \"descending\";\n\t}\n\n\t/** Whether a reader still waits for group `key` from this fill. Once false, it stays false. */\n\tisWanted(key: bigint): boolean {\n\t\tcheckKey(key);\n\t\treturn this.#pending.owed(key, key + 1n).length > 0;\n\t}\n\n\t/**\n\t * The next group still owed in the fill's {@link order}: a reader still reads it, it was\n\t * neither answered nor delivered live since it was asked, and the track does not hold it whole.\n\t * `undefined` once none is, so stop serving the fill.\n\t */\n\twanted(): bigint | undefined {\n\t\tfor (;;) {\n\t\t\tconst owed = this.#pending.owed();\n\t\t\tif (owed.length === 0) return undefined;\n\t\t\tconst key = this.order === \"ascending\" ? owed[0].start : (owed.at(-1) as Run).end - 1n;\n\t\t\t// A time start asked once its group already landed, which no arrival answers, is answered by\n\t\t\t// the cache, not the source, as the Rust `FillGroups::wanted` does.\n\t\t\tif (!fillOps.answerCached(this.#state, this.#pending, key)) return key;\n\t\t}\n\t}\n\n\t/**\n\t * {@link wanted} once it differs from what this handle last returned: at once on the first\n\t * call, then on each change. So `for (let at = await fill.wantedChanged(); at !== undefined;\n\t * at = await fill.wantedChanged())` serves each group as it becomes owed, and ends once the\n\t * fill is answered or withdrawn.\n\t */\n\tasync wantedChanged(): Promise<bigint | undefined> {\n\t\tfor (;;) {\n\t\t\tconst wanted = this.wanted();\n\t\t\tif (!this.#prev || this.#prev.wanted !== wanted) {\n\t\t\t\tthis.#prev = { wanted };\n\t\t\t\treturn wanted;\n\t\t\t}\n\t\t\tawait this.#pending.revision.changed();\n\t\t}\n\t}\n\n\t/** Resolves once no reader waits for group `key` from this fill, so stop serving it. */\n\tasync unwanted(key: bigint): Promise<void> {\n\t\tcheckKey(key);\n\t\twhile (this.isWanted(key)) await this.#pending.revision.changed();\n\t}\n\n\t/**\n\t * Insert group `key` into the track's cache, handing it to the readers waiting on it,\n\t * and return the producer to write its frames into. A live subscription covering it receives\n\t * it too. `info` commits the track's {@link Info} if it has none yet. A key from the\n\t * {@link floor} up to the start answers the start with that group. A cached copy missing its\n\t * first frames, which a reader asked whole, is replaced. Returns `undefined` if the group was\n\t * already answered or cached whole. Throws a `RangeError` outside the fill, and an error if the\n\t * track is closed.\n\t *\n\t * A group is named by its frame 0's timestamp, so on a timed track writing frame 0 at any other\n\t * time throws `TimestampMismatch`.\n\t */\n\taccept(start: bigint, info?: Info): GroupProducer | undefined {\n\t\tcheckKey(start);\n\t\tconst group = fillOps.accept(this.#state, this.#pending, start, info);\n\t\tif (group) hooks.keyGroup(group);\n\t\treturn group;\n\t}\n\n\t/**\n\t * Name `[start, end)` as never to be delivered: the source does not have them. Readers stop\n\t * waiting for them, and the track records them so nobody asks again. Only the groups a reader\n\t * still reads count; the rest of the fill was never owed.\n\t */\n\tdropGroups(start: bigint, end: bigint): void {\n\t\tcheckKey(start);\n\t\tcheckEnd(end);\n\t\tfillOps.drop(this.#state, this.#pending, start, end);\n\t}\n\n\t/**\n\t * Refuse `[start, end)` with `error` without saying the source lost them, as when serving them\n\t * failed for now. The readers waiting now stop waiting and get `error`; a later reader asks\n\t * again.\n\t */\n\trefuseGroups(start: bigint, end: bigint, error: Error): void {\n\t\tcheckKey(start);\n\t\tcheckEnd(end);\n\t\tfillOps.refuse(this.#state, this.#pending, start, end, error);\n\t}\n\n\t/** Done serving: whatever a reader still wants is named dropped. Idempotent. */\n\tclose(): void {\n\t\tfillOps.settle(this.#state, this.#pending);\n\t}\n\n\t/** Closes the fill; see {@link close}. */\n\t[Symbol.dispose](): void {\n\t\tthis.close();\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../../src/flate/decoder.ts"],"names":[],"mappings":""}
|
package/flate/decoder.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// The group-scoped moq-flate decoder; applications always read inflated frames.
|
|
2
|
+
import { Inflate, Z_SYNC_FLUSH } from "pako";
|
|
3
|
+
import { StreamCode, StreamError } from "../error.js";
|
|
4
|
+
const SYNC_FLUSH_TAIL = new Uint8Array([0x00, 0x00, 0xff, 0xff]);
|
|
5
|
+
function malformed(message) {
|
|
6
|
+
return new StreamError(StreamCode.MalformedTrack, { message });
|
|
7
|
+
}
|
|
8
|
+
/** Decode one group's slices in frame order, enforcing each declared size. @internal */
|
|
9
|
+
export class Decoder {
|
|
10
|
+
#inflate = new Inflate({ raw: true, chunkSize: 4096 });
|
|
11
|
+
#chunks = [];
|
|
12
|
+
#total = 0;
|
|
13
|
+
#size = 0;
|
|
14
|
+
#failed = false;
|
|
15
|
+
constructor() {
|
|
16
|
+
this.#inflate.onData = (chunk) => {
|
|
17
|
+
this.#total += chunk.length;
|
|
18
|
+
// Throw inside push, so a bomb stops doing work at its declaration plus one
|
|
19
|
+
// scratch chunk rather than merely discarding the rest of its output.
|
|
20
|
+
if (this.#total > this.#size)
|
|
21
|
+
throw malformed("inflated frame exceeds its declared size");
|
|
22
|
+
this.#chunks.push(chunk);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Inflate a slice to exactly `size` bytes, without preallocating from that declaration. */
|
|
26
|
+
frame(slice, size) {
|
|
27
|
+
if (this.#failed)
|
|
28
|
+
throw malformed("decoder already failed");
|
|
29
|
+
if (!Number.isSafeInteger(size) || size < 0)
|
|
30
|
+
throw malformed("invalid inflated frame size");
|
|
31
|
+
this.#chunks = [];
|
|
32
|
+
this.#total = 0;
|
|
33
|
+
this.#size = size;
|
|
34
|
+
try {
|
|
35
|
+
if (slice.length > 0) {
|
|
36
|
+
this.#inflate.push(slice, false);
|
|
37
|
+
if (this.#inflate.ended)
|
|
38
|
+
throw malformed("compressed group ended its DEFLATE stream");
|
|
39
|
+
this.#inflate.push(SYNC_FLUSH_TAIL, Z_SYNC_FLUSH);
|
|
40
|
+
if (this.#inflate.err || this.#inflate.ended)
|
|
41
|
+
throw malformed("malformed DEFLATE slice");
|
|
42
|
+
}
|
|
43
|
+
if (this.#total !== size)
|
|
44
|
+
throw malformed("inflated frame differs from its declared size");
|
|
45
|
+
// Retained frames must own tight buffers rather than pinning scratch storage.
|
|
46
|
+
const out = new Uint8Array(this.#total);
|
|
47
|
+
let offset = 0;
|
|
48
|
+
for (const chunk of this.#chunks) {
|
|
49
|
+
out.set(chunk, offset);
|
|
50
|
+
offset += chunk.length;
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.#failed = true;
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
this.#chunks = [];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=decoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decoder.js","sourceRoot":"","sources":["../../src/flate/decoder.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,eAAe,GAAG,IAAI,UAAU,CAAC,CAA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,CAAC,EAAE,CAAC;gBACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBACjC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK;oBAAE,MAAM,SAAS,CAAC,2CAA2C,CAAC,CAAC;gBACtF,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;gBAClD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK;oBAAE,MAAM,SAAS,CAAC,yBAAyB,CAAC,CAAC;YAC1F,CAAC;YACD,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI;gBAAE,MAAM,SAAS,CAAC,+CAA+C,CAAC,CAAC;YAC3F,8EAA8E;YAC9E,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACxC,IAAI,MAAM,GAAG,CAAC,CAAC;YACf,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;YACxB,CAAC;YACD,OAAO,GAAG,CAAC;QACZ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,MAAM,KAAK,CAAC;QACb,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QACnB,CAAC;IACF,CAAC;CACD","sourcesContent":["// The group-scoped moq-flate decoder; applications always read inflated frames.\nimport { Inflate, Z_SYNC_FLUSH } from \"pako\";\nimport { StreamCode, StreamError } from \"../error.ts\";\n\nconst SYNC_FLUSH_TAIL = new Uint8Array([0x00, 0x00, 0xff, 0xff]);\n\nfunction malformed(message: string): Error {\n\treturn new StreamError(StreamCode.MalformedTrack, { message });\n}\n\n/** Decode one group's slices in frame order, enforcing each declared size. @internal */\nexport class Decoder {\n\t#inflate = new Inflate({ raw: true, chunkSize: 4096 });\n\t#chunks: Uint8Array[] = [];\n\t#total = 0;\n\t#size = 0;\n\t#failed = false;\n\n\tconstructor() {\n\t\tthis.#inflate.onData = (chunk) => {\n\t\t\tthis.#total += chunk.length;\n\t\t\t// Throw inside push, so a bomb stops doing work at its declaration plus one\n\t\t\t// scratch chunk rather than merely discarding the rest of its output.\n\t\t\tif (this.#total > this.#size) throw malformed(\"inflated frame exceeds its declared size\");\n\t\t\tthis.#chunks.push(chunk);\n\t\t};\n\t}\n\n\t/** Inflate a slice to exactly `size` bytes, without preallocating from that declaration. */\n\tframe(slice: Uint8Array, size: number): Uint8Array {\n\t\tif (this.#failed) throw malformed(\"decoder already failed\");\n\t\tif (!Number.isSafeInteger(size) || size < 0) throw malformed(\"invalid inflated frame size\");\n\t\tthis.#chunks = [];\n\t\tthis.#total = 0;\n\t\tthis.#size = size;\n\t\ttry {\n\t\t\tif (slice.length > 0) {\n\t\t\t\tthis.#inflate.push(slice, false);\n\t\t\t\tif (this.#inflate.ended) throw malformed(\"compressed group ended its DEFLATE stream\");\n\t\t\t\tthis.#inflate.push(SYNC_FLUSH_TAIL, Z_SYNC_FLUSH);\n\t\t\t\tif (this.#inflate.err || this.#inflate.ended) throw malformed(\"malformed DEFLATE slice\");\n\t\t\t}\n\t\t\tif (this.#total !== size) throw malformed(\"inflated frame differs from its declared size\");\n\t\t\t// Retained frames must own tight buffers rather than pinning scratch storage.\n\t\t\tconst out = new Uint8Array(this.#total);\n\t\t\tlet offset = 0;\n\t\t\tfor (const chunk of this.#chunks) {\n\t\t\t\tout.set(chunk, offset);\n\t\t\t\toffset += chunk.length;\n\t\t\t}\n\t\t\treturn out;\n\t\t} catch (error) {\n\t\t\tthis.#failed = true;\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tthis.#chunks = [];\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../src/flate/encoder.ts"],"names":[],"mappings":""}
|
package/flate/encoder.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Synchronous model writes include the encoder in the static graph.
|
|
2
|
+
import { Deflate, Z_SYNC_FLUSH } from "pako";
|
|
3
|
+
const DEFAULT_LEVEL = 6;
|
|
4
|
+
const SYNC_FLUSH_TAIL = new Uint8Array([0x00, 0x00, 0xff, 0xff]);
|
|
5
|
+
/**
|
|
6
|
+
* Encodes a stream's frame payloads into one shared DEFLATE window, one self-delimited slice per
|
|
7
|
+
* frame. Hold one per stream; create a new one for each independent stream.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export class Encoder {
|
|
12
|
+
#deflate;
|
|
13
|
+
#chunks = [];
|
|
14
|
+
#total = 0;
|
|
15
|
+
/** Start a fresh encoder with a cold window. */
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
// `raw`: no zlib header/trailer, matching the Rust side and the browser's `deflate-raw`.
|
|
18
|
+
// pako types `level` as a literal union; we accept a plain number and narrow here.
|
|
19
|
+
const level = (options.level ?? DEFAULT_LEVEL);
|
|
20
|
+
this.#deflate = new Deflate({ raw: true, level });
|
|
21
|
+
this.#deflate.onData = (chunk) => {
|
|
22
|
+
const bytes = chunk;
|
|
23
|
+
this.#chunks.push(bytes);
|
|
24
|
+
this.#total += bytes.length;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The most bytes {@link frame} can return for a payload of `len` bytes, at any level and whatever
|
|
29
|
+
* the window already holds.
|
|
30
|
+
*
|
|
31
|
+
* zlib's `deflateBound` for its default window and memory level, which both pako and the Rust
|
|
32
|
+
* `moq-flate` use: incompressible input falls back to stored blocks, 5 bytes per 16 KiB. The
|
|
33
|
+
* constant covers the block headers and the flush, whose fixed 4-byte marker is stripped anyway.
|
|
34
|
+
*/
|
|
35
|
+
static bound(len) {
|
|
36
|
+
// Division rather than shifts, which wrap past 2^31.
|
|
37
|
+
return len + Math.floor(len / 4096) + Math.floor(len / 16384) + Math.floor(len / 33554432) + 13;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Compress the next frame's `payload`, returning its slice of the stream: the DEFLATE bytes minus
|
|
41
|
+
* the fixed sync-flush marker. Empty in yields empty out. Slices must be produced in frame order.
|
|
42
|
+
*/
|
|
43
|
+
frame(payload) {
|
|
44
|
+
if (payload.length === 0)
|
|
45
|
+
return payload;
|
|
46
|
+
this.#chunks = [];
|
|
47
|
+
this.#total = 0;
|
|
48
|
+
this.#deflate.push(payload, Z_SYNC_FLUSH);
|
|
49
|
+
// Copy into one tight owned buffer, dropping the trailing sync-flush marker. We can't return
|
|
50
|
+
// pako's chunk views: a caller retains the reference and pako backs each chunk with a ~16 KB
|
|
51
|
+
// buffer, so a view would pin far more memory than the frame.
|
|
52
|
+
const out = new Uint8Array(this.#total - SYNC_FLUSH_TAIL.length);
|
|
53
|
+
let offset = 0;
|
|
54
|
+
for (const chunk of this.#chunks) {
|
|
55
|
+
if (offset >= out.length)
|
|
56
|
+
break;
|
|
57
|
+
const take = Math.min(chunk.length, out.length - offset);
|
|
58
|
+
out.set(chunk.subarray(0, take), offset);
|
|
59
|
+
offset += take;
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=encoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../src/flate/encoder.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,EAAE,OAAO,EAAuB,YAAY,EAAE,MAAM,MAAM,CAAC;AAElE,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,eAAe,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,I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D;QAC9D,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACjE,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,IAAI,MAAM,IAAI,GAAG,CAAC,MAAM;gBAAE,MAAM;YAChC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;YACzD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;YACzC,MAAM,IAAI,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;CACD","sourcesContent":["// Synchronous model writes include the encoder in the static graph.\nimport { Deflate, type DeflateOptions, Z_SYNC_FLUSH } from \"pako\";\n\nconst DEFAULT_LEVEL = 6;\nconst SYNC_FLUSH_TAIL = new Uint8Array([0x00, 0x00, 0xff, 0xff]);\n\n/** Options for an {@link Encoder}. */\ninterface EncoderOptions {\n\t/** DEFLATE level, `0..=9` (higher is smaller and slower). Defaults to {@link DEFAULT_LEVEL}. */\n\tlevel?: number;\n}\n\n/**\n * Encodes a stream's frame payloads into one shared DEFLATE window, one self-delimited slice per\n * frame. Hold one per stream; create a new one for each independent stream.\n *\n * @internal\n */\nexport class Encoder {\n\t#deflate: Deflate;\n\t#chunks: Uint8Array[] = [];\n\t#total = 0;\n\n\t/** Start a fresh encoder with a cold window. */\n\tconstructor(options: EncoderOptions = {}) {\n\t\t// `raw`: no zlib header/trailer, matching the Rust side and the browser's `deflate-raw`.\n\t\t// pako types `level` as a literal union; we accept a plain number and narrow here.\n\t\tconst level = (options.level ?? DEFAULT_LEVEL) as DeflateOptions[\"level\"];\n\t\tthis.#deflate = new Deflate({ raw: true, level });\n\t\tthis.#deflate.onData = (chunk) => {\n\t\t\tconst bytes = chunk as Uint8Array;\n\t\t\tthis.#chunks.push(bytes);\n\t\t\tthis.#total += bytes.length;\n\t\t};\n\t}\n\n\t/**\n\t * The most bytes {@link frame} can return for a payload of `len` bytes, at any level and whatever\n\t * the window already holds.\n\t *\n\t * zlib's `deflateBound` for its default window and memory level, which both pako and the Rust\n\t * `moq-flate` use: incompressible input falls back to stored blocks, 5 bytes per 16 KiB. The\n\t * constant covers the block headers and the flush, whose fixed 4-byte marker is stripped anyway.\n\t */\n\tstatic bound(len: number): number {\n\t\t// Division rather than shifts, which wrap past 2^31.\n\t\treturn len + Math.floor(len / 4096) + Math.floor(len / 16384) + Math.floor(len / 33554432) + 13;\n\t}\n\n\t/**\n\t * Compress the next frame's `payload`, returning its slice of the stream: the DEFLATE bytes minus\n\t * the fixed sync-flush marker. Empty in yields empty out. Slices must be produced in frame order.\n\t */\n\tframe(payload: Uint8Array): Uint8Array {\n\t\tif (payload.length === 0) return payload;\n\t\tthis.#chunks = [];\n\t\tthis.#total = 0;\n\t\tthis.#deflate.push(payload, Z_SYNC_FLUSH);\n\n\t\t// Copy into one tight owned buffer, dropping the trailing sync-flush marker. We can't return\n\t\t// pako's chunk views: a caller retains the reference and pako backs each chunk with a ~16 KB\n\t\t// buffer, so a view would pin far more memory than the frame.\n\t\tconst out = new Uint8Array(this.#total - SYNC_FLUSH_TAIL.length);\n\t\tlet offset = 0;\n\t\tfor (const chunk of this.#chunks) {\n\t\t\tif (offset >= out.length) break;\n\t\t\tconst take = Math.min(chunk.length, out.length - offset);\n\t\t\tout.set(chunk.subarray(0, take), offset);\n\t\t\toffset += take;\n\t\t}\n\t\treturn out;\n\t}\n}\n"]}
|
package/flate/group.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Frame } from "../group.ts";
|
|
2
|
+
/** A stored slice and its declared plain size. Package-private wire metadata. */
|
|
3
|
+
export interface Stored {
|
|
4
|
+
/** The original compressed bytes. */
|
|
5
|
+
payload: Uint8Array;
|
|
6
|
+
/** The exact plain payload length. */
|
|
7
|
+
inflated: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Whether a local plain payload of `size` bytes encodes to a slice a peer accepts, whatever it
|
|
11
|
+
* holds: checked before encoding, since an encoded frame has already advanced the dictionary.
|
|
12
|
+
*/
|
|
13
|
+
export declare function encodable(size: number): boolean;
|
|
14
|
+
/** Read a compressed frame's stored form without inflating it. */
|
|
15
|
+
export declare function stored(frame: Frame): Stored | undefined;
|
|
16
|
+
/** One group's stored tail and lazy plain copy, shared by every mirror. */
|
|
17
|
+
export declare class Compression {
|
|
18
|
+
#private;
|
|
19
|
+
/** Retained compressed payload bytes, separate from its optional plain copy. */
|
|
20
|
+
stored: number;
|
|
21
|
+
/** Retained slice and shared plain bytes. */
|
|
22
|
+
bytes: number;
|
|
23
|
+
/** Called once a slice fails to decode, so the owning group fails with it. */
|
|
24
|
+
failed?: (error: Error) => void;
|
|
25
|
+
/** Store a local plain frame or a received slice. */
|
|
26
|
+
push(frame: Frame, inflated?: number): Frame;
|
|
27
|
+
/** Advance the dictionary through a shed prefix, retaining neither its slices nor plain bytes. */
|
|
28
|
+
shed(base: number): void;
|
|
29
|
+
/** Release cached content on an abort, failing every mirror's late read. */
|
|
30
|
+
abort(error: Error): void;
|
|
31
|
+
/** Release codec scratch once no more frames can arrive. */
|
|
32
|
+
finish(): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/flate/group.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAOzC,iFAAiF;AACjF,MAAM,WAAW,MAAM;IACtB,qCAAqC;IACrC,OAAO,EAAE,UAAU,CAAC;IACpB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;CACjB;AAmBD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED,kEAAkE;AAClE,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAEvD;AAQD,2EAA2E;AAC3E,qBAAa,WAAW;;IAUvB,gFAAgF;IAChF,MAAM,SAAK;IACX,6CAA6C;IAC7C,KAAK,SAAK;IACV,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEhC,qDAAqD;IACrD,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAgB3C;IAyBD,kGAAkG;IAClG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAkBvB;IAED,4EAA4E;IAC5E,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAUxB;IAED,4DAA4D;IAC5D,MAAM,IAAI,IAAI,CAIb;CACD"}
|
package/flate/group.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { StreamCode, StreamError } from "../error.js";
|
|
2
|
+
import { Queue } from "../queue.js";
|
|
3
|
+
import { MAX_FRAME_BYTES } from "../util/limits.js";
|
|
4
|
+
import { Decoder } from "./decoder.js";
|
|
5
|
+
import { Encoder } from "./encoder.js";
|
|
6
|
+
// Class identity keeps reactive equality from reading the lazy payload getter.
|
|
7
|
+
class SliceFrame {
|
|
8
|
+
timestamp;
|
|
9
|
+
created;
|
|
10
|
+
#read;
|
|
11
|
+
constructor(timestamp, created, read) {
|
|
12
|
+
this.timestamp = timestamp;
|
|
13
|
+
this.created = created;
|
|
14
|
+
this.#read = read;
|
|
15
|
+
}
|
|
16
|
+
get payload() {
|
|
17
|
+
return this.#read();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const slices = new WeakMap();
|
|
21
|
+
/**
|
|
22
|
+
* Whether a local plain payload of `size` bytes encodes to a slice a peer accepts, whatever it
|
|
23
|
+
* holds: checked before encoding, since an encoded frame has already advanced the dictionary.
|
|
24
|
+
*/
|
|
25
|
+
export function encodable(size) {
|
|
26
|
+
return Encoder.bound(size) <= MAX_FRAME_BYTES;
|
|
27
|
+
}
|
|
28
|
+
/** Read a compressed frame's stored form without inflating it. */
|
|
29
|
+
export function stored(frame) {
|
|
30
|
+
return slices.get(frame);
|
|
31
|
+
}
|
|
32
|
+
/** One group's stored tail and lazy plain copy, shared by every mirror. */
|
|
33
|
+
export class Compression {
|
|
34
|
+
#encoder;
|
|
35
|
+
#decoder;
|
|
36
|
+
#frames = new Queue();
|
|
37
|
+
#pending = new Queue();
|
|
38
|
+
#next = 0;
|
|
39
|
+
#decoded = 0;
|
|
40
|
+
#base = 0;
|
|
41
|
+
#failed;
|
|
42
|
+
#finished = false;
|
|
43
|
+
/** Retained compressed payload bytes, separate from its optional plain copy. */
|
|
44
|
+
stored = 0;
|
|
45
|
+
/** Retained slice and shared plain bytes. */
|
|
46
|
+
bytes = 0;
|
|
47
|
+
/** Called once a slice fails to decode, so the owning group fails with it. */
|
|
48
|
+
failed;
|
|
49
|
+
/** Store a local plain frame or a received slice. */
|
|
50
|
+
push(frame, inflated) {
|
|
51
|
+
// A failed dictionary cannot decode anything after it, so the group takes no more.
|
|
52
|
+
if (this.#failed)
|
|
53
|
+
throw this.#failed;
|
|
54
|
+
let slice;
|
|
55
|
+
if (inflated === undefined) {
|
|
56
|
+
this.#encoder ??= new Encoder();
|
|
57
|
+
slice = { payload: this.#encoder.frame(frame.payload), inflated: frame.payload.length };
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
slice = { payload: frame.payload, inflated };
|
|
61
|
+
this.stored += slice.payload.length;
|
|
62
|
+
this.bytes += slice.payload.length;
|
|
63
|
+
const entry = { index: this.#next++, slice };
|
|
64
|
+
this.#frames.push(entry);
|
|
65
|
+
this.#pending.push(entry);
|
|
66
|
+
const result = new SliceFrame(frame.timestamp, frame.created, () => this.#inflate(entry));
|
|
67
|
+
slices.set(result, slice);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
#inflate(entry) {
|
|
71
|
+
if (this.#failed)
|
|
72
|
+
throw this.#failed;
|
|
73
|
+
if (entry.index < this.#base)
|
|
74
|
+
throw new StreamError(StreamCode.Evicted);
|
|
75
|
+
if (entry.plain)
|
|
76
|
+
return entry.plain;
|
|
77
|
+
try {
|
|
78
|
+
while (this.#pending.first && this.#pending.first.index <= entry.index)
|
|
79
|
+
this.#decode(this.#pending.first);
|
|
80
|
+
if (this.#finished && this.#decoded === this.#next)
|
|
81
|
+
this.#decoder = undefined;
|
|
82
|
+
if (!entry.plain)
|
|
83
|
+
throw new Error("compressed frame is missing");
|
|
84
|
+
return entry.plain;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
this.abort(error instanceof Error ? error : new Error(String(error)));
|
|
88
|
+
throw this.#failed;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
#decode(entry) {
|
|
92
|
+
this.#decoder ??= new Decoder();
|
|
93
|
+
entry.plain = this.#decoder.frame(entry.slice.payload, entry.slice.inflated);
|
|
94
|
+
this.#pending.shift();
|
|
95
|
+
this.#decoded = entry.index + 1;
|
|
96
|
+
this.bytes += entry.plain.length;
|
|
97
|
+
}
|
|
98
|
+
/** Advance the dictionary through a shed prefix, retaining neither its slices nor plain bytes. */
|
|
99
|
+
shed(base) {
|
|
100
|
+
while (this.#frames.first && this.#frames.first.index < base) {
|
|
101
|
+
const entry = this.#frames.first;
|
|
102
|
+
// Later slices depend on this dictionary even if no plain reader took the prefix.
|
|
103
|
+
if (entry.index >= this.#decoded && !this.#failed) {
|
|
104
|
+
try {
|
|
105
|
+
this.#decode(entry);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
this.abort(error instanceof Error ? error : new Error(String(error)));
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
this.#frames.shift();
|
|
113
|
+
this.stored -= entry.slice.payload.length;
|
|
114
|
+
this.bytes -= entry.slice.payload.length + (entry.plain?.length ?? 0);
|
|
115
|
+
entry.plain = undefined;
|
|
116
|
+
}
|
|
117
|
+
this.#base = base;
|
|
118
|
+
}
|
|
119
|
+
/** Release cached content on an abort, failing every mirror's late read. */
|
|
120
|
+
abort(error) {
|
|
121
|
+
this.#failed = error;
|
|
122
|
+
this.#encoder = undefined;
|
|
123
|
+
this.#decoder = undefined;
|
|
124
|
+
for (const entry of this.#frames)
|
|
125
|
+
entry.plain = undefined;
|
|
126
|
+
this.#frames = new Queue();
|
|
127
|
+
this.#pending = new Queue();
|
|
128
|
+
this.bytes = 0;
|
|
129
|
+
this.stored = 0;
|
|
130
|
+
this.failed?.(error);
|
|
131
|
+
}
|
|
132
|
+
/** Release codec scratch once no more frames can arrive. */
|
|
133
|
+
finish() {
|
|
134
|
+
this.#finished = true;
|
|
135
|
+
this.#encoder = undefined;
|
|
136
|
+
if (this.#decoded === this.#next)
|
|
137
|
+
this.#decoder = undefined;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/flate/group.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAUvC,+EAA+E;AAC/E,MAAM,UAAU;IACN,SAAS,CAAY;IACrB,OAAO,CAAsB;IACtC,KAAK,CAAmB;IACxB,YAAY,SAAoB,EAAE,OAA4B,EAAE,IAAsB;QACrF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C,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,4DAA4D;IAC5D,MAAM;QACL,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC7D,CAAC;CACD","sourcesContent":["import type { Instant } from \"@moq/clock\";\nimport { StreamCode, StreamError } from \"../error.ts\";\nimport type { Frame } from \"../group.ts\";\nimport { Queue } from \"../queue.ts\";\nimport type { Timestamp } from \"../time.ts\";\nimport { MAX_FRAME_BYTES } from \"../util/limits.ts\";\nimport { Decoder } from \"./decoder.ts\";\nimport { Encoder } from \"./encoder.ts\";\n\n/** A stored slice and its declared plain size. Package-private wire metadata. */\nexport interface Stored {\n\t/** The original compressed bytes. */\n\tpayload: Uint8Array;\n\t/** The exact plain payload length. */\n\tinflated: number;\n}\n\n// Class identity keeps reactive equality from reading the lazy payload getter.\nclass SliceFrame implements Frame {\n\treadonly timestamp: Timestamp;\n\treadonly created: Instant | undefined;\n\t#read: () => Uint8Array;\n\tconstructor(timestamp: Timestamp, created: Instant | undefined, read: () => Uint8Array) {\n\t\tthis.timestamp = timestamp;\n\t\tthis.created = created;\n\t\tthis.#read = read;\n\t}\n\tget payload(): Uint8Array {\n\t\treturn this.#read();\n\t}\n}\n\nconst slices = new WeakMap<Frame, Stored>();\n\n/**\n * Whether a local plain payload of `size` bytes encodes to a slice a peer accepts, whatever it\n * holds: checked before encoding, since an encoded frame has already advanced the dictionary.\n */\nexport function encodable(size: number): boolean {\n\treturn Encoder.bound(size) <= MAX_FRAME_BYTES;\n}\n\n/** Read a compressed frame's stored form without inflating it. */\nexport function stored(frame: Frame): Stored | undefined {\n\treturn slices.get(frame);\n}\n\ninterface Entry {\n\tindex: number;\n\tslice: Stored;\n\tplain?: Uint8Array;\n}\n\n/** One group's stored tail and lazy plain copy, shared by every mirror. */\nexport class Compression {\n\t#encoder?: Encoder;\n\t#decoder?: Decoder;\n\t#frames = new Queue<Entry>();\n\t#pending = new Queue<Entry>();\n\t#next = 0;\n\t#decoded = 0;\n\t#base = 0;\n\t#failed?: Error;\n\t#finished = false;\n\t/** Retained compressed payload bytes, separate from its optional plain copy. */\n\tstored = 0;\n\t/** Retained slice and shared plain bytes. */\n\tbytes = 0;\n\t/** Called once a slice fails to decode, so the owning group fails with it. */\n\tfailed?: (error: Error) => void;\n\n\t/** Store a local plain frame or a received slice. */\n\tpush(frame: Frame, inflated?: number): Frame {\n\t\t// A failed dictionary cannot decode anything after it, so the group takes no more.\n\t\tif (this.#failed) throw this.#failed;\n\t\tlet slice: Stored;\n\t\tif (inflated === undefined) {\n\t\t\tthis.#encoder ??= new Encoder();\n\t\t\tslice = { payload: this.#encoder.frame(frame.payload), inflated: frame.payload.length };\n\t\t} else slice = { payload: frame.payload, inflated };\n\t\tthis.stored += slice.payload.length;\n\t\tthis.bytes += slice.payload.length;\n\t\tconst entry: Entry = { index: this.#next++, slice };\n\t\tthis.#frames.push(entry);\n\t\tthis.#pending.push(entry);\n\t\tconst result = new SliceFrame(frame.timestamp, frame.created, () => this.#inflate(entry));\n\t\tslices.set(result, slice);\n\t\treturn result;\n\t}\n\n\t#inflate(entry: Entry): Uint8Array {\n\t\tif (this.#failed) throw this.#failed;\n\t\tif (entry.index < this.#base) throw new StreamError(StreamCode.Evicted);\n\t\tif (entry.plain) return entry.plain;\n\t\ttry {\n\t\t\twhile (this.#pending.first && this.#pending.first.index <= entry.index) this.#decode(this.#pending.first);\n\t\t\tif (this.#finished && this.#decoded === this.#next) this.#decoder = undefined;\n\t\t\tif (!entry.plain) throw new Error(\"compressed frame is missing\");\n\t\t\treturn entry.plain;\n\t\t} catch (error) {\n\t\t\tthis.abort(error instanceof Error ? error : new Error(String(error)));\n\t\t\tthrow this.#failed;\n\t\t}\n\t}\n\n\t#decode(entry: Entry): void {\n\t\tthis.#decoder ??= new Decoder();\n\t\tentry.plain = this.#decoder.frame(entry.slice.payload, entry.slice.inflated);\n\t\tthis.#pending.shift();\n\t\tthis.#decoded = entry.index + 1;\n\t\tthis.bytes += entry.plain.length;\n\t}\n\n\t/** Advance the dictionary through a shed prefix, retaining neither its slices nor plain bytes. */\n\tshed(base: number): void {\n\t\twhile (this.#frames.first && this.#frames.first.index < base) {\n\t\t\tconst entry = this.#frames.first;\n\t\t\t// Later slices depend on this dictionary even if no plain reader took the prefix.\n\t\t\tif (entry.index >= this.#decoded && !this.#failed) {\n\t\t\t\ttry {\n\t\t\t\t\tthis.#decode(entry);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.abort(error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#frames.shift();\n\t\t\tthis.stored -= entry.slice.payload.length;\n\t\t\tthis.bytes -= entry.slice.payload.length + (entry.plain?.length ?? 0);\n\t\t\tentry.plain = undefined;\n\t\t}\n\t\tthis.#base = base;\n\t}\n\n\t/** Release cached content on an abort, failing every mirror's late read. */\n\tabort(error: Error): void {\n\t\tthis.#failed = error;\n\t\tthis.#encoder = undefined;\n\t\tthis.#decoder = undefined;\n\t\tfor (const entry of this.#frames) entry.plain = undefined;\n\t\tthis.#frames = new Queue();\n\t\tthis.#pending = new Queue();\n\t\tthis.bytes = 0;\n\t\tthis.stored = 0;\n\t\tthis.failed?.(error);\n\t}\n\n\t/** Release codec scratch once no more frames can arrive. */\n\tfinish(): void {\n\t\tthis.#finished = true;\n\t\tthis.#encoder = undefined;\n\t\tif (this.#decoded === this.#next) this.#decoder = undefined;\n\t}\n}\n"]}
|
package/frame.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frame role handles: one frame's payload written or read in pieces as it arrives.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { Instant } from "@moq/clock";
|
|
7
|
+
import type { Producer as GroupProducer } from "./group.ts";
|
|
8
|
+
import type { Timestamp } from "./time.ts";
|
|
9
|
+
/**
|
|
10
|
+
* A frame's header, declared before its payload, as Rust's `frame::Info`.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export interface Info {
|
|
15
|
+
/** The payload size in bytes, which the writes must add up to exactly. */
|
|
16
|
+
size: number;
|
|
17
|
+
/**
|
|
18
|
+
* Presentation timestamp, or on a scale-less track {@link Timestamp.unscaled} at its group's
|
|
19
|
+
* key (see `Group.Frame.timestamp`).
|
|
20
|
+
*/
|
|
21
|
+
timestamp: Timestamp;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Writes one frame's payload in pieces, as Rust's `frame::Producer`. Obtain one from
|
|
25
|
+
* `Group.Producer.createFrame`.
|
|
26
|
+
*
|
|
27
|
+
* The writes must add up to the declared size exactly, and {@link finish} commits the frame.
|
|
28
|
+
* Its group takes no other frame until then; ending the group first fails the frame.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare class Producer {
|
|
33
|
+
#private;
|
|
34
|
+
/** The declared payload size in bytes. */
|
|
35
|
+
readonly size: number;
|
|
36
|
+
/** The frame's presentation timestamp, or on a scale-less track its group's key. */
|
|
37
|
+
readonly timestamp: Timestamp;
|
|
38
|
+
private constructor();
|
|
39
|
+
/** Bytes still needed to complete the frame. */
|
|
40
|
+
get remaining(): number;
|
|
41
|
+
/** Append `chunk`, waking readers streaming the frame. The bytes are copied unless one write carries the whole frame. */
|
|
42
|
+
write(chunk: Uint8Array): void;
|
|
43
|
+
/** Commit the frame once every declared byte is written, returning its group to write the rest. */
|
|
44
|
+
finish(): GroupProducer;
|
|
45
|
+
/**
|
|
46
|
+
* Give the frame and its group up for now, as {@link GroupProducer.abort} does. A no-op once the
|
|
47
|
+
* frame finished or aborted. Mirrors the Rust `frame::Producer::abort`.
|
|
48
|
+
*/
|
|
49
|
+
abort(): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Reads one frame's payload as it arrives, as Rust's `frame::Consumer`. Obtain one from
|
|
53
|
+
* `Group.Consumer.nextFrame`.
|
|
54
|
+
*
|
|
55
|
+
* Chunks are read-only views shared with other readers. A frame larger than its group's
|
|
56
|
+
* retained tail sheds its oldest segments while it is written, so a reader that falls that
|
|
57
|
+
* far behind fails with a `StreamError` of code `Evicted`.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export declare class Consumer {
|
|
62
|
+
#private;
|
|
63
|
+
/** The frame's index within its group, counting from 0 in write order. */
|
|
64
|
+
readonly index: number;
|
|
65
|
+
/** The payload size in bytes. */
|
|
66
|
+
readonly size: number;
|
|
67
|
+
/** The frame's presentation timestamp, or on a scale-less track its group's key. */
|
|
68
|
+
readonly timestamp: Timestamp;
|
|
69
|
+
private constructor();
|
|
70
|
+
/** When the frame's last byte landed in this node's group; `undefined` until then. */
|
|
71
|
+
get created(): Instant | undefined;
|
|
72
|
+
/** The next chunk of the payload, waiting for it to be written; `undefined` once every byte is read. */
|
|
73
|
+
readChunk(): Promise<Uint8Array | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* The rest of the payload in one buffer, copied only when it spans chunks. It grows as
|
|
76
|
+
* bytes arrive, so a declared size is never allocated ahead of them.
|
|
77
|
+
*/
|
|
78
|
+
readAll(): Promise<Uint8Array>;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=frame.d.ts.map
|
package/frame.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../src/frame.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,OAAO,KAAK,EAAS,QAAQ,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,KAAK,EAAE,SAAS,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