@moq/net 0.1.9 → 0.2.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.
Files changed (252) hide show
  1. package/announced.d.ts +40 -24
  2. package/announced.d.ts.map +1 -1
  3. package/announced.js +74 -40
  4. package/announced.js.map +1 -1
  5. package/announced.test.d.ts +2 -0
  6. package/announced.test.d.ts.map +1 -0
  7. package/announced.test.js +37 -0
  8. package/announced.test.js.map +1 -0
  9. package/broadcast.d.ts +80 -25
  10. package/broadcast.d.ts.map +1 -1
  11. package/broadcast.js +266 -49
  12. package/broadcast.js.map +1 -1
  13. package/broadcast.test.d.ts +2 -0
  14. package/broadcast.test.d.ts.map +1 -0
  15. package/broadcast.test.js +219 -0
  16. package/broadcast.test.js.map +1 -0
  17. package/connection/accept.d.ts +6 -0
  18. package/connection/accept.d.ts.map +1 -1
  19. package/connection/accept.js +30 -10
  20. package/connection/accept.js.map +1 -1
  21. package/connection/browser.d.ts +5 -0
  22. package/connection/browser.d.ts.map +1 -0
  23. package/connection/browser.js +25 -0
  24. package/connection/browser.js.map +1 -0
  25. package/connection/browser.test.d.ts +2 -0
  26. package/connection/browser.test.d.ts.map +1 -0
  27. package/connection/browser.test.js +29 -0
  28. package/connection/browser.test.js.map +1 -0
  29. package/connection/connect.d.ts +43 -1
  30. package/connection/connect.d.ts.map +1 -1
  31. package/connection/connect.js +96 -107
  32. package/connection/connect.js.map +1 -1
  33. package/connection/connect.test.d.ts +2 -0
  34. package/connection/connect.test.d.ts.map +1 -0
  35. package/connection/connect.test.js +118 -0
  36. package/connection/connect.test.js.map +1 -0
  37. package/connection/established.d.ts +29 -15
  38. package/connection/established.d.ts.map +1 -1
  39. package/connection/established.js.map +1 -1
  40. package/connection/index.d.ts +8 -0
  41. package/connection/index.d.ts.map +1 -1
  42. package/connection/index.js +6 -0
  43. package/connection/index.js.map +1 -1
  44. package/connection/reload.d.ts +43 -7
  45. package/connection/reload.d.ts.map +1 -1
  46. package/connection/reload.js +159 -62
  47. package/connection/reload.js.map +1 -1
  48. package/connection/reload.test.js +65 -0
  49. package/connection/reload.test.js.map +1 -1
  50. package/connection/stats.d.ts +92 -0
  51. package/connection/stats.d.ts.map +1 -0
  52. package/connection/stats.js +35 -0
  53. package/connection/stats.js.map +1 -0
  54. package/connection/stats.test.d.ts +2 -0
  55. package/connection/stats.test.d.ts.map +1 -0
  56. package/connection/stats.test.js +120 -0
  57. package/connection/stats.test.js.map +1 -0
  58. package/connection/transport.d.ts +10 -0
  59. package/connection/transport.d.ts.map +1 -0
  60. package/connection/transport.js +12 -0
  61. package/connection/transport.js.map +1 -0
  62. package/consume.d.ts +26 -0
  63. package/consume.d.ts.map +1 -0
  64. package/consume.js +40 -0
  65. package/consume.js.map +1 -0
  66. package/datagram.d.ts +23 -0
  67. package/datagram.d.ts.map +1 -0
  68. package/datagram.js +3 -0
  69. package/datagram.js.map +1 -0
  70. package/group.d.ts +125 -36
  71. package/group.d.ts.map +1 -1
  72. package/group.js +244 -67
  73. package/group.js.map +1 -1
  74. package/group.test.js +121 -35
  75. package/group.test.js.map +1 -1
  76. package/ietf/adapter.d.ts +2 -2
  77. package/ietf/adapter.d.ts.map +1 -1
  78. package/ietf/adapter.js +15 -5
  79. package/ietf/adapter.js.map +1 -1
  80. package/ietf/connection.d.ts +19 -6
  81. package/ietf/connection.d.ts.map +1 -1
  82. package/ietf/connection.js +23 -8
  83. package/ietf/connection.js.map +1 -1
  84. package/ietf/ietf.test.js +58 -1
  85. package/ietf/ietf.test.js.map +1 -1
  86. package/ietf/object.d.ts +12 -4
  87. package/ietf/object.d.ts.map +1 -1
  88. package/ietf/object.js +92 -9
  89. package/ietf/object.js.map +1 -1
  90. package/ietf/publisher.d.ts +2 -2
  91. package/ietf/publisher.d.ts.map +1 -1
  92. package/ietf/publisher.js +12 -12
  93. package/ietf/publisher.js.map +1 -1
  94. package/ietf/subscribe_namespace.d.ts +0 -4
  95. package/ietf/subscribe_namespace.d.ts.map +1 -1
  96. package/ietf/subscribe_namespace.js +0 -5
  97. package/ietf/subscribe_namespace.js.map +1 -1
  98. package/ietf/subscriber.d.ts +8 -4
  99. package/ietf/subscriber.d.ts.map +1 -1
  100. package/ietf/subscriber.js +171 -93
  101. package/ietf/subscriber.js.map +1 -1
  102. package/index.d.ts +8 -5
  103. package/index.d.ts.map +1 -1
  104. package/index.js +8 -5
  105. package/index.js.map +1 -1
  106. package/integration.test.js +598 -12
  107. package/integration.test.js.map +1 -1
  108. package/internal.d.ts +14 -0
  109. package/internal.d.ts.map +1 -0
  110. package/internal.js +8 -0
  111. package/internal.js.map +1 -0
  112. package/lite/announce.d.ts +55 -13
  113. package/lite/announce.d.ts.map +1 -1
  114. package/lite/announce.js +221 -68
  115. package/lite/announce.js.map +1 -1
  116. package/lite/announce.test.d.ts +2 -0
  117. package/lite/announce.test.d.ts.map +1 -0
  118. package/lite/announce.test.js +71 -0
  119. package/lite/announce.test.js.map +1 -0
  120. package/lite/connection.d.ts +45 -19
  121. package/lite/connection.d.ts.map +1 -1
  122. package/lite/connection.js +85 -80
  123. package/lite/connection.js.map +1 -1
  124. package/lite/datagram.d.ts +23 -0
  125. package/lite/datagram.d.ts.map +1 -0
  126. package/lite/datagram.js +57 -0
  127. package/lite/datagram.js.map +1 -0
  128. package/lite/datagram.test.d.ts +2 -0
  129. package/lite/datagram.test.d.ts.map +1 -0
  130. package/lite/datagram.test.js +26 -0
  131. package/lite/datagram.test.js.map +1 -0
  132. package/lite/datagram_stream.d.ts +8 -0
  133. package/lite/datagram_stream.d.ts.map +1 -0
  134. package/lite/datagram_stream.js +44 -0
  135. package/lite/datagram_stream.js.map +1 -0
  136. package/lite/datagram_stream.test.d.ts +2 -0
  137. package/lite/datagram_stream.test.d.ts.map +1 -0
  138. package/lite/datagram_stream.test.js +15 -0
  139. package/lite/datagram_stream.test.js.map +1 -0
  140. package/lite/fetch.d.ts.map +1 -1
  141. package/lite/fetch.js +2 -2
  142. package/lite/fetch.js.map +1 -1
  143. package/lite/fetch.test.d.ts +2 -0
  144. package/lite/fetch.test.d.ts.map +1 -0
  145. package/lite/fetch.test.js +41 -0
  146. package/lite/fetch.test.js.map +1 -0
  147. package/lite/index.d.ts +3 -0
  148. package/lite/index.d.ts.map +1 -1
  149. package/lite/index.js +3 -0
  150. package/lite/index.js.map +1 -1
  151. package/lite/publisher.d.ts +13 -6
  152. package/lite/publisher.d.ts.map +1 -1
  153. package/lite/publisher.js +274 -64
  154. package/lite/publisher.js.map +1 -1
  155. package/lite/publisher.test.d.ts +2 -0
  156. package/lite/publisher.test.d.ts.map +1 -0
  157. package/lite/publisher.test.js +65 -0
  158. package/lite/publisher.test.js.map +1 -0
  159. package/lite/setup.d.ts +72 -6
  160. package/lite/setup.d.ts.map +1 -1
  161. package/lite/setup.js +184 -31
  162. package/lite/setup.js.map +1 -1
  163. package/lite/setup.test.d.ts +2 -0
  164. package/lite/setup.test.d.ts.map +1 -0
  165. package/lite/setup.test.js +122 -0
  166. package/lite/setup.test.js.map +1 -0
  167. package/lite/stream.d.ts +12 -3
  168. package/lite/stream.d.ts.map +1 -1
  169. package/lite/stream.js +7 -4
  170. package/lite/stream.js.map +1 -1
  171. package/lite/subscribe.d.ts +37 -23
  172. package/lite/subscribe.d.ts.map +1 -1
  173. package/lite/subscribe.js +70 -55
  174. package/lite/subscribe.js.map +1 -1
  175. package/lite/subscribe.test.d.ts +2 -0
  176. package/lite/subscribe.test.d.ts.map +1 -0
  177. package/lite/subscribe.test.js +68 -0
  178. package/lite/subscribe.test.js.map +1 -0
  179. package/lite/subscriber.d.ts +24 -17
  180. package/lite/subscriber.d.ts.map +1 -1
  181. package/lite/subscriber.js +515 -90
  182. package/lite/subscriber.js.map +1 -1
  183. package/lite/subscriber.test.js +2 -2
  184. package/lite/subscriber.test.js.map +1 -1
  185. package/lite/track.d.ts +25 -13
  186. package/lite/track.d.ts.map +1 -1
  187. package/lite/track.js +60 -35
  188. package/lite/track.js.map +1 -1
  189. package/lite/track.test.js +12 -10
  190. package/lite/track.test.js.map +1 -1
  191. package/lite/version.d.ts +17 -4
  192. package/lite/version.d.ts.map +1 -1
  193. package/lite/version.js +88 -17
  194. package/lite/version.js.map +1 -1
  195. package/mock.d.ts +42 -3
  196. package/mock.d.ts.map +1 -1
  197. package/mock.js +88 -17
  198. package/mock.js.map +1 -1
  199. package/package.json +3 -3
  200. package/path.d.ts +30 -0
  201. package/path.d.ts.map +1 -1
  202. package/path.js +49 -0
  203. package/path.js.map +1 -1
  204. package/path.test.js +41 -0
  205. package/path.test.js.map +1 -1
  206. package/stream.test.js +10 -0
  207. package/stream.test.js.map +1 -1
  208. package/time.d.ts +109 -86
  209. package/time.d.ts.map +1 -1
  210. package/time.js +80 -30
  211. package/time.js.map +1 -1
  212. package/time.test.d.ts +2 -0
  213. package/time.test.d.ts.map +1 -0
  214. package/time.test.js +12 -0
  215. package/time.test.js.map +1 -0
  216. package/track.d.ts +225 -45
  217. package/track.d.ts.map +1 -1
  218. package/track.js +505 -93
  219. package/track.js.map +1 -1
  220. package/track.test.js +138 -29
  221. package/track.test.js.map +1 -1
  222. package/util/error.d.ts +9 -0
  223. package/util/error.d.ts.map +1 -1
  224. package/util/error.js +21 -0
  225. package/util/error.js.map +1 -1
  226. package/util/error.test.d.ts +2 -0
  227. package/util/error.test.d.ts.map +1 -0
  228. package/util/error.test.js +45 -0
  229. package/util/error.test.js.map +1 -0
  230. package/util/index.d.ts +1 -0
  231. package/util/index.d.ts.map +1 -1
  232. package/util/index.js +1 -0
  233. package/util/index.js.map +1 -1
  234. package/util/timeout.d.ts +5 -0
  235. package/util/timeout.d.ts.map +1 -0
  236. package/util/timeout.js +18 -0
  237. package/util/timeout.js.map +1 -0
  238. package/util/timeout.test.d.ts +2 -0
  239. package/util/timeout.test.d.ts.map +1 -0
  240. package/util/timeout.test.js +18 -0
  241. package/util/timeout.test.js.map +1 -0
  242. package/varint.d.ts +6 -0
  243. package/varint.d.ts.map +1 -1
  244. package/varint.js +6 -2
  245. package/varint.js.map +1 -1
  246. package/zod.d.ts +4 -4
  247. package/zod.d.ts.map +1 -1
  248. package/zod.js.map +1 -1
  249. package/bandwidth.d.ts +0 -11
  250. package/bandwidth.d.ts.map +0 -1
  251. package/bandwidth.js +0 -7
  252. package/bandwidth.js.map +0 -1
@@ -1,15 +1,45 @@
1
1
  /* @ts-self-types="./subscriber.d.ts" */
2
- import { Announced } from "../announced.js";
3
- import { Broadcast } from "../broadcast.js";
4
- import { Group } from "../group.js";
2
+ import { Signal } from "@moq/signals";
3
+ import * as announce from "../announced.js";
4
+ import * as broadcast from "../broadcast.js";
5
+ import { BroadcastCache } from "../consume.js";
6
+ import * as netGroup from "../group.js";
5
7
  import * as Path from "../path.js";
6
8
  import { Stream } from "../stream.js";
7
- import { error } from "../util/error.js";
8
- import { Announce, AnnounceInit, AnnounceInterest } from "./announce.js";
9
+ import * as Time from "../time.js";
10
+ import { error, reason } from "../util/error.js";
11
+ import { withTimeout } from "../util/timeout.js";
12
+ import { AnnounceInit, AnnounceOk, AnnounceRequest, decodeAnnounceBroadcastMaybe } from "./announce.js";
13
+ import { Datagram as DatagramMessage } from "./datagram.js";
14
+ import * as DatagramStream from "./datagram_stream.js";
15
+ import { Fetch as FetchMessage } from "./fetch.js";
9
16
  import { Probe } from "./probe.js";
17
+ import { ProbeLevel } from "./setup.js";
10
18
  import { StreamId } from "./stream.js";
11
19
  import { decodeSubscribeResponse, decodeSubscribeResponseMaybe, Subscribe, SubscribeUpdate } from "./subscribe.js";
12
- import { hasTrackStream, Version } from "./version.js";
20
+ import { TrackInfo, Track as TrackMessage } from "./track.js";
21
+ import { hasAnnounceId, hasAnnounceOk, hasDatagrams, Version } from "./version.js";
22
+ // Bound on how long stream-open plus the first response (SUBSCRIBE_OK on older
23
+ // drafts, or TRACK_INFO on lite-05+) may take. Browsers cap concurrent QUIC
24
+ // streams (Chrome ~100); past the cap createBidirectionalStream silently blocks.
25
+ // The timeout turns that into a clear error.
26
+ const SUBSCRIBE_SETUP_TIMEOUT_MS = 10_000;
27
+ /** Decode an unsigned zigzag varint back to a signed delta (mirrors Rust `VarInt::to_zigzag`). */
28
+ function unzigzag(v) {
29
+ return (v >> 1n) ^ -(v & 1n);
30
+ }
31
+ // The TRACK stream and implicit SUBSCRIBE acceptance are lite-05+.
32
+ function supportsTrackStream(version) {
33
+ switch (version) {
34
+ case Version.DRAFT_01:
35
+ case Version.DRAFT_02:
36
+ case Version.DRAFT_03:
37
+ case Version.DRAFT_04:
38
+ return false;
39
+ default:
40
+ return true;
41
+ }
42
+ }
13
43
  /**
14
44
  * Handles subscribing to broadcasts and managing their lifecycle.
15
45
  *
@@ -22,13 +52,22 @@ export class Subscriber {
22
52
  // Shared with the Publisher so callers can optionally filter out their
23
53
  // own announcements on a per-call basis (see {@link AnnouncedOptions}).
24
54
  origin;
25
- // Our subscribed tracks.
55
+ // Our subscribed tracks. `timescale` resolves once known (from TRACK_INFO on
56
+ // lite-05+, or implicit defaults on older drafts); group streams block on it
57
+ // before decoding any frame, since a group's QUIC stream can race ahead.
26
58
  #subscribes = new Map();
27
59
  #subscribeNext = 0n;
28
- // Recv bandwidth producer (Lite03+ only).
29
- #recvBandwidth;
30
- // RTT producer (Lite04+ only).
31
- #rtt;
60
+ // Dedup consumed broadcasts per path: repeat consume() calls share one subscription.
61
+ #consumes = new BroadcastCache();
62
+ // Dedup in-flight one-shot fetches, keyed by [broadcast, track, sequence]. Concurrent (or
63
+ // repeat, while still open) fetchGroup() calls for the same group share one FETCH stream and
64
+ // each get an independent mirror; the entry is evicted once the group closes.
65
+ #fetches = new Map();
66
+ // The peer's PROBE estimates, written as they arrive (Lite03+ only).
67
+ #probe;
68
+ // The peer's SETUP (lite-05+), undefined until it arrives. Gates opening the PROBE
69
+ // stream on the peer having advertised Probe >= Report.
70
+ #peerSetup;
32
71
  // Distinguishes failures from streams torn down by Subscriber.close().
33
72
  #closed = new AbortController();
34
73
  /**
@@ -36,17 +75,17 @@ export class Subscriber {
36
75
  * @param quic - The WebTransport session to use
37
76
  * @param version - The protocol version
38
77
  * @param origin - Origin id shared with the Publisher
39
- * @param recvBandwidth - Optional bandwidth producer for PROBE
40
- * @param rtt - Optional RTT signal for PROBE
78
+ * @param probe - Optional sink for the peer's PROBE estimates
79
+ * @param peerSetup - Optional peer SETUP slot for capability gating (lite-05+)
41
80
  *
42
81
  * @internal
43
82
  */
44
- constructor(quic, version, origin, recvBandwidth, rtt) {
83
+ constructor(quic, version, origin, probe, peerSetup) {
45
84
  this.#quic = quic;
46
85
  this.version = version;
47
86
  this.origin = origin;
48
- this.#recvBandwidth = recvBandwidth;
49
- this.#rtt = rtt;
87
+ this.#probe = probe;
88
+ this.#peerSetup = peerSetup;
50
89
  }
51
90
  /**
52
91
  * Subscribe to broadcast announcements under `prefix`.
@@ -55,21 +94,29 @@ export class Subscriber {
55
94
  * this connection's {@link origin}.
56
95
  */
57
96
  announced(prefix = Path.empty(), options = {}) {
58
- const announced = new Announced();
97
+ const announced = new announce.Producer(prefix);
59
98
  void this.#runAnnounced(announced, prefix, options);
60
- return announced;
99
+ return announced.consume();
61
100
  }
62
101
  async #runAnnounced(announced, prefix, options) {
63
102
  console.debug(`announced: prefix=${prefix}`);
64
103
  // Send our own session-level origin id so the peer can skip announces
65
104
  // whose hop chain already passed through us. Matches the Rust subscriber's
66
105
  // `exclude_hop: self.self_origin.id` in `run_announce_prefix`.
67
- const msg = new AnnounceInterest(prefix, this.origin);
106
+ const msg = new AnnounceRequest(prefix, this.origin);
68
107
  try {
69
108
  // Open a stream and send the announce interest.
70
109
  const stream = await Stream.open(this.#quic);
71
110
  await stream.writer.u53(StreamId.Announce);
72
111
  await msg.encode(stream.writer, this.version);
112
+ // Lite05+: the publisher reports its own origin id before any announces.
113
+ // It no longer stamps itself onto each hop chain, so we append it here to
114
+ // keep the ignoreSelf loop check seeing the full chain.
115
+ let responderOrigin;
116
+ if (hasAnnounceOk(this.version)) {
117
+ const ok = await AnnounceOk.decode(stream.reader, this.version);
118
+ responderOrigin = ok.origin;
119
+ }
73
120
  switch (this.version) {
74
121
  case Version.DRAFT_01:
75
122
  case Version.DRAFT_02: {
@@ -79,7 +126,7 @@ export class Subscriber {
79
126
  for (const suffix of init.suffixes) {
80
127
  const path = Path.join(prefix, suffix);
81
128
  console.debug(`announced: broadcast=${path} active=true`);
82
- announced.append({ path, active: true });
129
+ announced.append({ path: suffix, active: true });
83
130
  }
84
131
  break;
85
132
  }
@@ -87,24 +134,73 @@ export class Subscriber {
87
134
  // Draft03+: no AnnounceInit, initial state comes via Announce messages.
88
135
  break;
89
136
  }
137
+ // Lite06+: announce ids. Each received `active` implicitly assigns the next
138
+ // per-stream ordinal; `endedId`/`restart` reference it. Tracked even for
139
+ // announces we skip via ignoreSelf, since the sender doesn't know we skipped.
140
+ let nextAnnounceId = 0n;
141
+ const announcedById = new Map();
90
142
  // Receive announce updates (for Draft03, this includes initial state)
91
143
  for (;;) {
92
144
  const announce = await Promise.race([
93
- Announce.decodeMaybe(stream.reader, this.version),
145
+ decodeAnnounceBroadcastMaybe(stream.reader, this.version),
94
146
  announced.closed,
95
147
  ]);
148
+ // undefined: the stream ended. null: the consumer closed cleanly.
96
149
  if (!announce)
97
150
  break;
98
151
  if (announce instanceof Error)
99
152
  throw announce;
153
+ let suffix;
154
+ let active;
155
+ // Present on active/restart; ended messages never carry hops worth checking.
156
+ let hops;
157
+ switch (announce.status) {
158
+ case "active":
159
+ suffix = announce.suffix;
160
+ active = true;
161
+ hops = announce.hops;
162
+ if (hasAnnounceId(this.version)) {
163
+ announcedById.set(nextAnnounceId++, announce.suffix);
164
+ }
165
+ break;
166
+ case "ended":
167
+ suffix = announce.suffix;
168
+ active = false;
169
+ break;
170
+ case "endedId": {
171
+ // Resolve and retire the id; an unknown or retired id is a protocol violation.
172
+ const path = announcedById.get(announce.id);
173
+ if (path === undefined)
174
+ throw new Error(`unknown announce id: ${announce.id}`);
175
+ announcedById.delete(announce.id);
176
+ suffix = path;
177
+ active = false;
178
+ break;
179
+ }
180
+ case "restart": {
181
+ // Resolve the id; it stays live (the replacement reuses it).
182
+ const path = announcedById.get(announce.id);
183
+ if (path === undefined)
184
+ throw new Error(`unknown announce id: ${announce.id}`);
185
+ suffix = path;
186
+ active = true;
187
+ hops = announce.hops;
188
+ break;
189
+ }
190
+ }
100
191
  // Optionally drop reflected announces so callers asking for
101
- // "someone else's broadcasts" don't re-see their own publishes.
102
- if (options.ignoreSelf && announce.hops.includes(this.origin)) {
103
- continue;
192
+ // "someone else's broadcasts" don't re-see their own publishes. In
193
+ // Lite05+ the sender's origin arrives via AnnounceOk, not in each hop
194
+ // list, so fold it back in before checking.
195
+ if (hops !== undefined && options.ignoreSelf) {
196
+ const full = responderOrigin !== undefined ? [...hops, responderOrigin] : hops;
197
+ if (full.includes(this.origin)) {
198
+ continue;
199
+ }
104
200
  }
105
- const path = Path.join(prefix, announce.suffix);
106
- console.debug(`announced: broadcast=${path} active=${announce.active}`);
107
- announced.append({ path, active: announce.active });
201
+ const path = Path.join(prefix, suffix);
202
+ console.debug(`announced: broadcast=${path} active=${active}`);
203
+ announced.append({ path: suffix, active });
108
204
  }
109
205
  announced.close();
110
206
  }
@@ -115,78 +211,278 @@ export class Subscriber {
115
211
  /**
116
212
  * Consumes a broadcast from the connection.
117
213
  *
214
+ * Deduplicated per path: repeat calls for the same still-live path share one reference-counted
215
+ * broadcast (and one upstream subscription). The shared broadcast closes once every caller has
216
+ * closed its handle, so callers close normally.
217
+ *
118
218
  * @param name - The name of the broadcast to consume
119
219
  * @returns A Broadcast instance
120
220
  */
121
221
  consume(path) {
122
- const broadcast = new Broadcast();
222
+ return this.#consumes.get(path) ?? this.#consumes.insert(path, this.#createConsume(path));
223
+ }
224
+ #createConsume(path) {
225
+ // A consumed broadcast resolves info() and fetchGroup() over the wire by reaching
226
+ // back into this Subscriber (see ConsumeBroadcast below), rather than the wire
227
+ // installing callbacks on the broadcast.
228
+ const consumer = new ConsumeBroadcast(this, path);
123
229
  void (async () => {
124
230
  for (;;) {
125
- const request = await broadcast.requested();
231
+ const request = await consumer.requested();
126
232
  if (!request)
127
233
  break;
128
234
  void this.#runSubscribe(path, request);
129
235
  }
130
236
  })();
131
- return broadcast;
237
+ return consumer;
132
238
  }
133
239
  async #runSubscribe(broadcast, request) {
134
240
  const id = this.#subscribeNext++;
135
- // Save the writer so we can append groups to it.
136
- this.#subscribes.set(id, request.track);
137
- console.debug(`subscribe start: id=${id} broadcast=${broadcast} track=${request.track.name}`);
138
- const msg = new Subscribe({ id, broadcast, track: request.track.name, priority: request.priority });
139
- const stream = await Stream.open(this.#quic);
140
- await stream.writer.u53(StreamId.Subscribe);
141
- await msg.encode(stream.writer, this.version);
241
+ // `timescale` stays undefined until TRACK_INFO (or, on older drafts,
242
+ // implicit defaults) resolves it; runGroup blocks on it before decoding.
243
+ const timescale = new Signal(undefined);
244
+ console.debug(`subscribe start: id=${id} broadcast=${broadcast} track=${request.name}`);
245
+ const msg = new Subscribe({ id, broadcast, track: request.name, priority: request.priority });
246
+ // Open the stream under a timeout. The stream handle flows back via `state`
247
+ // so the timeout path can abort it if it finishes opening after the deadline.
248
+ const state = {};
249
+ const setup = this.#openSubscribe(state, msg, request, id, timescale);
250
+ let opened;
251
+ try {
252
+ opened = await withTimeout(setup, SUBSCRIBE_SETUP_TIMEOUT_MS, `subscribe timed out after ${SUBSCRIBE_SETUP_TIMEOUT_MS}ms waiting for the first response (browser stream limit reached?)`);
253
+ console.debug(`subscribe ok: id=${id} broadcast=${broadcast} track=${request.name}`);
254
+ }
255
+ catch (err) {
256
+ const e = error(err);
257
+ request.reject(e);
258
+ this.#subscribes.delete(id);
259
+ console.warn(`subscribe error: id=${id} broadcast=${broadcast} track=${request.name} error=${reason(e)}`);
260
+ // If the stream eventually opens after the timeout, abort it so we
261
+ // don't leak it. Cover both branches: setup may resolve late, or it
262
+ // may reject (e.g. encode/decode failure) after the stream is open.
263
+ setup.then(() => state.stream?.abort(e), () => state.stream?.abort(e));
264
+ return;
265
+ }
266
+ const { stream, producer } = opened;
142
267
  try {
143
- // The first response MUST be a SUBSCRIBE_OK.
144
- const resp = await decodeSubscribeResponse(stream.reader, this.version);
145
- if (!("ok" in resp)) {
146
- throw new Error("first subscribe response must be SUBSCRIBE_OK");
147
- }
148
- console.debug(`subscribe ok: id=${id} broadcast=${broadcast} track=${request.track.name}`);
149
268
  // Watch for priority changes and send SUBSCRIBE_UPDATE. Lite01/Lite02
150
269
  // don't carry SUBSCRIBE_UPDATE on the wire, so skip the watcher there
151
270
  // and just wait on the stream/track like before.
152
- // Draining responses also consumes any SUBSCRIBE_END / SUBSCRIBE_DROP and
153
- // resolves when the publisher FINs.
154
- const waits = [this.#drainResponses(stream), request.track.closed];
155
- switch (this.version) {
156
- case Version.DRAFT_01:
157
- case Version.DRAFT_02:
158
- break;
159
- default:
160
- waits.push(this.#runPriorityUpdates(id, broadcast, request.track, msg, stream));
161
- break;
271
+ //
272
+ // On lite-05+ the publisher sends SUBSCRIBE_START/END/DROP on this stream;
273
+ // drain them (we don't drive delivery off the resolved range) so the FIN is
274
+ // observed. Older drafts just wait for the stream to close.
275
+ const closed = supportsTrackStream(this.version) ? this.#drainResponses(stream) : stream.reader.closed;
276
+ const priorityUpdates = this.version === Version.DRAFT_01 || this.version === Version.DRAFT_02
277
+ ? undefined
278
+ : this.#runPriorityUpdates(id, broadcast, producer, msg, stream);
279
+ // Terminal conditions (stream end, track close, a failed priority update) settle at most
280
+ // once; race them into one stable promise so the demand loop doesn't re-subscribe each pass.
281
+ const terminal = [closed, producer.closed];
282
+ if (priorityUpdates !== undefined)
283
+ terminal.push(priorityUpdates);
284
+ const done = Promise.race(terminal);
285
+ // Serve until a terminal condition fires or the last local subscriber leaves. The unused
286
+ // wake is level-triggered: re-check demand so a subscriber that returns before we tear
287
+ // down (e.g. a quickly unmuted tile) resumes on the same subscription.
288
+ const idle = Symbol("idle");
289
+ for (;;) {
290
+ const reason = await Promise.race([done, producer.unused().then(() => idle)]);
291
+ if (reason === idle && producer.closed.peek() === undefined && producer.used.peek())
292
+ continue;
293
+ break;
162
294
  }
163
- await Promise.race(waits);
164
- request.track.close();
295
+ producer.close();
165
296
  stream.close();
166
- console.debug(`subscribe close: id=${id} broadcast=${broadcast} track=${request.track.name}`);
297
+ console.debug(`subscribe close: id=${id} broadcast=${broadcast} track=${request.name}`);
167
298
  }
168
299
  catch (err) {
169
300
  const e = error(err);
170
- request.track.close(e);
171
- console.warn(`subscribe error: id=${id} broadcast=${broadcast} track=${request.track.name} error=${e.message}`);
301
+ producer.close(e);
302
+ console.warn(`subscribe error: id=${id} broadcast=${broadcast} track=${request.name} error=${reason(e)}`);
172
303
  stream.abort(e);
173
304
  }
174
305
  finally {
175
306
  this.#subscribes.delete(id);
176
307
  }
177
308
  }
178
- /**
179
- * Drain responses on the subscribe stream until the publisher FINs.
180
- *
181
- * The first SUBSCRIBE_OK is consumed by the caller; this reads any further
182
- * SUBSCRIBE_END / SUBSCRIBE_DROP. They aren't acted on yet (groups arrive on
183
- * their own streams regardless), but consuming them keeps the stream aligned.
184
- */
309
+ // Determine the track's immutable properties, accept the request (so the
310
+ // application's track.Subscriber resolves and incoming groups have a producer to
311
+ // write into), register it, then open the subscribe stream. `state.stream` is
312
+ // populated as soon as the subscribe stream opens so the caller can clean it up
313
+ // on timeout even before this promise settles.
314
+ //
315
+ // On lite-05+ the properties come from a TRACK stream opened first, and the
316
+ // SUBSCRIBE is accepted implicitly (no SUBSCRIBE_OK). Older drafts carry no
317
+ // per-track properties, so they resolve to defaults and just drain SUBSCRIBE_OK.
318
+ async #openSubscribe(state, msg, request, id, timescale) {
319
+ let producer;
320
+ let drainOk = false;
321
+ if (supportsTrackStream(this.version)) {
322
+ // Fetch the immutable properties once via the TRACK stream.
323
+ const info = await this.#trackInfo(msg.broadcast, msg.track);
324
+ producer = request.accept(this.#toModelInfo(info));
325
+ timescale.set(info.timescale);
326
+ }
327
+ else {
328
+ // Older drafts negotiate nothing per-track: verbatim frames, no timescale.
329
+ producer = request.accept();
330
+ timescale.set(0);
331
+ drainOk = true;
332
+ }
333
+ // Register before opening SUBSCRIBE so a racing GROUP stream finds the entry.
334
+ this.#subscribes.set(id, { track: producer, timescale });
335
+ state.stream = await Stream.open(this.#quic);
336
+ await state.stream.writer.u53(StreamId.Subscribe);
337
+ await msg.encode(state.stream.writer, this.version);
338
+ if (drainOk) {
339
+ // The first response MUST be a SUBSCRIBE_OK (older drafts only).
340
+ const resp = await decodeSubscribeResponse(state.stream.reader, this.version);
341
+ if (!("ok" in resp)) {
342
+ throw new Error("first subscribe response must be SUBSCRIBE_OK");
343
+ }
344
+ }
345
+ return { stream: state.stream, producer };
346
+ }
347
+ // Opens a TRACK stream, reads the single TRACK_INFO, and FINs. Lite-05+ only.
348
+ async #trackInfo(broadcast, track) {
349
+ const stream = await Stream.open(this.#quic);
350
+ try {
351
+ await stream.writer.u53(StreamId.Track);
352
+ await new TrackMessage(broadcast, track).encode(stream.writer, this.version);
353
+ const info = await TrackInfo.decode(stream.reader, this.version);
354
+ // The publisher FINs after TRACK_INFO; FIN our side too.
355
+ stream.close();
356
+ return info;
357
+ }
358
+ catch (err) {
359
+ stream.abort(error(err));
360
+ throw err;
361
+ }
362
+ }
363
+ // Map the wire TRACK_INFO onto the model track.Info a producer/consumer holds.
364
+ #toModelInfo(info) {
365
+ return {
366
+ timescale: Time.Timescale(info.timescale),
367
+ // Publisher Max Latency rides on the wire, so the local retention window
368
+ // matches what the upstream advertises (relays re-serve with the same bound).
369
+ latencyMax: info.latencyMax,
370
+ priority: info.priority,
371
+ ordered: info.ordered,
372
+ };
373
+ }
374
+ // Resolve a track's immutable model info via a TRACK stream (lite-05+), for the
375
+ // ConsumeBroadcast backing track.Consumer.info(). On older drafts there's no TRACK
376
+ // stream, so this rejects rather than fabricating defaults.
377
+ async resolveTrackInfo(broadcast, track) {
378
+ if (!supportsTrackStream(this.version)) {
379
+ throw new Error("track info requires moq-lite-05 or newer");
380
+ }
381
+ return this.#toModelInfo(await this.#trackInfo(broadcast, track));
382
+ }
383
+ // Open a FETCH stream for one group and stream its bare frames into a group, for the
384
+ // ConsumeBroadcast backing track.Consumer.fetchGroup() (lite-05+).
385
+ fetchGroup(broadcast, track, sequence, options = {}) {
386
+ // Coalesce onto a still-open fetch of the same group so we don't open a second FETCH
387
+ // stream (and re-download it); each caller reads an independent mirror.
388
+ const key = JSON.stringify([broadcast, track, sequence]);
389
+ const existing = this.#fetches.get(key);
390
+ if (existing && !existing.isClosed)
391
+ return Promise.resolve(existing.mirror());
392
+ // Create and cache the group synchronously (before any await) so a concurrent fetch for
393
+ // the same group finds it and coalesces rather than racing to open its own stream.
394
+ const group = new netGroup.Producer(sequence);
395
+ this.#fetches.set(key, group);
396
+ void group.closed.then(() => {
397
+ if (this.#fetches.get(key) === group)
398
+ this.#fetches.delete(key);
399
+ });
400
+ return this.#runFetch(broadcast, track, sequence, options, group);
401
+ }
402
+ // Open the FETCH stream and pump the response into the shared group. Setup errors close the
403
+ // group (so coalesced mirrors observe them and the entry evicts) and reject this caller.
404
+ async #runFetch(broadcast, track, sequence, options, group) {
405
+ try {
406
+ if (!supportsTrackStream(this.version)) {
407
+ throw new Error("fetch group requires moq-lite-05 or newer");
408
+ }
409
+ const info = await this.#trackInfo(broadcast, track);
410
+ const priority = options.priority ?? 0;
411
+ const stream = await Stream.open(this.#quic, undefined, priority);
412
+ try {
413
+ await stream.writer.u53(StreamId.Fetch);
414
+ await new FetchMessage(broadcast, track, priority, sequence).encode(stream.writer, this.version);
415
+ }
416
+ catch (err) {
417
+ stream.abort(error(err));
418
+ throw err;
419
+ }
420
+ // Mint this caller's reader before starting the pump, so the group has demand when the
421
+ // pump begins watching it (an abandoned fetch cancels once every reader has left).
422
+ const consumer = group.mirror();
423
+ void this.#runFetchResponse(stream, group, Time.Timescale(info.timescale));
424
+ return consumer;
425
+ }
426
+ catch (err) {
427
+ group.close(error(err));
428
+ throw err;
429
+ }
430
+ }
431
+ // Read the FETCH response (bare zigzag-delta-timestamped frames) into the group, then
432
+ // FIN. A stream-level failure aborts the group so its reader observes the gap.
433
+ async #runFetchResponse(stream, group, timescale) {
434
+ try {
435
+ let prevTs = 0n;
436
+ // Serve until the stream FINs, the group closes, or every reader leaves. A group can
437
+ // stay open indefinitely (a catalog or JSON stream), so an abandoned fetch is stopped by
438
+ // demand, not by the stream ending. `closed` and `unused` are watched across frames as
439
+ // stable promises (not re-subscribed to the signals each frame); the unused check is
440
+ // level-triggered, so a coalesced fetch that arrives before we cancel re-arms and resumes.
441
+ const idle = Symbol("idle");
442
+ const closed = Promise.resolve(group.closed);
443
+ let unused = group.unused().then(() => idle);
444
+ for (;;) {
445
+ const done = await Promise.race([stream.reader.done(), closed, unused]);
446
+ if (done === idle) {
447
+ if (!group.isClosed && group.used.peek()) {
448
+ unused = group.unused().then(() => idle);
449
+ continue;
450
+ }
451
+ break;
452
+ }
453
+ if (done !== false)
454
+ break;
455
+ prevTs += unzigzag(await stream.reader.u62());
456
+ const timestamp = new Time.Timestamp(Number(prevTs), timescale);
457
+ const size = await stream.reader.u53();
458
+ const payload = await stream.reader.read(size);
459
+ if (!payload)
460
+ break;
461
+ group.writeFrame({ payload, timestamp });
462
+ }
463
+ group.close();
464
+ stream.close();
465
+ }
466
+ catch (err) {
467
+ const e = error(err);
468
+ group.close(e);
469
+ stream.abort(e);
470
+ }
471
+ }
472
+ // Drains SUBSCRIBE_START/END/DROP on the subscribe stream until FIN (lite-05+).
473
+ // The resolved range is informational here; the producer already orders groups.
474
+ // Resolves (never rejects) on FIN or on the stream being reset out from under it,
475
+ // so it's safe to drop from a Promise.race without an unhandled rejection.
185
476
  async #drainResponses(stream) {
186
- for (;;) {
187
- const resp = await decodeSubscribeResponseMaybe(stream.reader, this.version);
188
- if (!resp)
189
- break;
477
+ try {
478
+ for (;;) {
479
+ const resp = await decodeSubscribeResponseMaybe(stream.reader, this.version);
480
+ if (!resp)
481
+ return;
482
+ }
483
+ }
484
+ catch {
485
+ // Stream closed or reset; nothing more to drain.
190
486
  }
191
487
  }
192
488
  /**
@@ -204,10 +500,10 @@ export class Subscriber {
204
500
  const stopped = Promise.race([track.closed, stream.reader.closed]).then(() => null);
205
501
  let lastSent;
206
502
  for (;;) {
207
- const current = track.state.priority.peek();
503
+ const current = track.subscription.peek()?.priority;
208
504
  if (current === undefined || current === lastSent) {
209
505
  // Nothing new to send; wait for a change or termination.
210
- const next = await Promise.race([track.state.priority.next(), stopped]);
506
+ const next = await Promise.race([track.subscription.changed(), stopped]);
211
507
  if (next === null)
212
508
  return;
213
509
  continue;
@@ -234,30 +530,51 @@ export class Subscriber {
234
530
  * @internal
235
531
  */
236
532
  async runGroup(group, stream) {
237
- const subscribe = this.#subscribes.get(group.subscribe);
238
- if (!subscribe) {
533
+ const entry = this.#subscribes.get(group.subscribe);
534
+ if (!entry) {
239
535
  if (group.subscribe >= this.#subscribeNext) {
240
536
  throw new Error(`unknown subscription: id=${group.subscribe}`);
241
537
  }
242
538
  return;
243
539
  }
244
- const producer = new Group(group.sequence);
245
- subscribe.writeGroup(producer);
540
+ const { track, timescale } = entry;
541
+ const producer = new netGroup.Producer(group.sequence);
542
+ track.writeGroup(producer);
246
543
  try {
544
+ // Block until the timescale is known; the group's stream can arrive before
545
+ // TRACK_INFO (or implicit defaults) resolves it on the subscribe stream.
546
+ let scale = timescale.peek();
547
+ while (scale === undefined) {
548
+ if (track.closed.peek() !== undefined) {
549
+ // Subscription ended before the scale resolved; nothing to decode.
550
+ producer.close();
551
+ stream.stop(new Error("cancel"));
552
+ return;
553
+ }
554
+ await Signal.race(timescale, track.closed);
555
+ scale = timescale.peek();
556
+ }
557
+ // A non-zero scale means every frame is prefixed with a zigzag-delta timestamp
558
+ // (the lite-05 FRAME format), which we decode into a Timestamp at that scale.
559
+ // Scale 0 (pre-lite-05) carries no timestamp, so we wall-clock-stamp.
560
+ let prevTs = 0n;
247
561
  for (;;) {
248
- const done = await Promise.race([stream.done(), subscribe.closed, producer.closed]);
562
+ const done = await Promise.race([stream.done(), track.closed, producer.closed]);
249
563
  if (done !== false)
250
564
  break;
251
- if (hasTrackStream(this.version)) {
252
- // moq-lite-05+ prefixes each frame with a zigzag timestamp delta. Decode it
253
- // to stay aligned with the wire, but don't surface it yet.
254
- await stream.u62();
565
+ let timestamp;
566
+ if (scale !== 0) {
567
+ prevTs += unzigzag(await stream.u62());
568
+ timestamp = new Time.Timestamp(Number(prevTs), Time.Timescale(scale));
569
+ }
570
+ else {
571
+ timestamp = Time.Timestamp.now();
255
572
  }
256
573
  const size = await stream.u53();
257
574
  const payload = await stream.read(size);
258
575
  if (!payload)
259
576
  break;
260
- producer.writeFrame(payload);
577
+ producer.writeFrame({ payload, timestamp });
261
578
  }
262
579
  producer.close();
263
580
  stream.stop(new Error("cancel"));
@@ -268,6 +585,69 @@ export class Subscriber {
268
585
  stream.stop(e);
269
586
  }
270
587
  }
588
+ /**
589
+ * Receives QUIC datagrams and routes each to its subscription's track producer (lite-05 §6.4).
590
+ *
591
+ * Returns immediately on a non-datagram transport or pre-lite-05 version. A decode error or an
592
+ * unknown subscribe id drops that datagram without tearing down the session (best-effort); the
593
+ * loop ends only when the datagram stream closes.
594
+ *
595
+ * @internal
596
+ */
597
+ async runDatagrams() {
598
+ if (!hasDatagrams(this.version) || DatagramStream.maxDatagramSize(this.#quic) === 0) {
599
+ return;
600
+ }
601
+ // Never reject: this loop is awaited alongside the connection's other tasks, so a
602
+ // datagram-stream failure must not tear the whole session down (it's best-effort).
603
+ const reader = DatagramStream.datagramReader(this.#quic);
604
+ if (!reader)
605
+ return;
606
+ try {
607
+ try {
608
+ for (;;) {
609
+ const { value, done } = await reader.read();
610
+ if (done)
611
+ break;
612
+ if (!value)
613
+ continue;
614
+ try {
615
+ await this.#routeDatagram(value);
616
+ }
617
+ catch (err) {
618
+ console.debug(`dropping datagram: ${reason(err)}`);
619
+ }
620
+ }
621
+ }
622
+ finally {
623
+ reader.releaseLock();
624
+ }
625
+ }
626
+ catch (err) {
627
+ const e = error(err);
628
+ if (e.message === "The session is closed.") {
629
+ console.debug(`datagram receive stopped: ${e.message}`);
630
+ }
631
+ else {
632
+ console.warn("datagram stream error", err);
633
+ }
634
+ }
635
+ }
636
+ // Decode one datagram body and hand it to the matching subscription's producer. Drops the
637
+ // datagram (best-effort) if the subscription is unknown/closed or its timescale isn't resolved.
638
+ async #routeDatagram(payload) {
639
+ const dg = await DatagramMessage.decode(payload);
640
+ const entry = this.#subscribes.get(dg.subscribe);
641
+ if (!entry)
642
+ return; // Unknown or already-closed subscription.
643
+ // Datagrams are lite-05+, which always negotiates a timescale; if it hasn't resolved
644
+ // yet (the datagram raced ahead of TRACK_INFO), drop rather than guess.
645
+ const scale = entry.timescale.peek();
646
+ if (!scale)
647
+ return;
648
+ const timestamp = new Time.Timestamp(dg.timestamp, Time.Timescale(scale));
649
+ entry.track.writeDatagram({ sequence: dg.sequence, timestamp, payload: dg.payload });
650
+ }
271
651
  /**
272
652
  * Opens a PROBE bidi stream to receive bandwidth estimates from the publisher.
273
653
  * Returns immediately if recv bandwidth is not supported.
@@ -279,14 +659,31 @@ export class Subscriber {
279
659
  *
280
660
  * @internal
281
661
  */
662
+ // Await the peer's advertised probe level, blocking until its SETUP arrives. The peer
663
+ // MUST send exactly one SETUP, so this resolves once that stream is read.
664
+ async #peerProbeLevel(peerSetup) {
665
+ let setup = peerSetup.peek();
666
+ while (setup === undefined) {
667
+ setup = await peerSetup.changed();
668
+ }
669
+ return setup.probe;
670
+ }
282
671
  async runProbe() {
283
- if (!this.#recvBandwidth)
672
+ if (!this.#probe)
284
673
  return;
285
674
  if (this.version === Version.DRAFT_01 || this.version === Version.DRAFT_02)
286
675
  return;
676
+ // Lite-05+ gates the PROBE stream on the peer advertising Probe >= Report in its
677
+ // SETUP. Wait for the SETUP, then bail if the peer can't report bitrate. Older
678
+ // drafts have no SETUP, so they keep probing unconditionally.
679
+ if (this.#peerSetup) {
680
+ const probe = await this.#peerProbeLevel(this.#peerSetup);
681
+ if (probe < ProbeLevel.Report)
682
+ return;
683
+ }
287
684
  // Probe is best-effort: any failure (stream reset by peer, missing peer support,
288
685
  // transport hiccup) MUST NOT tear down the connection. On error, drop the
289
- // bandwidth/RTT estimates so consumers know they're stale.
686
+ // estimates so consumers know they're stale.
290
687
  try {
291
688
  const stream = await Stream.open(this.#quic);
292
689
  await stream.writer.u53(StreamId.Probe);
@@ -294,10 +691,13 @@ export class Subscriber {
294
691
  const probe = await Probe.decodeMaybe(stream.reader, this.version);
295
692
  if (!probe)
296
693
  break;
297
- this.#recvBandwidth.set(probe.bitrate ?? undefined);
298
- if (this.#rtt && probe.rtt !== undefined) {
299
- this.#rtt.set(probe.rtt);
300
- }
694
+ // A message that omits the RTT leaves the last one standing, so a
695
+ // bitrate-only report doesn't blank it.
696
+ const prev = this.#probe.peek();
697
+ this.#probe.set({
698
+ estimatedRecvRate: probe.bitrate ?? undefined,
699
+ rtt: probe.rtt !== undefined ? Time.Milli(probe.rtt) : prev.rtt,
700
+ });
301
701
  }
302
702
  }
303
703
  catch (err) {
@@ -306,16 +706,41 @@ export class Subscriber {
306
706
  }
307
707
  }
308
708
  finally {
309
- this.#recvBandwidth.set(undefined);
310
- this.#rtt?.set(undefined);
709
+ this.#probe.set({});
311
710
  }
312
711
  }
313
712
  close() {
314
713
  this.#closed.abort();
315
- for (const track of this.#subscribes.values()) {
714
+ for (const { track } of this.#subscribes.values()) {
316
715
  track.close();
317
716
  }
318
717
  this.#subscribes.clear();
319
718
  }
320
719
  }
720
+ /**
721
+ * A broadcast consumed from a lite session. It resolves `track.Consumer.info()` and
722
+ * `.fetchGroup()` over the wire (lite-05+ TRACK / FETCH streams) by reaching into the
723
+ * {@link Subscriber} it was opened from, the way the Rust `BroadcastConsumer` holds its
724
+ * session. Live subscribes still flow through the inherited requested() queue.
725
+ */
726
+ class ConsumeBroadcast extends broadcast.Consumer {
727
+ #subscriber;
728
+ #path;
729
+ constructor(subscriber, path, state) {
730
+ super(state);
731
+ this.#subscriber = subscriber;
732
+ this.#path = path;
733
+ }
734
+ // Preserve the subclass (and its wire-backed info/fetchGroup) when the consume cache shares
735
+ // this broadcast across callers.
736
+ clone() {
737
+ return new ConsumeBroadcast(this.#subscriber, this.#path, this.shareState());
738
+ }
739
+ resolveTrackInfo(name) {
740
+ return this.#subscriber.resolveTrackInfo(this.#path, name);
741
+ }
742
+ fetchGroup(name, sequence, options) {
743
+ return this.#subscriber.fetchGroup(this.#path, name, sequence, options);
744
+ }
745
+ }
321
746
  //# sourceMappingURL=subscriber.js.map