@moq/net 0.3.4 → 0.4.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 +2 -2
- package/announce.d.ts +7 -0
- package/announce.d.ts.map +1 -0
- package/announce.js +8 -0
- package/announce.js.map +1 -0
- package/announced.d.ts +35 -91
- package/announced.d.ts.map +1 -1
- package/announced.js +21 -156
- package/announced.js.map +1 -1
- package/bandwidth.d.ts +163 -0
- package/bandwidth.d.ts.map +1 -0
- package/bandwidth.js +304 -0
- package/bandwidth.js.map +1 -0
- package/bandwidth_api.d.ts +7 -0
- package/bandwidth_api.d.ts.map +1 -0
- package/bandwidth_api.js +8 -0
- package/bandwidth_api.js.map +1 -0
- package/broadcast.d.ts +20 -28
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +60 -42
- package/broadcast.js.map +1 -1
- package/connection/accept.d.ts +16 -1
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +39 -24
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +9 -7
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +30 -6
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +97 -50
- package/connection/connect.js.map +1 -1
- package/connection/established.d.ts +16 -21
- package/connection/established.d.ts.map +1 -1
- package/connection/established.js.map +1 -1
- package/connection/forward.d.ts +2 -0
- package/connection/forward.d.ts.map +1 -0
- package/connection/forward.js +159 -0
- package/connection/forward.js.map +1 -0
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +2 -2
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +5 -5
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +4 -5
- package/connection/index.js.map +1 -1
- package/connection/pool.d.ts +188 -0
- package/connection/pool.d.ts.map +1 -0
- package/connection/pool.js +351 -0
- package/connection/pool.js.map +1 -0
- package/connection/reload.d.ts +14 -93
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +216 -80
- package/connection/reload.js.map +1 -1
- package/connection/stats.d.ts +3 -26
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js.map +1 -1
- package/connection/transport.d.ts +0 -7
- package/connection/transport.d.ts.map +1 -1
- package/consume.d.ts +1 -43
- package/consume.d.ts.map +1 -1
- package/consume.js +1 -1
- package/consume.js.map +1 -1
- package/error.d.ts +180 -29
- package/error.d.ts.map +1 -1
- package/error.js +310 -16
- package/error.js.map +1 -1
- package/errors.d.ts +7 -0
- package/errors.d.ts.map +1 -0
- package/errors.js +8 -0
- package/errors.js.map +1 -0
- package/group.d.ts +9 -43
- package/group.d.ts.map +1 -1
- package/group.js +283 -69
- package/group.js.map +1 -1
- package/hop.d.ts +107 -0
- package/hop.d.ts.map +1 -0
- package/hop.js +103 -0
- package/hop.js.map +1 -0
- package/ietf/aliases.d.ts +1 -78
- package/ietf/aliases.d.ts.map +1 -1
- package/ietf/cluster.d.ts +6 -120
- package/ietf/cluster.d.ts.map +1 -1
- package/ietf/cluster.js +81 -41
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +6 -72
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +11 -47
- package/ietf/connection.js.map +1 -1
- package/ietf/error.d.ts +11 -0
- package/ietf/error.d.ts.map +1 -0
- package/ietf/error.js +168 -0
- package/ietf/error.js.map +1 -0
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +6 -1
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -5
- package/ietf/goaway.js.map +1 -1
- package/ietf/parameters.d.ts +2 -2
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +15 -17
- package/ietf/parameters.js.map +1 -1
- package/ietf/publish_namespace.d.ts +25 -0
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +63 -0
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.d.ts +1 -82
- package/ietf/publisher.d.ts.map +1 -1
- package/ietf/publisher.js +219 -125
- package/ietf/publisher.js.map +1 -1
- package/ietf/solicit.d.ts +1 -40
- package/ietf/solicit.d.ts.map +1 -1
- package/ietf/subscribe.d.ts +1 -5
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +8 -9
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscriber.d.ts +1 -65
- package/ietf/subscriber.d.ts.map +1 -1
- package/ietf/subscriber.js +154 -73
- package/ietf/subscriber.js.map +1 -1
- package/ietf/version.d.ts +12 -1
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +13 -0
- package/ietf/version.js.map +1 -1
- package/index.d.ts +11 -6
- package/index.d.ts.map +1 -1
- package/index.js +10 -5
- package/index.js.map +1 -1
- package/internal.d.ts +99 -1
- package/internal.d.ts.map +1 -1
- package/internal.js +65 -0
- package/internal.js.map +1 -1
- package/lite/announce.d.ts +15 -9
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +47 -20
- package/lite/announce.js.map +1 -1
- package/lite/connection.d.ts +9 -59
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +20 -32
- package/lite/connection.js.map +1 -1
- package/lite/fetch.d.ts +15 -1
- package/lite/fetch.d.ts.map +1 -1
- package/lite/fetch.js +39 -7
- package/lite/fetch.js.map +1 -1
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +7 -1
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +18 -4
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +31 -10
- package/lite/group.js.map +1 -1
- package/lite/priority.d.ts +1 -61
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +4 -5
- package/lite/priority.js.map +1 -1
- package/lite/publisher.d.ts +1 -69
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +559 -232
- package/lite/publisher.js.map +1 -1
- package/lite/setup.d.ts +7 -7
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +13 -13
- package/lite/setup.js.map +1 -1
- package/lite/subscribe.d.ts +61 -13
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +186 -44
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +8 -57
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +179 -117
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +4 -10
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +34 -29
- package/lite/track.js.map +1 -1
- package/lite/version.d.ts +31 -6
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +71 -11
- package/lite/version.js.map +1 -1
- package/origin.d.ts +229 -29
- package/origin.d.ts.map +1 -1
- package/origin.js +1087 -37
- package/origin.js.map +1 -1
- package/package.json +3 -2
- package/path.d.ts +25 -7
- package/path.d.ts.map +1 -1
- package/path.js +5 -3
- package/path.js.map +1 -1
- package/stream.d.ts.map +1 -1
- package/stream.js +25 -16
- package/stream.js.map +1 -1
- package/time.d.ts +15 -2
- package/time.d.ts.map +1 -1
- package/time.js +28 -9
- package/time.js.map +1 -1
- package/track.d.ts +171 -82
- package/track.d.ts.map +1 -1
- package/track.js +633 -184
- package/track.js.map +1 -1
- package/util/log.d.ts +5 -0
- package/util/log.d.ts.map +1 -0
- package/util/log.js +17 -0
- package/util/log.js.map +1 -0
- package/wire.d.ts +67 -0
- package/wire.d.ts.map +1 -0
- package/wire.js +32 -0
- package/wire.js.map +1 -0
- package/zod.d.ts +1 -1
- package/zod.d.ts.map +1 -1
- package/zod.js.map +1 -1
- package/mock.d.ts +0 -66
- package/mock.d.ts.map +0 -1
- package/mock.js +0 -243
- package/mock.js.map +0 -1
package/track.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track.js","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAgC,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE1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AC,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC/G,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAqB;QAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,CAAC;CACD","sourcesContent":["/**\n * Track role handles: a live stream of groups (and best-effort datagrams) within a broadcast.\n *\n * @module\n */\nimport { type GetPromise, type Getter, Once, Signal } from \"@moq/signals\";\nimport type { Datagram } from \"./datagram.ts\";\nimport { type Frame, type Consumer as GroupConsumer, Producer as GroupProducer, Lagged } from \"./group.ts\";\nimport { hooks, type TrackRequestOptions, type TrackSequence, type TrackSequences } from \"./internal.ts\";\nimport { Timescale, type Timestamp } from \"./time.ts\";\n\nexport type { Datagram } from \"./datagram.ts\";\n\n/** Default {@link Info.latencyMax} window (milliseconds) when the publisher does not set one. */\nexport const DEFAULT_LATENCY_MAX_MS = 5000;\n\n/**\n * How long (milliseconds) a datagram stays in the per-subscriber buffer before it is dropped.\n *\n * Datagrams are a best-effort send buffer, not a replay cache (unlike groups): only the last few\n * tens of milliseconds are kept, so a consumer that stalls loses stale datagrams instead of\n * replaying them. Mirrors the Rust `MAX_DATAGRAM_AGE`.\n */\nconst MAX_DATAGRAM_AGE_MS = 50;\n\n/** A datagram buffered with its arrival time, so the send buffer can evict by age. */\ntype BufferedDatagram = { datagram: Datagram; time: number };\n\n/**\n * Sanity cap on a datagram payload: the QUIC DATAGRAM frame ceiling. The real limit is\n * per-hop (the negotiated transport datagram size minus a small header) and oversize\n * datagrams are dropped there; a payload above this cap could never fit anywhere.\n */\nconst MAX_DATAGRAM_BYTES = 65535;\n\n/** A position within a track: a group's sequence and a frame's index inside it. */\nexport interface Location {\n\t/** The group's sequence number within the track. */\n\tgroup: number;\n\t/** The frame's index within that group. */\n\tframe: number;\n}\n\n/**\n * A track's immutable publisher properties, fixed for the lifetime of the track.\n *\n * A producer declares these once (via {@link Request.accept} or\n * {@link Producer.accept}); a consumer awaits them via {@link Subscriber.info}\n * (resolved from the wire TRACK_INFO on lite-05+). They map 1:1 onto TRACK_INFO.\n */\nexport interface Info {\n\t/**\n\t * Units per second for this track's frame timestamps (reported in TRACK_INFO on\n\t * Lite05+). Defaults to milliseconds; set it finer (e.g. {@link Timescale.MICRO})\n\t * for media that needs sub-millisecond timing.\n\t */\n\ttimescale: Timescale;\n\t/**\n\t * Publisher Max Latency: the maximum age (milliseconds) of a non-latest group before\n\t * the publisher evicts it. Reported in TRACK_INFO (Lite05+) so relays re-serve with the\n\t * same bound. The publisher-side half of the budget a subscriber sets for itself.\n\t */\n\tlatencyMax: number;\n\t/** Tie-break priority between subscriptions of equal subscriber priority. */\n\tpriority: number;\n\t/**\n\t * Whether groups are prioritized in sequence order. Groups may always arrive\n\t * out-of-order (or not at all) over the network. Defaults to `false` (newest-first).\n\t */\n\tordered: boolean;\n}\n\n/** Fill in any unset {@link Info} fields with their defaults. */\nexport function infoDefaults(info: Partial<Info> = {}): Info {\n\treturn {\n\t\ttimescale: info.timescale ?? Timescale.MILLI,\n\t\tlatencyMax: info.latencyMax ?? DEFAULT_LATENCY_MAX_MS,\n\t\tpriority: info.priority ?? 0,\n\t\tordered: info.ordered ?? false,\n\t};\n}\n\n/**\n * Per-subscription options, requested when a subscription opens and adjustable later via\n * {@link Subscriber.update}. Mirrors the Rust `Subscription`.\n */\nexport interface Subscription {\n\t/** Delivery priority relative to this session's other subscriptions. Defaults to `0`. */\n\tpriority?: number;\n\t/** Whether groups are prioritized in sequence order. Defaults to `false` (newest-first). */\n\tordered?: boolean;\n\t/** Maximum age (milliseconds) of a non-latest group before it is skipped. Defaults to `0`. */\n\tlatencyMax?: number;\n\t/** First group the publisher should deliver, or omit to start at the latest group. */\n\tstartGroup?: number;\n\t/** Last group the publisher should deliver (inclusive), or omit for no end. */\n\tendGroup?: number;\n}\n\n// Materialize the defaults at the model boundary so every layer observes a complete\n// subscription rather than interpreting an omitted field differently.\nfunction subscriptionDefaults(subscription: Subscription = {}): Subscription {\n\treturn {\n\t\tpriority: subscription.priority ?? 0,\n\t\tordered: subscription.ordered ?? false,\n\t\tlatencyMax: subscription.latencyMax ?? 0,\n\t\tstartGroup: subscription.startGroup,\n\t\tendGroup: subscription.endGroup,\n\t};\n}\n\n// Aggregate the preferences of every live subscriber, matching Rust's Subscription::poll_combined.\nfunction combineSubscriptions(states: Iterable<TrackState>): Subscription | undefined {\n\tlet combined: Subscription | undefined;\n\tfor (const state of states) {\n\t\tconst subscription = state.update.peek();\n\t\tif (!subscription) continue;\n\t\tif (!combined) {\n\t\t\tcombined = { ...subscription };\n\t\t\tcontinue;\n\t\t}\n\n\t\tcombined.priority = Math.max(combined.priority ?? 0, subscription.priority ?? 0);\n\t\tcombined.ordered = (combined.ordered ?? false) && (subscription.ordered ?? false);\n\t\tcombined.latencyMax = Math.max(combined.latencyMax ?? 0, subscription.latencyMax ?? 0);\n\n\t\tif (subscription.startGroup !== undefined) {\n\t\t\tcombined.startGroup =\n\t\t\t\tcombined.startGroup === undefined\n\t\t\t\t\t? subscription.startGroup\n\t\t\t\t\t: Math.min(combined.startGroup, subscription.startGroup);\n\t\t}\n\n\t\tif (combined.endGroup === undefined || subscription.endGroup === undefined) {\n\t\t\tcombined.endGroup = undefined;\n\t\t} else {\n\t\t\tcombined.endGroup = Math.max(combined.endGroup, subscription.endGroup);\n\t\t}\n\t}\n\treturn combined;\n}\n\n/**\n * A request for a track the peer wants, yielded by `Broadcast.Producer.requested`.\n *\n * Created internally by the broadcast when a subscription (or info lookup) needs a track\n * served; answer it with {@link accept} or {@link reject}.\n *\n * @public\n */\nexport class Request {\n\t/** The requested track name. */\n\treadonly name: string;\n\n\t#producer: Producer;\n\t#sequences: TrackSequences;\n\n\tprivate constructor(options: TrackRequestOptions) {\n\t\tthis.name = options.name;\n\t\tthis.#producer = options.producer;\n\t\tthis.#sequences = options.sequences;\n\t}\n\n\tstatic {\n\t\thooks.makeRequest = (options) => new Request(options);\n\t}\n\n\t/** The aggregate subscription requested for this track. */\n\tget subscription(): Readonly<Subscription> {\n\t\treturn this.#producer.subscription.peek() ?? subscriptionDefaults();\n\t}\n\n\t/** The subscriber's priority for this track. */\n\tget priority(): number {\n\t\treturn this.subscription.priority ?? 0;\n\t}\n\n\t/** Accept the request, committing the track's immutable {@link Info}. */\n\taccept(info: Partial<Info> = {}): Producer {\n\t\tbindProducer(this.name, this.#producer, this.#sequences);\n\t\treturn this.#producer.accept(info);\n\t}\n\n\t/** Reject the request, closing the track optionally with an error. */\n\treject(err?: Error): void {\n\t\tthis.#producer.close(err);\n\t}\n}\n\n/** Options for {@link Consumer.fetchGroup}. */\nexport interface FetchGroupOptions {\n\t/** Delivery priority for the fetch stream. Defaults to `0`. */\n\tpriority?: number;\n}\n\n/**\n * The per-track operations a lazy {@link Consumer} delegates to the broadcast it came from.\n *\n * Implemented by `broadcast.Producer` / `broadcast.Consumer` (and the wire-layer subclasses\n * that resolve them over the network), so a track handle holds a reference to its broadcast\n * and calls methods on it rather than capturing a bag of callbacks.\n */\nexport interface Broadcast {\n\t/** Open a live subscription to the named track. */\n\tsubscribe(name: string, options?: Subscription): Subscriber;\n\t/** Resolve the named track's immutable info. */\n\tresolveTrackInfo(name: string): Promise<Info>;\n\t/** Fetch a single group of the named track by sequence. */\n\tfetchGroup(name: string, sequence: number, options?: FetchGroupOptions): Promise<GroupConsumer>;\n}\n\n/**\n * A lazy handle to a track on a consumed broadcast.\n *\n * @public\n */\nexport class Consumer {\n\t/** The track name. */\n\treadonly name: string;\n\n\t#broadcast: Broadcast;\n\n\tconstructor(name: string, broadcast: Broadcast) {\n\t\tthis.name = name;\n\t\tthis.#broadcast = broadcast;\n\t}\n\n\t/** Open a live subscription to the track. */\n\tsubscribe(options?: Subscription): Subscriber {\n\t\treturn this.#broadcast.subscribe(this.name, options);\n\t}\n\n\t/** Fetch the track's immutable publisher properties without subscribing. */\n\tinfo(): Promise<Info> {\n\t\treturn this.#broadcast.resolveTrackInfo(this.name);\n\t}\n\n\t/** Fetch a single group by sequence without holding a live subscription. */\n\tfetchGroup(sequence: number, options?: FetchGroupOptions): Promise<GroupConsumer> {\n\t\treturn this.#broadcast.fetchGroup(this.name, sequence, options);\n\t}\n}\n\n// The shared state behind a Producer / Subscriber pair. Package-internal\n// wiring, unexported so it never appears in the published type declarations.\nclass TrackState {\n\t/** The producer fanning into this sink, so a subscriber can mint a sibling of itself. */\n\tproducer?: Producer;\n\tgroups = new Signal<GroupConsumer[]>([]);\n\t/** Best-effort datagram channel, parallel to {@link groups}; an age-evicted send buffer per subscriber. */\n\tdatagrams = new Signal<BufferedDatagram[]>([]);\n\tlatest?: number;\n\tclosed = new Once<Error | null>();\n\tupdate: Signal<Subscription | undefined>;\n\t/** Resolved once the producer commits the immutable properties. */\n\tinfo = new Signal<Info | undefined>(undefined);\n\n\tconstructor(subscription?: Subscription) {\n\t\tthis.update = new Signal(subscription === undefined ? undefined : subscriptionDefaults(subscription));\n\t}\n}\n\n// Settle a track state's closed Once. Idempotent: Once.set throws on a second settle, and a\n// Producer closing its sinks races the Subscriber closing itself (the sink is only removed from\n// #sinks a microtask later, via the closed subscription below).\nfunction closeTrackState(state: TrackState, abort?: Error): boolean {\n\tif (state.closed.peek() !== undefined) return false;\n\tstate.closed.set(abort ?? null);\n\treturn true;\n}\n\n// Resolve the track's immutable publisher properties, or reject if it closes first.\n// On a producer this resolves once info is committed (at accept time); on a consumer\n// once the wire layer commits the TRACK_INFO it received (lite-05+) or defaults (older\n// drafts), so awaiting it never yields a placeholder.\nasync function resolveInfo(state: TrackState): Promise<Info> {\n\tfor (;;) {\n\t\tconst info = state.info.peek();\n\t\tif (info) return info;\n\n\t\tconst closed = state.closed.peek();\n\t\tif (closed instanceof Error) throw closed;\n\t\tif (closed !== undefined) throw new Error(\"track closed before info was known\");\n\n\t\tawait Signal.race(state.info, state.closed);\n\t}\n}\n\n// A source group retained in the producer cache, with the mirror handed to each sink\n// so eviction can drop them together.\ntype CachedGroup = { group: GroupProducer; time: number; mirrors: Map<TrackState, GroupConsumer> };\n\nfunction bindProducer(name: string, producer: Producer, sequences: TrackSequences): void {\n\tlet shared = sequences.get(name);\n\tif (!shared) {\n\t\tshared = { next: 0 };\n\t\tsequences.set(name, shared);\n\t}\n\tbindProducerSequence(producer, shared);\n}\n\nlet bindProducerSequence: (producer: Producer, sequence: TrackSequence) => void;\n\n// Constructs a Subscriber from within this module without exposing a public\n// constructor that would leak the unexported TrackState. Assigned in the class's\n// static block.\nlet makeSubscriber: (name: string, state: TrackState) => Subscriber;\n\n/**\n * The write side of a track, mirroring the Rust `Producer`.\n *\n * A producer is a fan-out source: every {@link subscribe} (including each wire\n * subscription the publisher serves from it) gets an independent\n * {@link Subscriber} that receives a full copy of the groups, each with its own\n * read cursor. Groups are mirrored into every live subscriber and retained for the\n * track's `latencyMax` window so a late subscriber replays the recent groups.\n *\n * Obtained from {@link Request.accept} (the wire asks the application for a track to\n * serve) or constructed directly for an in-process track.\n */\nexport class Producer {\n\t/** The track name. */\n\treadonly name: string;\n\n\t// The producer's own state is the source of truth (info/closed); subscribers\n\t// read mirrored sinks, never this state directly.\n\t#state = new TrackState();\n\t#sequence: TrackSequence = { next: 0 };\n\n\t// Recently written source groups, retained for replay to late subscribers and\n\t// pruned once closed and older than the cache window. Each entry tracks the mirror\n\t// it handed to every sink so eviction can drop them too: otherwise a slow consumer\n\t// that never reads would pin old groups (and their frame bytes) forever.\n\t#cache: CachedGroup[] = [];\n\n\t// One independent downstream state per live subscriber.\n\t#sinks = new Set<TrackState>();\n\n\t// Whether any subscriber is currently attached. Exposed as {@link used}; the consumer wire\n\t// watches it to tear down an idle upstream, and a publisher can watch it for on-demand capture.\n\t#used = new Signal<boolean>(false);\n\n\tconstructor(name: string) {\n\t\tthis.name = name;\n\t}\n\n\tstatic {\n\t\tbindProducerSequence = (producer, sequence) => {\n\t\t\tproducer.#sequence = sequence;\n\t\t};\n\t}\n\n\t/**\n\t * Resolve this track's immutable publisher properties, committed at accept time.\n\t * Rejects if the track is closed before the properties are known.\n\t */\n\tinfo(): Promise<Info> {\n\t\treturn resolveInfo(this.#state);\n\t}\n\n\t/**\n\t * Settles once the track closes: `null` on a clean close, or the abort {@link Error}.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/**\n\t * The aggregate subscription across live subscribers, or `undefined` when there are none.\n\t * The wire layer watches this to emit SUBSCRIBE_UPDATE.\n\t */\n\tget subscription(): Getter<Subscription | undefined> {\n\t\treturn this.#state.update;\n\t}\n\n\t/** Commit the immutable publisher properties, resolving {@link info}. Returns `this`. */\n\taccept(info: Partial<Info> = {}): this {\n\t\tconst resolved = infoDefaults(info);\n\t\tthis.#state.info.set(resolved);\n\t\t// Propagate to any sink handed out before accept (the on-demand path).\n\t\tfor (const sink of this.#sinks) sink.info.set(resolved);\n\t\treturn this;\n\t}\n\n\t/** An independent {@link Subscriber} receiving a full copy of this track's groups. */\n\tsubscribe(options: Subscription = {}): Subscriber {\n\t\tconst sink = new TrackState(options);\n\t\tthis.#addSink(sink);\n\t\treturn makeSubscriber(this.name, sink);\n\t}\n\n\t/**\n\t * Whether the track currently has any subscribers.\n\t *\n\t * Watch it (`effect.get` / `.peek()`) to drive on-demand work: a publisher can start and stop\n\t * capture with demand, and the consumer wire watches it to tear an idle upstream subscription\n\t * down instead of downloading to nobody. Pairs with {@link unused}. Mirrors the Rust `Demand`.\n\t */\n\tget used(): Getter<boolean> {\n\t\treturn this.#used;\n\t}\n\n\t/** Resolves once the track has no subscribers (or has closed). Await it to react to demand ending. */\n\tasync unused(): Promise<void> {\n\t\twhile (this.#used.peek() && this.#state.closed.peek() === undefined) {\n\t\t\tawait Signal.race(this.#used, this.#state.closed);\n\t\t}\n\t}\n\n\t// Register a downstream sink: seed its info, replay the retained window, and (while\n\t// the track is open) mirror future groups into it. A late subscriber to a closed\n\t// track still drains the buffered groups before seeing the end.\n\t#addSink(sink: TrackState): void {\n\t\tsink.producer = this;\n\t\tconst info = this.#state.info.peek();\n\t\tif (info) sink.info.set(info);\n\n\t\tconst closed = this.#state.closed.peek();\n\t\tif (closed === undefined) {\n\t\t\tthis.#sinks.add(sink);\n\t\t\tthis.#used.set(true);\n\n\t\t\t// Forward subscription updates from the sink's Subscriber to the producer's own\n\t\t\t// state, which the wire layer (or the serving application) watches.\n\t\t\tconst forward = sink.update.subscribe(() => this.#updateSubscription());\n\t\t\tthis.#updateSubscription();\n\n\t\t\t// Drop the sink once its consumer goes away, closing its mirrors so source\n\t\t\t// groups stop teeing into them, so a long-lived producer doesn't leak. This\n\t\t\t// covers mirrors already handed out via recvGroup (no longer in sink.groups)\n\t\t\t// by closing them through the cache's per-sink tracking.\n\t\t\tconst dispose = sink.closed.subscribe((c) => {\n\t\t\t\tif (c === undefined) return;\n\t\t\t\tconst abort = c instanceof Error ? c : undefined;\n\t\t\t\tforward();\n\t\t\t\tthis.#sinks.delete(sink);\n\t\t\t\tthis.#updateSubscription();\n\t\t\t\tfor (const entry of this.#cache) {\n\t\t\t\t\tconst mirror = entry.mirrors.get(sink);\n\t\t\t\t\tif (mirror) {\n\t\t\t\t\t\tmirror.close(abort);\n\t\t\t\t\t\tentry.mirrors.delete(sink);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const group of sink.groups.peek()) group.close(abort);\n\t\t\t\tdispose();\n\n\t\t\t\t// Update demand: once the last subscriber leaves, the consumer wire (watching\n\t\t\t\t// {@link unused}) tears the upstream down instead of downloading to nobody.\n\t\t\t\tthis.#used.set(this.#sinks.size > 0);\n\t\t\t});\n\t\t}\n\n\t\tthis.#prune();\n\t\tfor (const entry of this.#cache) this.#mirror(entry, sink);\n\n\t\tif (closed !== undefined) closeTrackState(sink, closed instanceof Error ? closed : undefined);\n\t}\n\n\t// Recompute from every live sink because an update or close can narrow as well as widen\n\t// the aggregate. The wire layer observes this signal and emits SUBSCRIBE_UPDATE.\n\t#updateSubscription(): void {\n\t\tthis.#state.update.set(combineSubscriptions(this.#sinks));\n\t}\n\n\t// Mirror a cached source group into a sink. The mirror fills synchronously as the\n\t// source is written and keeps its own read cursor; frame bytes are shared by\n\t// reference. Tracked on the entry so eviction can drop it from the sink.\n\t#mirror(entry: CachedGroup, sink: TrackState): void {\n\t\tconst dst = entry.group.mirror();\n\t\tentry.mirrors.set(sink, dst);\n\t\tsink.latest = Math.max(sink.latest ?? 0, dst.sequence);\n\t\tsink.groups.mutate((groups) => {\n\t\t\tgroups.push(dst);\n\t\t\tgroups.sort((a, b) => a.sequence - b.sequence);\n\t\t});\n\t}\n\n\t// Drop a cached group's mirror from every sink so no consumer can pin it.\n\t#evict(entry: CachedGroup): void {\n\t\tfor (const [sink, mirror] of entry.mirrors) {\n\t\t\tsink.groups.mutate((groups) => {\n\t\t\t\tconst i = groups.indexOf(mirror);\n\t\t\t\tif (i >= 0) groups.splice(i, 1);\n\t\t\t});\n\t\t\tmirror.close();\n\t\t}\n\t\tentry.mirrors.clear();\n\t}\n\n\t// Evict cached groups that are closed and older than the cache window.\n\t#prune(): void {\n\t\tconst latencyMaxMs = this.#state.info.peek()?.latencyMax ?? DEFAULT_LATENCY_MAX_MS;\n\t\tconst cutoff = Date.now() - latencyMaxMs;\n\n\t\tconst retained: CachedGroup[] = [];\n\t\tfor (const entry of this.#cache) {\n\t\t\tif (entry.time > cutoff || entry.group.closed.peek() === undefined) {\n\t\t\t\tretained.push(entry);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.#evict(entry);\n\t\t}\n\t\tthis.#cache = retained;\n\t}\n\n\t// Retain a source group and fan it out to every live sink.\n\t#publish(group: GroupProducer): void {\n\t\tconst entry: CachedGroup = { group, time: Date.now(), mirrors: new Map<TrackState, GroupConsumer>() };\n\t\tthis.#cache.push(entry);\n\t\tthis.#prune();\n\t\tfor (const sink of this.#sinks) this.#mirror(entry, sink);\n\t}\n\n\t/** Append a new group with the next sequence number. */\n\tappendGroup(): GroupProducer {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"track is closed\");\n\n\t\tconst sequence = this.#sequence;\n\t\tconst group = new GroupProducer(sequence.next);\n\t\tsequence.next = group.sequence + 1;\n\t\tthis.#publish(group);\n\n\t\treturn group;\n\t}\n\n\t/**\n\t * Insert an existing group into the track.\n\t *\n\t * Throws on a sequence that is still cached: a live duplicate would fan out to every\n\t * subscriber twice. An aborted incarnation is evicted so a fresh group can serve the\n\t * sequence again. Best effort (mirrors Rust): nothing remembers a sequence whose cache\n\t * entry is already gone, so a long-evicted sequence is accepted as new.\n\t */\n\twriteGroup(group: GroupProducer) {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"track is closed\");\n\n\t\tconst existing = this.#cache.findIndex((entry) => entry.group.sequence === group.sequence);\n\t\tif (existing >= 0) {\n\t\t\tconst entry = this.#cache[existing];\n\t\t\tif (!(entry.group.closed.peek() instanceof Error)) {\n\t\t\t\tthrow new Error(`duplicate group: sequence=${group.sequence}`);\n\t\t\t}\n\t\t\tthis.#evict(entry);\n\t\t\tthis.#cache.splice(existing, 1);\n\t\t}\n\n\t\t// Only advance the shared counter upward (for appendGroup auto-increment).\n\t\tconst sequence = this.#sequence;\n\t\tif (group.sequence >= sequence.next) {\n\t\t\tsequence.next = group.sequence + 1;\n\t\t}\n\n\t\tthis.#publish(group);\n\t}\n\n\t// Fan a datagram out to every live subscriber, dropping the oldest once the ring is full.\n\t// Late subscribers do NOT replay old datagrams (best-effort, unlike the group cache).\n\t#publishDatagram(datagram: Datagram): void {\n\t\tconst now = performance.now();\n\t\tfor (const sink of this.#sinks) {\n\t\t\tsink.datagrams.mutate((list) => {\n\t\t\t\tlist.push({ datagram, time: now });\n\t\t\t\t// Drop anything older than the send-buffer window.\n\t\t\t\twhile (list.length > 0 && now - list[0].time > MAX_DATAGRAM_AGE_MS) list.shift();\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Append a datagram with the next sequence number, returning the assigned sequence.\n\t *\n\t * A datagram is delivered best-effort over a single QUIC datagram, parallel to the track's\n\t * groups but drawing from the same sequence namespace (interleaving with {@link appendGroup}\n\t * never reuses a number). The payload must fit the negotiated transport datagram size minus\n\t * a small header; an oversize payload is dropped at each hop (there is no group fallback), so\n\t * keep datagram payloads small (e.g. a single audio frame). Datagrams are never delivered\n\t * over IETF moq-transport or stream-only transports (the WebSocket fallback). A payload over\n\t * 65535 bytes (the QUIC datagram frame ceiling) throws. An origin publisher uses this; a\n\t * relay preserving upstream numbering uses {@link writeDatagram}.\n\t */\n\tappendDatagram(timestamp: Timestamp, payload: Uint8Array): number {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"track is closed\");\n\t\tif (payload.byteLength > MAX_DATAGRAM_BYTES) throw new Error(\"datagram payload too large\");\n\n\t\tconst counter = this.#sequence;\n\t\tconst sequence = counter.next;\n\t\tcounter.next = sequence + 1;\n\t\tthis.#publishDatagram({ sequence, timestamp, payload });\n\t\treturn sequence;\n\t}\n\n\t/**\n\t * Write a datagram with an explicit sequence number.\n\t *\n\t * Preserves the supplied sequence (advancing the shared counter if needed) so a relay can\n\t * forward a datagram without renumbering it. The size limits of {@link appendDatagram}\n\t * apply. Most origin publishers want {@link appendDatagram} instead.\n\t */\n\twriteDatagram(datagram: Datagram) {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"track is closed\");\n\t\tif (datagram.payload.byteLength > MAX_DATAGRAM_BYTES) throw new Error(\"datagram payload too large\");\n\n\t\tconst sequence = this.#sequence;\n\t\tif (datagram.sequence >= sequence.next) {\n\t\t\tsequence.next = datagram.sequence + 1;\n\t\t}\n\t\tthis.#publishDatagram(datagram);\n\t}\n\n\t/** Close the track and every subscriber, mirroring the abort to their groups. Idempotent. */\n\tclose(abort?: Error) {\n\t\tcloseTrackState(this.#state, abort);\n\t\tfor (const { group } of this.#cache) group.close(abort);\n\t\tfor (const sink of this.#sinks) {\n\t\t\tfor (const group of sink.groups.peek()) group.close(abort);\n\t\t\tcloseTrackState(sink, abort);\n\t\t}\n\t\tthis.#sinks.clear();\n\t}\n\n\t/** Append a frame as its own single-frame group. */\n\twriteFrame(frame: Frame) {\n\t\tconst group = this.appendGroup();\n\t\tgroup.writeFrame(frame);\n\t\tgroup.close();\n\t}\n\n\t/** Appends a string to the track as its own single-frame group. */\n\twriteString(str: string) {\n\t\tconst group = this.appendGroup();\n\t\tgroup.writeString(str);\n\t\tgroup.close();\n\t}\n\n\t/** Appends a JSON value to the track as its own single-frame group. */\n\twriteJson(json: unknown) {\n\t\tconst group = this.appendGroup();\n\t\tgroup.writeJson(json);\n\t\tgroup.close();\n\t}\n\n\t/** Appends a boolean to the track as its own single-frame group. */\n\twriteBool(bool: boolean) {\n\t\tconst group = this.appendGroup();\n\t\tgroup.writeBool(bool);\n\t\tgroup.close();\n\t}\n}\n\n/**\n * The read side of a live track subscription, mirroring the Rust `Subscriber`.\n *\n * Obtained from `Broadcast.Consumer.subscribe` / `Track.Consumer.subscribe`, or from\n * {@link Producer.subscribe} for an in-process track. Reads the groups a\n * {@link Producer} on the same underlying state writes.\n */\nexport class Subscriber {\n\t/** The track name. */\n\treadonly name: string;\n\n\t#state: TrackState;\n\t#nextSequence = 0;\n\t#cursor = new Signal<{ start: number; end?: number }>({ start: 0 });\n\n\tprivate constructor(name: string, state: TrackState) {\n\t\tthis.name = name;\n\t\tthis.#state = state;\n\t}\n\n\tstatic {\n\t\tmakeSubscriber = (name, state) => new Subscriber(name, state);\n\t}\n\n\t/**\n\t * Resolve this track's immutable publisher properties.\n\t *\n\t * Resolves once the wire layer commits the TRACK_INFO it received (lite-05+) or\n\t * defaults (older drafts), so awaiting it never yields a placeholder. Rejects if\n\t * the track is closed before the properties are known (e.g. a rejected subscription).\n\t */\n\tinfo(): Promise<Info> {\n\t\treturn resolveInfo(this.#state);\n\t}\n\n\t/** Settles once the track closes; see {@link Producer.closed}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/** This subscriber's current options, including defaults and the last {@link update}. */\n\tget subscription(): Getter<Subscription | undefined> {\n\t\treturn this.#state.update;\n\t}\n\n\t/** Return the latest group sequence observed on this track, if any. */\n\tlatest(): number | undefined {\n\t\treturn this.#state.latest;\n\t}\n\n\t/**\n\t * The newest frame this track has produced, or `undefined` while it has none.\n\t *\n\t * Read from the groups buffered for this subscriber, so nothing is consumed. A newest\n\t * group that has no frames yet falls back to the newest older group that does. It\n\t * reads as `undefined` once the newest group has been evicted or received: what is\n\t * left can no longer say where the edge is.\n\t */\n\tlargest(): Location | undefined {\n\t\tconst latest = this.#state.latest;\n\t\tif (latest === undefined) return undefined;\n\n\t\tconst groups = this.#state.groups.peek();\n\t\tconst newest = groups[groups.length - 1];\n\t\tif (!newest || newest.sequence !== latest) return undefined;\n\n\t\tfor (let i = groups.length - 1; i >= 0; i--) {\n\t\t\tconst count = groups[i].frameCount;\n\t\t\tif (count > 0) return { group: groups[i].sequence, frame: count - 1 };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * An independent subscriber to the same track, with its own cursor and its own replay of\n\t * the retained window.\n\t *\n\t * Reads here do not consume anything this one would deliver, which is what lets a\n\t * publisher read the cache alongside the cursor it is serving from. Resolving the track\n\t * again through the broadcast would not do: a dynamic serve is one request per peer\n\t * subscription, so that mints a second producer the application has to answer separately.\n\t *\n\t * @internal Wire layers only.\n\t */\n\tfork(options?: Subscription): Subscriber {\n\t\tconst producer = this.#state.producer;\n\t\tif (!producer) throw new Error(\"track has no producer to fork from\");\n\t\treturn producer.subscribe(options);\n\t}\n\n\t/** Start this subscriber's local read cursor at `sequence`, without changing its wire request. */\n\tstartAt(sequence: number): void {\n\t\tthis.#cursor.update((cursor) => ({ ...cursor, start: sequence }));\n\t}\n\n\t/**\n\t * Cap {@link nextGroup} and {@link recvGroup} at `sequence` inclusively, or omit it to\n\t * remove the cap. Groups above the cap remain buffered and become readable if the cap\n\t * is raised. This local cursor does not change the subscription's wire request.\n\t */\n\tendAt(sequence?: number): void {\n\t\tthis.#cursor.update((cursor) => ({ ...cursor, end: sequence }));\n\t}\n\n\t/** Close the track (optionally with an error), closing any pending groups. Idempotent. */\n\tclose(abort?: Error) {\n\t\t// Settle if we're first (the producer may already have); either way drop anything\n\t\t// still buffered. Groups parked at the endAt cap deliberately outlive a clean\n\t\t// producer close, so the subscriber leaving is what must release them: closing\n\t\t// and clearing wakes a pending read to observe the end instead of hanging.\n\t\tcloseTrackState(this.#state, abort);\n\t\tthis.#state.groups.mutate((groups) => {\n\t\t\tfor (const group of groups) group.close(abort);\n\t\t\tgroups.length = 0;\n\t\t});\n\t}\n\n\t/**\n\t * Receive every group on this track exactly once, as it becomes available.\n\t *\n\t * Groups may arrive out of order or with gaps due to network conditions; unlike\n\t * {@link nextGroup}, one that arrives after a newer group was already returned is\n\t * still delivered. When several groups are buffered, the lowest sequence is\n\t * returned first.\n\t *\n\t * Honors the floor set by {@link startAt} and the cap set by {@link endAt}: a group\n\t * beyond the cap stays buffered (not dropped) and is offered once the cap rises, even\n\t * after a clean close, without blocking in-range groups that arrive behind it.\n\t */\n\tasync recvGroup(): Promise<GroupConsumer | undefined> {\n\t\tfor (;;) {\n\t\t\tconst group = this.tryRecvGroup();\n\t\t\tif (group) return group;\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\t// A group beyond the cap outlives a clean close: it becomes deliverable if\n\t\t\t// the cap rises, so the track isn't over while any are held.\n\t\t\tif (closed !== undefined && !this.#state.groups.peek()[0]) return undefined;\n\n\t\t\tawait Signal.race(this.#state.groups, this.#cursor, this.#state.closed);\n\t\t}\n\t}\n\n\t/**\n\t * Take the next buffered group without blocking, honoring the same cursor bounds as\n\t * {@link recvGroup}.\n\t *\n\t * Returns `undefined` when nothing is deliverable right now, which is not by itself the\n\t * end of the track: a group may still arrive, or one may be parked beyond the\n\t * {@link endAt} cap. Use it to drain what the retained window already holds, where\n\t * waiting for a sequence nothing will republish would park forever.\n\t */\n\ttryRecvGroup(): GroupConsumer | undefined {\n\t\tconst groups = this.#state.groups.peek();\n\t\tconst { start, end } = this.#cursor.peek();\n\t\twhile (groups.length > 0 && groups[0].sequence < start) groups.shift()?.close();\n\n\t\t// The buffer is sequence-sorted, so an in-range group that arrives behind a\n\t\t// beyond-cap one sorts in front of it and is never blocked by it.\n\t\tconst group = groups[0];\n\t\tif (group && (end === undefined || group.sequence <= end)) {\n\t\t\tgroups.shift();\n\t\t\treturn group;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Receive the next datagram in arrival order.\n\t *\n\t * Datagrams are a separate best-effort channel from groups (see\n\t * {@link Producer.appendDatagram}); they share only the sequence namespace. A consumer\n\t * that falls too far behind silently loses the oldest datagrams. Read this alongside\n\t * {@link recvGroup} (e.g. in a separate loop) to receive both channels concurrently. Returning\n\t * a datagram advances {@link nextGroup} past that sequence.\n\t */\n\tasync recvDatagram(): Promise<Datagram | undefined> {\n\t\tfor (;;) {\n\t\t\tconst datagrams = this.#state.datagrams.peek();\n\n\t\t\t// Evict datagrams older than the send-buffer window (also enforced on write), so a\n\t\t\t// reader that stalled skips stale datagrams instead of replaying them.\n\t\t\tconst cutoff = performance.now() - MAX_DATAGRAM_AGE_MS;\n\t\t\twhile (datagrams.length > 0 && datagrams[0].time < cutoff) datagrams.shift();\n\n\t\t\tif (datagrams.length > 0) {\n\t\t\t\tconst datagram = datagrams.shift()?.datagram;\n\t\t\t\tif (datagram) {\n\t\t\t\t\tthis.#nextSequence = Math.max(this.#nextSequence, datagram.sequence + 1);\n\t\t\t\t}\n\t\t\t\treturn datagram;\n\t\t\t}\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed !== undefined) return undefined;\n\n\t\t\tawait Signal.race(this.#state.datagrams, this.#state.closed);\n\t\t}\n\t}\n\n\t/**\n\t * Return the next group with a strictly-greater sequence number than the last returned.\n\t *\n\t * Late arrivals (sequence at or below the last returned) are silently skipped.\n\t * Use {@link recvGroup} to see every group in arrival order instead.\n\t */\n\tasync nextGroup(): Promise<GroupConsumer | undefined> {\n\t\tfor (;;) {\n\t\t\tconst groups = this.#state.groups.peek();\n\t\t\tconst cursor = this.#cursor.peek();\n\t\t\tconst start = Math.max(cursor.start, this.#nextSequence);\n\t\t\twhile (groups.length > 0 && groups[0].sequence < start) groups.shift()?.close();\n\n\t\t\tconst group = groups[0];\n\t\t\tif (group && (cursor.end === undefined || group.sequence <= cursor.end)) {\n\t\t\t\tgroups.shift();\n\t\t\t\tthis.#nextSequence = group.sequence + 1;\n\t\t\t\treturn group;\n\t\t\t}\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed !== undefined && !group) return undefined;\n\n\t\t\tawait Signal.race(this.#state.groups, this.#cursor, this.#state.closed);\n\t\t}\n\t}\n\n\t/**\n\t * Reads the next frame across all groups, discarding older groups.\n\t * Treat the returned frame bytes as read-only; they are shared with other consumers.\n\t */\n\tasync readFrame(): Promise<Frame | undefined> {\n\t\tconst next = await this.readFrameSequence();\n\t\treturn next ? { payload: next.payload, timestamp: next.timestamp } : undefined;\n\t}\n\n\t/**\n\t * Reads the next frame along with its group and frame sequence numbers.\n\t * Treat the returned frame bytes as read-only; they are shared with other consumers.\n\t */\n\tasync readFrameSequence(): Promise<({ group: number; frame: number } & Frame) | undefined> {\n\t\tfor (;;) {\n\t\t\tconst groups = this.#state.groups.peek();\n\t\t\tconst { start } = this.#cursor.peek();\n\t\t\twhile (groups.length > 0 && groups[0].sequence < start) groups.shift()?.close();\n\n\t\t\t// Drain older groups first, dropping each once empty.\n\t\t\twhile (groups.length > 1) {\n\t\t\t\tif (groups[0].skipped) {\n\t\t\t\t\t// The reader fell behind this group's eviction window. Drop it and\n\t\t\t\t\t// signal the gap; the next read resyncs from the following group.\n\t\t\t\t\tgroups.shift()?.close();\n\t\t\t\t\tthrow new Lagged();\n\t\t\t\t}\n\t\t\t\tconst next = groups[0].tryReadFrameSequence();\n\t\t\t\tif (next) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tgroup: groups[0].sequence,\n\t\t\t\t\t\tframe: next.sequence,\n\t\t\t\t\t\tpayload: next.payload,\n\t\t\t\t\t\ttimestamp: next.timestamp,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tgroups.shift()?.close();\n\t\t\t}\n\n\t\t\tif (groups.length === 0) {\n\t\t\t\tconst closed = this.#state.closed.peek();\n\t\t\t\tif (closed instanceof Error) throw closed;\n\t\t\t\tif (closed !== undefined) return undefined;\n\t\t\t\tawait Signal.race(this.#state.groups, this.#cursor, this.#state.closed);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst group = groups[0];\n\t\t\tif (group.skipped) {\n\t\t\t\t// Fell behind this group's eviction window. Drop it and signal the gap;\n\t\t\t\t// the next read resyncs from the following group.\n\t\t\t\tgroups.shift()?.close();\n\t\t\t\tthrow new Lagged();\n\t\t\t}\n\t\t\tconst next = group.tryReadFrameSequence();\n\t\t\tif (next)\n\t\t\t\treturn {\n\t\t\t\t\tgroup: group.sequence,\n\t\t\t\t\tframe: next.sequence,\n\t\t\t\t\tpayload: next.payload,\n\t\t\t\t\ttimestamp: next.timestamp,\n\t\t\t\t};\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed !== undefined) return undefined;\n\n\t\t\t// A finished (drained + closed) group has nothing left: drop it and loop, rather than\n\t\t\t// busy-waiting on its already-resolved readable() (which would livelock and starve the\n\t\t\t// macrotask that delivers the next group).\n\t\t\tif (group.done) {\n\t\t\t\tgroups.shift()?.close();\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Lone open group with nothing buffered yet: wait for a frame on it, a new group, or\n\t\t\t// the track closing.\n\t\t\tawait Promise.race([Signal.race(this.#state.groups, this.#cursor, this.#state.closed), group.readable()]);\n\t\t}\n\t}\n\n\t/** Reads the next frame and decodes it as a UTF-8 string. */\n\tasync readString(): Promise<string | undefined> {\n\t\tconst next = await this.readFrame();\n\t\tif (!next) return undefined;\n\t\treturn new TextDecoder().decode(next.payload);\n\t}\n\n\t/** Reads the next frame and parses it as JSON. */\n\tasync readJson(): Promise<unknown | undefined> {\n\t\tconst next = await this.readString();\n\t\tif (!next) return undefined;\n\t\treturn JSON.parse(next);\n\t}\n\n\t/** Reads the next frame and decodes it as a one-byte boolean, throwing on a malformed frame. */\n\tasync readBool(): Promise<boolean | undefined> {\n\t\tconst next = await this.readFrame();\n\t\tif (!next) return undefined;\n\t\tconst payload = next.payload;\n\t\tif (payload.byteLength !== 1 || !(payload[0] === 0 || payload[0] === 1)) throw new Error(\"invalid bool frame\");\n\t\treturn payload[0] === 1;\n\t}\n\n\t/**\n\t * Update this subscription's options (e.g. priority), triggering a SUBSCRIBE_UPDATE to the\n\t * publisher. Mirrors the Rust `Subscriber::update`.\n\t */\n\tupdate(options: Subscription) {\n\t\tthis.#state.update.set(subscriptionDefaults(options));\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"track.js","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAA8C,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAExF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAA8C,QAAQ,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AACnG,OAAO,EACN,WAAW,EACX,KAAK,GAKL,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAmC,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAInF,qFAAqF;AACrF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C,OAAqB;QAC3B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,0FAA0F;IAC1F,KAAK,CAAC,KAAa;QAClB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;;OAOG;IACH,SAAS;QACR,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACH,SAAS;QACR,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED,2DAA2D;IAC3D,UAAU;QACT,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC;IAED,gDAAgD;IAChD,QAAQ;QACP,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED,8FAA8F;IAC9F,QAAQ;QACP,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;OAQG;IACH,YAAY;QACX,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;CACD","sourcesContent":["/**\n * Track role handles: a live stream of groups (and best-effort datagrams) within a broadcast.\n *\n * @module\n */\nimport { type Dispose, type GetPromise, type Getter, Once, Signal } from \"@moq/signals\";\nimport type { Datagram } from \"./datagram.ts\";\nimport { GroupTooLarge, TooFarBehind } from \"./error.ts\";\nimport { type Frame, type Consumer as GroupConsumer, Producer as GroupProducer } from \"./group.ts\";\nimport {\n\tgroupBounds,\n\thooks,\n\ttype Recv,\n\ttype TrackRequestOptions,\n\ttype TrackSequence,\n\ttype TrackSequences,\n} from \"./internal.ts\";\nimport { Milli, Timescale, type Timestamp } from \"./time.ts\";\nimport { type Broadcast as BroadcastWire, registerTrackConsumer } from \"./wire.ts\";\n\nexport type { Datagram } from \"./datagram.ts\";\n\n// The largest delay setTimeout keeps: anything more truncates to a signed 32-bit int\n// and fires right away.\nconst MAX_TIMEOUT_MS = 2 ** 31 - 1;\n\n/** Default {@link Info.maxAge} window (milliseconds) when the publisher does not set one. */\nexport const DEFAULT_MAX_AGE_MS = Milli(5000);\n\n/** Maximum buffered datagrams per subscriber; mirrors Rust's bounded send buffer. */\nconst MAX_DATAGRAMS = 64;\n\n/**\n * Sanity cap on a datagram payload: the QUIC DATAGRAM frame ceiling. The real limit is\n * per-hop (the negotiated transport datagram size minus a small header) and oversize\n * datagrams are dropped there; a payload above this cap could never fit anywhere.\n */\nconst MAX_DATAGRAM_BYTES = 65535;\n\n/** A position within a track: a group's sequence and a frame's index inside it. */\nexport interface Location {\n\t/** The group's sequence number within the track. */\n\tgroup: number;\n\t/** The frame's index within that group. */\n\tframe: number;\n}\n\n/**\n * A track's immutable publisher properties, fixed for the lifetime of the track.\n *\n * A producer declares these once (via {@link Request.accept} or\n * {@link Producer.accept}); a consumer awaits them via {@link Subscriber.info}\n * (resolved from the wire TRACK_INFO on lite-05+). They map 1:1 onto TRACK_INFO.\n */\nexport interface Info {\n\t/**\n\t * Units per second for this track's frame timestamps (reported in TRACK_INFO on\n\t * Lite05+). Defaults to milliseconds; set it finer (e.g. {@link Timescale.MICRO})\n\t * for media that needs sub-millisecond timing.\n\t */\n\ttimescale: Timescale;\n\t/**\n\t * Publisher Max Age: the maximum age (milliseconds) of a non-latest group before\n\t * the publisher evicts it. Reported in TRACK_INFO (Lite05+) so relays re-serve with the\n\t * same bound. The publisher-side half of the budget a subscriber sets for itself.\n\t * Rounded up to a whole millisecond by {@link infoDefaults}, which refuses a negative\n\t * or non-finite value and a result past `Number.MAX_SAFE_INTEGER`.\n\t */\n\tmaxAge: Milli;\n\t/** Tie-break priority between subscriptions of equal subscriber priority (`0..=255`). */\n\tpriority: number;\n}\n\n// Normalize a latency budget for the wire, which carries it as an unsigned varint.\n//\n// Callers derive it from measurements (a jitter estimate scaled off RTT), so a fractional\n// millisecond is expected; ceil rather than round, because a budget shortened by rounding\n// skips a group the subscriber still wants. Anything that is not a duration is refused\n// here, where the field is named, rather than deep in the encoder.\nfunction maxAgeMillis(value: Milli): Milli {\n\tif (!Number.isFinite(value) || value < 0) {\n\t\tthrow new RangeError(`maxAge must be a non-negative number of milliseconds: ${value}`);\n\t}\n\tconst millis = Math.ceil(value);\n\tif (!Number.isSafeInteger(millis)) {\n\t\tthrow new RangeError(`maxAge exceeds the safe integer millisecond range: ${value}`);\n\t}\n\treturn Milli(millis);\n}\n\nfunction priorityByte(value: number): number {\n\tif (!Number.isInteger(value) || value < 0 || value > 255) {\n\t\tthrow new RangeError(`priority must be an integer in 0..=255: ${value}`);\n\t}\n\treturn value;\n}\n\n/** Fill in any unset {@link Info} fields with their defaults. */\nexport function infoDefaults(info: Partial<Info> = {}): Info {\n\treturn {\n\t\ttimescale: Timescale(info.timescale ?? Timescale.MILLI),\n\t\tmaxAge: maxAgeMillis(info.maxAge ?? DEFAULT_MAX_AGE_MS),\n\t\tpriority: priorityByte(info.priority ?? 0),\n\t};\n}\n\n/** An explicitly included or excluded group sequence. */\nexport type Bound = { included: number; excluded?: never } | { excluded: number; included?: never };\n\n/** Group limits; an omitted endpoint is unbounded. */\nexport interface Groups {\n\t/** The first group boundary. */\n\tstart?: Bound;\n\t/** The last group boundary. */\n\tend?: Bound;\n}\n\n/**\n * Per-subscription options, requested when a subscription opens and adjustable later via\n * {@link Subscriber.update}. Mirrors the Rust `Subscription`.\n */\nexport interface Subscription {\n\t/** Delivery priority relative to this session's other subscriptions (`0..=255`). Defaults to `0`. */\n\tpriority?: number;\n\t/**\n\t * Maximum age (milliseconds) of a non-latest group before it is skipped. Defaults to `0`.\n\t * Rounded up to a whole millisecond, so a value derived from a measurement is never\n\t * shortened. A negative or non-finite value, or one past `Number.MAX_SAFE_INTEGER`\n\t * after rounding, is refused.\n\t */\n\tmaxAge?: Milli;\n\t/**\n\t * The lowest group the publisher may deliver (a floor), or omit for none.\n\t *\n\t * A floor, not a request: only {@link maxAge} asks for data, and the floor bounds how\n\t * far back it may reach. Omitting it and a floor of 0 mean the same thing, and a floor\n\t * above the live edge simply waits there (a resumed subscription naming where it left\n\t * off).\n\t */\n\tgroups?: Groups;\n}\n\n// Materialize the defaults at the model boundary so every layer observes a complete\n// subscription rather than interpreting an omitted field differently.\nfunction subscriptionDefaults(subscription: Subscription = {}): Subscription {\n\tconst bounds = groupBounds(subscription.groups ?? {});\n\treturn {\n\t\tpriority: priorityByte(subscription.priority ?? 0),\n\t\tmaxAge: maxAgeMillis(subscription.maxAge ?? Milli.zero),\n\t\tgroups: {\n\t\t\tstart: subscription.groups?.start === undefined ? undefined : { included: bounds.start },\n\t\t\tend: bounds.end === undefined ? undefined : { excluded: bounds.end },\n\t\t},\n\t};\n}\n\n// Aggregate the preferences of every live subscriber, matching Rust's Subscription::poll_combined.\nfunction combineSubscriptions(states: Iterable<TrackState>): Subscription | undefined {\n\tlet combined: Subscription | undefined;\n\tfor (const state of states) {\n\t\tconst subscription = state.update.peek();\n\t\tif (!subscription) continue;\n\t\tif (!combined) {\n\t\t\tcombined = { ...subscription };\n\t\t\tcontinue;\n\t\t}\n\n\t\tcombined.priority = Math.max(combined.priority ?? 0, subscription.priority ?? 0);\n\t\tcombined.maxAge = Milli(Math.max(combined.maxAge ?? Milli.zero, subscription.maxAge ?? Milli.zero));\n\n\t\t// A floor only restricts, so a subscriber without one clears the aggregate:\n\t\t// its budget may reach below any floor the others set.\n\t\tconst a = groupBounds(combined.groups ?? {});\n\t\tconst b = groupBounds(subscription.groups ?? {});\n\t\tcombined.groups = {\n\t\t\tstart:\n\t\t\t\tcombined.groups?.start === undefined || subscription.groups?.start === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: { included: Math.min(a.start, b.start) },\n\t\t\tend: a.end === undefined || b.end === undefined ? undefined : { excluded: Math.max(a.end, b.end) },\n\t\t};\n\t}\n\treturn combined;\n}\n\n/**\n * A request for a track the peer wants, delivered to the publishing wire layer.\n *\n * Created internally by the broadcast when a subscription (or info lookup) needs a track\n * served; answer it with {@link accept} or {@link reject}.\n *\n * @public\n */\nexport class Request {\n\t/** The requested track name. */\n\treadonly name: string;\n\n\t#producer: Producer;\n\t#sequences: TrackSequences;\n\t#pending: Set<Request>;\n\n\tprivate constructor(options: TrackRequestOptions) {\n\t\tthis.name = options.name;\n\t\tthis.#producer = options.producer;\n\t\tthis.#sequences = options.sequences;\n\t\tthis.#pending = options.pending;\n\t\tthis.#pending.add(this);\n\t}\n\n\tstatic {\n\t\thooks.makeRequest = (options) => new Request(options);\n\t}\n\n\t/** The aggregate subscription requested for this track. */\n\tget subscription(): Readonly<Subscription> {\n\t\treturn this.#producer.subscription.peek() ?? subscriptionDefaults();\n\t}\n\n\t/** The subscriber's priority for this track. */\n\tget priority(): number {\n\t\treturn this.subscription.priority ?? 0;\n\t}\n\n\t/** Accept the request, committing the track's immutable {@link Info}. */\n\taccept(info: Partial<Info> = {}): Producer {\n\t\tthis.#pending.delete(this);\n\t\tbindProducer(this.name, this.#producer, this.#sequences);\n\t\treturn this.#producer.accept(info);\n\t}\n\n\t/** Reject the request, closing the track optionally with an error. */\n\treject(err?: Error): void {\n\t\tthis.#pending.delete(this);\n\t\tthis.#producer.close(err);\n\t}\n}\n\n/** Options for {@link Consumer.fetchGroup}. */\nexport interface FetchGroupOptions {\n\t/** Delivery priority for the fetch stream. Defaults to `0`. */\n\tpriority?: number;\n}\n\n/**\n * A lazy handle to a track on a consumed broadcast.\n *\n * @public\n */\nexport class Consumer {\n\t/** The track name. */\n\treadonly name: string;\n\n\t#broadcast: BroadcastWire;\n\n\tprivate constructor(name: string, broadcast: BroadcastWire) {\n\t\tthis.name = name;\n\t\tthis.#broadcast = broadcast;\n\t}\n\n\tstatic {\n\t\tregisterTrackConsumer((name, broadcast) => new Consumer(name, broadcast));\n\t}\n\n\t/**\n\t * Open a live subscription to the track.\n\t *\n\t * The cursor starts at the group the subscription named (its floor), or 0.\n\t * {@link Subscription.maxAge} is what asks for data: delivery skips everything above\n\t * the floor that the budget convicts, so the default budget of zero delivers only the\n\t * latest group and a larger one reaches back over what it can still use.\n\t */\n\tsubscribe(options?: Subscription): Subscriber {\n\t\treturn this.#broadcast.subscribe(this.name, options);\n\t}\n\n\t/** Fetch the track's immutable publisher properties without subscribing. */\n\tinfo(): Promise<Info> {\n\t\treturn this.#broadcast.resolveTrackInfo(this.name);\n\t}\n\n\t/** Fetch a single group by sequence without holding a live subscription. */\n\tfetchGroup(sequence: number, options?: FetchGroupOptions): Promise<GroupConsumer> {\n\t\treturn this.#broadcast.fetchGroup(this.name, sequence, options);\n\t}\n}\n\n// The shared state behind a Producer / Subscriber pair. Package-internal\n// wiring, unexported so it never appears in the published type declarations.\nclass TrackState {\n\t/** The producer fanning into this sink, so a subscriber can mint a sibling of itself. */\n\tproducer?: Producer;\n\tgroups = new Signal<GroupConsumer[]>([]);\n\t// Every group still in the producer's replay cache, including groups this\n\t// subscriber already consumed, paired with its source queue time. Drift anchors\n\t// have the same lifetime as content.\n\ttimeline = new Map<number, { group: GroupConsumer; time: number }>();\n\t// First timestamps mutate group state rather than track state, so held groups\n\t// watch this revision as well as arrivals when enforcing latency after handoff.\n\ttimelineChanged = new Signal(0);\n\t/** Best-effort datagram channel, parallel to {@link groups}; a bounded send buffer per subscriber. */\n\tdatagrams = new Signal<Datagram[]>([]);\n\tlatest?: number;\n\t/**\n\t * The exclusive final boundary, stamped when the producer closes cleanly: one past the\n\t * highest sequence produced. Groups and datagrams share the namespace, so this can\n\t * exceed `latest + 1` (which only tracks groups). Mirrors the Rust `final_sequence`.\n\t */\n\tfinal?: number;\n\tclosed = new Once<Error | null>();\n\tupdate: Signal<Subscription | undefined>;\n\t/** Resolved once the producer commits the immutable properties. */\n\tinfo = new Signal<Info | undefined>(undefined);\n\n\tconstructor(subscription?: Subscription) {\n\t\tthis.update = new Signal(subscription === undefined ? undefined : subscriptionDefaults(subscription));\n\t}\n}\n\n// Settle a track state's closed Once. Idempotent: Once.set throws on a second settle, and a\n// Producer closing its sinks races the Subscriber closing itself (the sink is only removed from\n// #sinks a microtask later, via the closed subscription below).\nfunction closeTrackState(state: TrackState, abort?: Error): boolean {\n\tif (state.closed.peek() !== undefined) return false;\n\tstate.closed.set(abort ?? null);\n\treturn true;\n}\n\n// Resolve the track's immutable publisher properties, or reject if it closes first.\n// On a producer this resolves once info is committed (at accept time); on a consumer\n// once the wire layer commits the TRACK_INFO it received (lite-05+) or defaults (older\n// drafts), so awaiting it never yields a placeholder.\nasync function resolveInfo(state: TrackState): Promise<Info> {\n\tfor (;;) {\n\t\tconst info = state.info.peek();\n\t\tif (info) return info;\n\n\t\tconst closed = state.closed.peek();\n\t\tif (closed instanceof Error) throw closed;\n\t\tif (closed !== undefined) throw new Error(\"track closed before info was known\");\n\n\t\tawait Signal.race(state.info, state.closed);\n\t}\n}\n\n// A source group retained in the producer cache, with the mirror handed to each sink\n// so eviction can drop them together.\ntype CachedGroup = { group: GroupProducer; time: number; mirrors: Map<TrackState, GroupConsumer> };\n\nfunction bindProducer(name: string, producer: Producer, sequences: TrackSequences): void {\n\tlet shared = sequences.get(name);\n\tif (!shared) {\n\t\tshared = { next: 0 };\n\t\tsequences.set(name, shared);\n\t}\n\tbindProducerSequence(producer, shared);\n}\n\nlet bindProducerSequence: (producer: Producer, sequence: TrackSequence) => void;\n\n// The sequence-order cursor lives inside `Subscriber` (it shares the group buffer and the\n// drift anchor with the arrival cursor), so `Ordered` reaches it through this bridge,\n// assigned in the class's static block.\nlet makeOrdered: (subscriber: Subscriber) => Ordered;\nlet ordered_: {\n\tnextGroup(subscriber: Subscriber): Promise<GroupConsumer | undefined>;\n\treadFrame(subscriber: Subscriber): Promise<({ group: number; frame: number } & Frame) | undefined>;\n\treadString(subscriber: Subscriber): Promise<string | undefined>;\n\treadJson(subscriber: Subscriber): Promise<unknown | undefined>;\n\treadBool(subscriber: Subscriber): Promise<boolean | undefined>;\n\trecvDatagram(subscriber: Subscriber): Promise<Datagram | undefined>;\n};\n\n// Constructs a Subscriber from within this module without exposing a public\n// constructor that would leak the unexported TrackState. Assigned in the class's\n// static block.\nlet makeSubscriber: (name: string, state: TrackState) => Subscriber;\n\n/**\n * The write side of a track, mirroring the Rust `Producer`.\n *\n * A producer is a fan-out source: every {@link subscribe} (including each wire\n * subscription the publisher serves from it) gets an independent\n * {@link Subscriber} that receives a full copy of the groups, each with its own\n * read cursor. Groups are mirrored into every live subscriber and retained for the\n * track's `maxAge` window so a late subscriber replays the recent groups.\n *\n * Obtained from {@link Request.accept} (the wire asks the application for a track to\n * serve) or constructed directly for an in-process track.\n */\nexport class Producer {\n\t/** The track name. */\n\treadonly name: string;\n\n\t// The producer's own state is the source of truth (info/closed); subscribers\n\t// read mirrored sinks, never this state directly.\n\t#state = new TrackState();\n\t#sequence: TrackSequence = { next: 0 };\n\n\t// Recently written source groups, retained for replay to late subscribers and\n\t// pruned once idle for longer than the cache window. Each entry tracks the mirror\n\t// it handed to every sink so eviction can drop them too: otherwise a slow consumer\n\t// that never reads would pin old groups (and their frame bytes) forever.\n\t#cache: CachedGroup[] = [];\n\n\t// Wakeup for the next entry due to age out. Writes settle retention inline, but a\n\t// publisher that stalls stops writing, so without this an abandoned group (and any\n\t// reader parked in it) would wait for a write that never comes.\n\t#pruneTimer?: ReturnType<typeof setTimeout>;\n\n\t// One independent downstream state per live subscriber.\n\t#sinks = new Set<TrackState>();\n\n\t// Whether any subscriber is currently attached. Exposed as {@link used}; the consumer wire\n\t// watches it to tear down an idle upstream, and a publisher can watch it for on-demand capture.\n\t#used = new Signal<boolean>(false);\n\n\tconstructor(name: string) {\n\t\tthis.name = name;\n\t}\n\n\tstatic {\n\t\tbindProducerSequence = (producer, sequence) => {\n\t\t\tproducer.#sequence = sequence;\n\t\t};\n\t}\n\n\t/**\n\t * Resolve this track's immutable publisher properties, committed at accept time.\n\t * Rejects if the track is closed before the properties are known.\n\t */\n\tinfo(): Promise<Info> {\n\t\treturn resolveInfo(this.#state);\n\t}\n\n\t/**\n\t * Publisher priority from the committed {@link Info}, or 0 before {@link accept}.\n\t *\n\t * Higher is served first. Hang publishers set this from `Catalog.PRIORITY` so\n\t * audio outranks video on the wire and in the bandwidth allocator.\n\t */\n\tget priority(): number {\n\t\treturn this.#state.info.peek()?.priority ?? 0;\n\t}\n\n\t/**\n\t * Settles once the track closes: `null` on a clean close, or the abort {@link Error}.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/**\n\t * The aggregate subscription across live subscribers, or `undefined` when there are none.\n\t * The wire layer watches this to emit SUBSCRIBE_UPDATE.\n\t */\n\tget subscription(): Getter<Subscription | undefined> {\n\t\treturn this.#state.update;\n\t}\n\n\t/** Commit the immutable publisher properties, resolving {@link info}. Returns `this`. */\n\taccept(info: Partial<Info> = {}): this {\n\t\tif (this.#state.closed.peek() !== undefined) return this;\n\t\tconst resolved = infoDefaults(info);\n\t\tthis.#state.info.set(resolved);\n\t\t// Propagate to any sink handed out before accept (the on-demand path).\n\t\tfor (const sink of this.#sinks) sink.info.set(resolved);\n\t\tthis.#updateSubscription();\n\t\treturn this;\n\t}\n\n\t/**\n\t * An independent {@link Subscriber} reading this track's groups.\n\t *\n\t * Its cursor starts at the group the subscription named (its floor), or 0.\n\t * {@link Subscription.maxAge} is what asks for data: delivery skips everything above\n\t * the floor that the budget convicts, so the default budget of zero delivers only the\n\t * latest group and a larger one reaches back over what it can still use.\n\t */\n\tsubscribe(options: Subscription = {}): Subscriber {\n\t\tconst sink = new TrackState(options);\n\t\tthis.#addSink(sink);\n\t\treturn makeSubscriber(this.name, sink);\n\t}\n\n\t/**\n\t * Whether the track currently has any subscribers.\n\t *\n\t * Watch it (`effect.get` / `.peek()`) to drive on-demand work: a publisher can start and stop\n\t * capture with demand, and the consumer wire watches it to tear an idle upstream subscription\n\t * down instead of downloading to nobody. Pairs with {@link unused}. Mirrors the Rust `Demand`.\n\t */\n\tget used(): Getter<boolean> {\n\t\treturn this.#used;\n\t}\n\n\t/** Resolves once the track has no subscribers (or has closed). Await it to react to demand ending. */\n\tasync unused(): Promise<void> {\n\t\twhile (this.#used.peek() && this.#state.closed.peek() === undefined) {\n\t\t\tawait Signal.race(this.#used, this.#state.closed);\n\t\t}\n\t}\n\n\t// Register a downstream sink: seed its info, replay the retained window, and (while\n\t// the track is open) mirror future groups into it. A late subscriber to a closed\n\t// track still drains the buffered groups before seeing the end.\n\t#addSink(sink: TrackState): void {\n\t\tsink.producer = this;\n\t\tconst info = this.#state.info.peek();\n\t\tif (info) sink.info.set(info);\n\n\t\tconst closed = this.#state.closed.peek();\n\t\tif (closed === undefined) {\n\t\t\tthis.#sinks.add(sink);\n\t\t\tthis.#used.set(true);\n\n\t\t\t// Forward subscription updates from the sink's Subscriber to the producer's own\n\t\t\t// state, which the wire layer (or the serving application) watches.\n\t\t\tconst forward = sink.update.subscribe(() => this.#updateSubscription());\n\t\t\tthis.#updateSubscription();\n\n\t\t\t// Drop the sink once its consumer goes away, closing its mirrors so source\n\t\t\t// groups stop teeing into them, so a long-lived producer doesn't leak. This\n\t\t\t// covers mirrors already handed out via recvGroup (no longer in sink.groups)\n\t\t\t// by closing them through the cache's per-sink tracking.\n\t\t\tconst dispose = sink.closed.subscribe((c) => {\n\t\t\t\tif (c === undefined) return;\n\t\t\t\tconst abort = c instanceof Error ? c : undefined;\n\t\t\t\tforward();\n\t\t\t\tthis.#sinks.delete(sink);\n\t\t\t\tthis.#updateSubscription();\n\t\t\t\tfor (const entry of this.#cache) {\n\t\t\t\t\tconst mirror = entry.mirrors.get(sink);\n\t\t\t\t\tif (mirror) {\n\t\t\t\t\t\tmirror.close(abort);\n\t\t\t\t\t\tentry.mirrors.delete(sink);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const group of sink.groups.peek()) group.close(abort);\n\t\t\t\tdispose();\n\n\t\t\t\t// Update demand: once the last subscriber leaves, the consumer wire (watching\n\t\t\t\t// {@link unused}) tears the upstream down instead of downloading to nobody.\n\t\t\t\tthis.#used.set(this.#sinks.size > 0);\n\t\t\t});\n\t\t}\n\n\t\tthis.#prune();\n\t\tfor (const entry of this.#cache) this.#mirror(entry, sink);\n\n\t\tif (closed !== undefined) {\n\t\t\tsink.final = this.#state.final;\n\t\t\tcloseTrackState(sink, closed instanceof Error ? closed : undefined);\n\t\t}\n\t}\n\n\t// Recompute from every live sink because an update or close can narrow as well as widen\n\t// the aggregate. The wire layer observes this signal and emits SUBSCRIBE_UPDATE.\n\t#updateSubscription(): void {\n\t\tconst combined = combineSubscriptions(this.#sinks);\n\t\tconst retained = this.#state.info.peek()?.maxAge;\n\t\tif (combined && retained !== undefined) combined.maxAge = Milli.min(combined.maxAge ?? Milli.zero, retained);\n\t\tthis.#state.update.set(combined);\n\t}\n\n\t// Mirror a cached source group into a sink. The mirror fills synchronously as the\n\t// source is written and keeps its own read cursor; frame bytes are shared by\n\t// reference. Tracked on the entry so eviction can drop it from the sink.\n\t#mirror(entry: CachedGroup, sink: TrackState): void {\n\t\tconst dst = entry.group.mirror();\n\t\tentry.mirrors.set(sink, dst);\n\t\tsink.timeline.set(dst.sequence, { group: dst, time: entry.time });\n\t\tvoid dst.readable().then(() => sink.timelineChanged.update((revision) => revision + 1));\n\t\tsink.latest = Math.max(sink.latest ?? 0, dst.sequence);\n\t\tsink.groups.mutate((groups) => {\n\t\t\tgroups.push(dst);\n\t\t\tgroups.sort((a, b) => a.sequence - b.sequence);\n\t\t});\n\t}\n\n\t// Drop a cached group's mirror from every sink so no consumer can pin it.\n\t#evict(entry: CachedGroup): void {\n\t\t// Reclaiming a group the publisher never closed ends it as the gap it is, before\n\t\t// the mirrors below would otherwise report a clean finish to a reader that had\n\t\t// drained it. The usual case, an already-closed group aging out, keeps its own\n\t\t// terminal state.\n\t\tif (!entry.group.isClosed) entry.group.close(new TooFarBehind());\n\t\tfor (const [sink, mirror] of entry.mirrors) {\n\t\t\thooks.evictGroup(mirror);\n\t\t\tsink.groups.mutate((groups) => {\n\t\t\t\tconst i = groups.indexOf(mirror);\n\t\t\t\tif (i >= 0) groups.splice(i, 1);\n\t\t\t});\n\t\t\tif (sink.timeline.get(mirror.sequence)?.group === mirror) sink.timeline.delete(mirror.sequence);\n\t\t\tmirror.close();\n\t\t}\n\t\tentry.mirrors.clear();\n\t}\n\n\t// The one group retention never takes: the newest, while it is still open. That is\n\t// the live edge a publisher is appending to, and a track may legitimately keep it\n\t// open across a long quiet stretch (a catalog snapshot, a JSON stream). Every other\n\t// open group is an abandoned one, and ages out like a closed one.\n\t#liveEdge(): GroupProducer | undefined {\n\t\tconst latest = this.#cache.at(-1)?.group;\n\t\treturn latest?.closed.peek() === undefined ? latest : undefined;\n\t}\n\n\t// Evict cached groups idle for longer than the cache window. Idle means nothing\n\t// written, so an abandoned open group ages out instead of pinning its buffer (and\n\t// any reader parked in it) forever.\n\t#prune(): void {\n\t\tconst maxAgeMs = this.#state.info.peek()?.maxAge ?? DEFAULT_MAX_AGE_MS;\n\t\tconst cutoff = performance.now() - maxAgeMs;\n\t\tconst live = this.#liveEdge();\n\n\t\tconst retained: CachedGroup[] = [];\n\t\tfor (const entry of this.#cache) {\n\t\t\tif (entry.group === live || entry.group.activity >= cutoff) {\n\t\t\t\tretained.push(entry);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.#evict(entry);\n\t\t}\n\t\tthis.#cache = retained;\n\t\tthis.#schedulePrune();\n\t}\n\n\t// Arm the wakeup for the next entry due to age out, replacing any pending one.\n\t// Writes settle retention inline, so this only has to cover the case no write\n\t// follows. Cheap to over-arm: an entry written since is retained and re-armed.\n\t#schedulePrune(): void {\n\t\tclearTimeout(this.#pruneTimer);\n\t\tthis.#pruneTimer = undefined;\n\t\tif (this.#state.closed.peek() !== undefined) return;\n\n\t\t// One pass, no intermediate arrays: this runs on every publish, and a spread\n\t\t// over the cache would also cap how many groups a track can hold.\n\t\tconst live = this.#liveEdge();\n\t\tlet oldest: number | undefined;\n\t\tfor (const entry of this.#cache) {\n\t\t\tif (entry.group === live) continue;\n\t\t\tif (oldest === undefined || entry.group.activity < oldest) oldest = entry.group.activity;\n\t\t}\n\t\tif (oldest === undefined) return;\n\n\t\tconst maxAgeMs = this.#state.info.peek()?.maxAge ?? DEFAULT_MAX_AGE_MS;\n\t\t// setTimeout truncates its delay to a signed 32-bit int, so a longer window\n\t\t// would fire immediately and spin. Wake at the cap instead and re-arm: #prune\n\t\t// retains anything still fresh, so the extra wakeups are the only cost.\n\t\tconst delay = Math.min(MAX_TIMEOUT_MS, Math.max(0, oldest + maxAgeMs - performance.now()));\n\t\tconst timer = setTimeout(() => {\n\t\t\tthis.#pruneTimer = undefined;\n\t\t\tthis.#prune();\n\t\t}, delay);\n\t\t// A cache prune is never a reason to hold a Node/Bun process open.\n\t\t(timer as unknown as { unref?: () => void }).unref?.();\n\t\tthis.#pruneTimer = timer;\n\t}\n\n\t// Retain a source group and fan it out to every live sink.\n\t#publish(group: GroupProducer): void {\n\t\tconst entry: CachedGroup = { group, time: performance.now(), mirrors: new Map<TrackState, GroupConsumer>() };\n\t\tthis.#cache.push(entry);\n\t\tfor (const sink of this.#sinks) this.#mirror(entry, sink);\n\t\t// Give held mirrors the new live edge before pruning their timeline entry,\n\t\t// so their latency guard can preserve a terminal expiry verdict.\n\t\tthis.#prune();\n\t}\n\n\t/** Append a new group with the next sequence number. */\n\tappendGroup(): GroupProducer {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"track is closed\");\n\n\t\tconst sequence = this.#sequence;\n\t\tconst group = new GroupProducer(sequence.next);\n\t\tsequence.next = group.sequence + 1;\n\t\tthis.#publish(group);\n\n\t\treturn group;\n\t}\n\n\t/**\n\t * Insert an existing group into the track.\n\t *\n\t * Throws on a sequence that is still cached: a live duplicate would fan out to every\n\t * subscriber twice. An aborted incarnation is evicted so a fresh group can serve the\n\t * sequence again. Best effort (mirrors Rust): nothing remembers a sequence whose cache\n\t * entry is already gone, so a long-evicted sequence is accepted as new.\n\t */\n\twriteGroup(group: GroupProducer) {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"track is closed\");\n\n\t\tconst existing = this.#cache.findIndex((entry) => entry.group.sequence === group.sequence);\n\t\tif (existing >= 0) {\n\t\t\tconst entry = this.#cache[existing];\n\t\t\tif (!(entry.group.closed.peek() instanceof Error)) {\n\t\t\t\tthrow new Error(`duplicate group: sequence=${group.sequence}`);\n\t\t\t}\n\t\t\tthis.#evict(entry);\n\t\t\tthis.#cache.splice(existing, 1);\n\t\t}\n\n\t\t// Only advance the shared counter upward (for appendGroup auto-increment).\n\t\tconst sequence = this.#sequence;\n\t\tif (group.sequence >= sequence.next) {\n\t\t\tsequence.next = group.sequence + 1;\n\t\t}\n\n\t\tthis.#publish(group);\n\t}\n\n\t// Fan a datagram out to every live subscriber, dropping the oldest once the ring is full.\n\t// Late subscribers do NOT replay old datagrams (best-effort, unlike the group cache).\n\t#publishDatagram(datagram: Datagram): void {\n\t\tfor (const sink of this.#sinks) {\n\t\t\tsink.datagrams.mutate((list) => {\n\t\t\t\tif (list.length === MAX_DATAGRAMS) list.shift();\n\t\t\t\tlist.push(datagram);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Append a datagram with the next sequence number, returning the assigned sequence.\n\t *\n\t * A datagram is delivered best-effort over a single QUIC datagram, parallel to the track's\n\t * groups but drawing from the same sequence namespace (interleaving with {@link appendGroup}\n\t * never reuses a number). The payload must fit the negotiated transport datagram size minus\n\t * a small header; an oversize payload is dropped at each hop (there is no group fallback), so\n\t * keep datagram payloads small (e.g. a single audio frame). Datagrams are never delivered\n\t * over IETF moq-transport or stream-only transports (the WebSocket fallback). A payload over\n\t * 65535 bytes (the QUIC datagram frame ceiling) throws. An origin publisher uses this; a\n\t * relay preserving upstream numbering uses {@link insertDatagram}.\n\t */\n\tappendDatagram(timestamp: Timestamp, payload: Uint8Array): number {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"track is closed\");\n\t\tif (payload.byteLength > MAX_DATAGRAM_BYTES) throw new Error(\"datagram payload too large\");\n\n\t\tconst counter = this.#sequence;\n\t\tconst sequence = counter.next;\n\t\tcounter.next = sequence + 1;\n\t\tthis.#publishDatagram({ sequence, timestamp, payload });\n\t\treturn sequence;\n\t}\n\n\t/**\n\t * Insert a datagram with an explicit sequence number.\n\t *\n\t * Preserves the supplied sequence (advancing the shared counter if needed) so a relay can\n\t * forward a datagram without renumbering it. The size limits of {@link appendDatagram}\n\t * apply. Most origin publishers want {@link appendDatagram} instead.\n\t */\n\tinsertDatagram(sequence: number, timestamp: Timestamp, payload: Uint8Array) {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"track is closed\");\n\t\tif (payload.byteLength > MAX_DATAGRAM_BYTES) throw new Error(\"datagram payload too large\");\n\n\t\tconst counter = this.#sequence;\n\t\tif (sequence >= counter.next) {\n\t\t\tcounter.next = sequence + 1;\n\t\t}\n\t\tthis.#publishDatagram({ sequence, timestamp, payload });\n\t}\n\n\t/** Close the track and every subscriber, mirroring the abort to their groups. Idempotent. */\n\tclose(abort?: Error) {\n\t\t// A clean close declares the final boundary; an abort ends without one.\n\t\tif (abort === undefined && this.#state.closed.peek() === undefined) {\n\t\t\tthis.#state.final = this.#sequence.next;\n\t\t\tfor (const sink of this.#sinks) sink.final = this.#state.final;\n\t\t}\n\t\tcloseTrackState(this.#state, abort);\n\t\tclearTimeout(this.#pruneTimer);\n\t\tthis.#pruneTimer = undefined;\n\t\tfor (const { group } of this.#cache) group.close(abort);\n\t\tfor (const sink of this.#sinks) {\n\t\t\tfor (const group of sink.groups.peek()) group.close(abort);\n\t\t\tcloseTrackState(sink, abort);\n\t\t}\n\t\tthis.#sinks.clear();\n\t}\n\n\t/** Append a frame as its own single-frame group. */\n\twriteFrame(frame: Frame) {\n\t\tconst group = this.appendGroup();\n\t\tgroup.writeFrame(frame);\n\t\tgroup.close();\n\t}\n\n\t/** Appends a string to the track as its own single-frame group. */\n\twriteString(str: string) {\n\t\tconst group = this.appendGroup();\n\t\tgroup.writeString(str);\n\t\tgroup.close();\n\t}\n\n\t/** Appends a JSON value to the track as its own single-frame group. */\n\twriteJson(json: unknown) {\n\t\tconst group = this.appendGroup();\n\t\tgroup.writeJson(json);\n\t\tgroup.close();\n\t}\n\n\t/** Appends a boolean to the track as its own single-frame group. */\n\twriteBool(bool: boolean) {\n\t\tconst group = this.appendGroup();\n\t\tgroup.writeBool(bool);\n\t\tgroup.close();\n\t}\n}\n\n/**\n * The read side of a live track subscription, mirroring the Rust `Subscriber`.\n *\n * Obtained from `Broadcast.Consumer.subscribe` / `Track.Consumer.subscribe`, or from\n * {@link Producer.subscribe} for an in-process track. Reads the groups a\n * {@link Producer} on the same underlying state writes.\n */\nexport class Subscriber {\n\t/** The track name. */\n\treadonly name: string;\n\n\t#state: TrackState;\n\t#nextSequence = 0;\n\t#cursor = new Signal<{ start: number; end?: number }>({ start: 0 });\n\t#enforceLatency = true;\n\t// Which cursor owns this subscription. Both cursors draw from one buffer, so the\n\t// first group read commits the track to arrival order and {@link ordered} commits\n\t// it to sequence order; whichever wins is the only one allowed from here on.\n\t// Datagrams are a separate cursor and never commit.\n\t#mode?: \"arrival\" | \"ordered\";\n\t// The group the frame-level helpers are currently draining, acquired through the\n\t// sequence cursor so frame reads and {@link Ordered.nextGroup} share one floor.\n\t#frameGroup?: GroupConsumer;\n\n\t#drift(): {\n\t\tbudget: number;\n\t\tpresentation?: { sequence: number; timestamp: Timestamp };\n\t\tend?: number;\n\t} {\n\t\tconst { end } = this.#cursor.peek();\n\t\tlet presentation: { sequence: number; timestamp: Timestamp } | undefined;\n\t\tfor (const { group } of this.#state.timeline.values()) {\n\t\t\tif (end !== undefined && group.sequence >= end) continue;\n\t\t\tif (group.closed.peek() instanceof Error) continue;\n\t\t\t// The edge wants the newest content that exists, so it takes the newest\n\t\t\t// stamped group's latest frame.\n\t\t\tconst timestamp = hooks.groupTimestamp(group);\n\t\t\tif (timestamp !== undefined && (!presentation || group.sequence > presentation.sequence)) {\n\t\t\t\tpresentation = { sequence: group.sequence, timestamp: hooks.groupLatest(group) ?? timestamp };\n\t\t\t}\n\t\t}\n\n\t\tconst requested = this.#state.update.peek()?.maxAge ?? 0;\n\t\tconst retained = this.#state.info.peek()?.maxAge;\n\t\treturn {\n\t\t\tbudget: this.#enforceLatency\n\t\t\t\t? retained === undefined\n\t\t\t\t\t? requested\n\t\t\t\t\t: Math.min(requested, retained)\n\t\t\t\t: Number.POSITIVE_INFINITY,\n\t\t\tpresentation,\n\t\t\tend,\n\t\t};\n\t}\n\n\t// The furthest presentation time the group at `sequence` could still reach: where its\n\t// immediate servable successor begins, or undefined when nothing proves where it\n\t// stops. An upper bound, deliberately: a frame's duration is not on the wire, so a\n\t// group's own last timestamp says where it starts presenting, not where it ends.\n\t// Only the *immediate* successor counts: timestamps need not rise with sequence (a\n\t// rewind reorders them), so a later stamped group proves nothing about where an\n\t// unstamped successor will begin, and shrinking the bound is the unsafe direction.\n\t// An unstamped successor leaves the reach unbounded until it presents a frame.\n\t#reach(sequence: number, end?: number): number | undefined {\n\t\tlet successor: GroupConsumer | undefined;\n\t\tfor (const { group } of this.#state.timeline.values()) {\n\t\t\tif (group.sequence <= sequence) continue;\n\t\t\tif (end !== undefined && group.sequence >= end) continue;\n\t\t\tif (group.closed.peek() instanceof Error) continue;\n\t\t\tif (!successor || group.sequence < successor.sequence) successor = group;\n\t\t}\n\t\tif (!successor) return undefined;\n\t\treturn hooks.groupTimestamp(successor)?.asMillis();\n\t}\n\n\t// Whether the drift budget says to give up on `group`.\n\t//\n\t// Presentation time measures a group by how far it could still reach, not by how far\n\t// behind it started. Being behind is survivable: priority transmits newer groups first,\n\t// so a backlog bursts at whatever rate is left over and closes the gap faster than the\n\t// live edge advances. A group is abandoned only once everything it could still present\n\t// falls outside the budget.\n\t//\n\t// A group's reach is bounded by its nearest successor: it cannot present past where the\n\t// next group begins. Its own frames say nothing, since a frame's duration is not on the\n\t// wire, and the candidate needs no timestamp of its own: an empty group is bounded by\n\t// its stamped successor the same way. The bound is exclusive, so the comparison is `>=`:\n\t// the freshest frame a group could still hold sits just below its reach, so an age equal\n\t// to the budget already puts every frame in it strictly past the budget. A zero budget\n\t// falls out for free. Only timestamps drive expiry; wall-clock reclamation of idle\n\t// content is the cache's own policy, not the budget's.\n\t#isStale(\n\t\tgroup: GroupConsumer,\n\t\tdrift: {\n\t\t\tbudget: number;\n\t\t\tpresentation?: { sequence: number; timestamp: Timestamp };\n\t\t\tend?: number;\n\t\t},\n\t): boolean {\n\t\tconst candidate = this.#state.timeline.get(group.sequence);\n\t\tif (candidate?.group !== group) return false;\n\n\t\tconst reach = this.#reach(group.sequence, drift.end);\n\t\treturn (\n\t\t\tdrift.presentation !== undefined &&\n\t\t\tdrift.presentation.sequence > group.sequence &&\n\t\t\treach !== undefined &&\n\t\t\tdrift.presentation.timestamp.asMillis() - reach >= drift.budget\n\t\t);\n\t}\n\n\t#guard(group: GroupConsumer): GroupConsumer {\n\t\tif (!this.#enforceLatency) return group;\n\t\thooks.expireGroup(group, {\n\t\t\texpired: () => this.#isStale(group, this.#drift()),\n\t\t\tchanged: [\n\t\t\t\tthis.#state.groups,\n\t\t\t\tthis.#state.timelineChanged,\n\t\t\t\tthis.#state.update,\n\t\t\t\tthis.#state.info,\n\t\t\t\tthis.#cursor,\n\t\t\t\tthis.#state.closed,\n\t\t\t],\n\t\t});\n\t\treturn group;\n\t}\n\n\tprivate constructor(name: string, state: TrackState) {\n\t\tthis.name = name;\n\t\tthis.#state = state;\n\t\t// The cursor's floor is the group the subscription named, or 0. A floor is the\n\t\t// only thing a start contributes; {@link Subscription.maxAge} is what asks for\n\t\t// data, and delivery skips everything above the floor that the budget convicts.\n\t\tthis.#cursor.set({ start: groupBounds(state.update.peek()?.groups ?? {}).start });\n\t}\n\n\tstatic {\n\t\tmakeSubscriber = (name, state) => new Subscriber(name, state);\n\t\thooks.tryRecvGroup = (subscriber) => subscriber.#tryRecvGroup();\n\t\thooks.groupChanged = (subscriber, fn) => subscriber.#groupChanged(fn);\n\t\thooks.exemptFetch = (subscriber) => {\n\t\t\tsubscriber.#enforceLatency = false;\n\t\t};\n\t\thooks.replaceGroups = (subscriber, groups) => subscriber.#replaceGroups(groups);\n\t\t// The sequence cursor lives here (it shares the buffer and the drift anchor with\n\t\t// the arrival cursor); `Ordered` is the handle that reaches it.\n\t\tordered_ = {\n\t\t\tnextGroup: (subscriber) => subscriber.#nextGroup(),\n\t\t\treadFrame: (subscriber) => subscriber.#readFrame(),\n\t\t\treadString: (subscriber) => subscriber.#readString(),\n\t\t\treadJson: (subscriber) => subscriber.#readJson(),\n\t\t\treadBool: (subscriber) => subscriber.#readBool(),\n\t\t\t// Unordered either way, so both handles reach the same cursor.\n\t\t\trecvDatagram: (subscriber) => subscriber.#recvDatagram(),\n\t\t};\n\t}\n\n\t// Refuse a read on this handle once `ordered()` has taken the subscription.\n\t#live() {\n\t\tif (this.#mode === \"ordered\") throw new Error(\"track is read in sequence order; use the Ordered handle\");\n\t}\n\n\t/**\n\t * Resolve this track's immutable publisher properties.\n\t *\n\t * Resolves once the wire layer commits the TRACK_INFO it received (lite-05+) or\n\t * defaults (older drafts), so awaiting it never yields a placeholder. Rejects if\n\t * the track is closed before the properties are known (e.g. a rejected subscription).\n\t */\n\tinfo(): Promise<Info> {\n\t\treturn resolveInfo(this.#state);\n\t}\n\n\t/** Settles once the track closes; see {@link Producer.closed}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/** This subscriber's current options, including defaults and the last {@link update}. */\n\tget subscription(): Getter<Subscription | undefined> {\n\t\treturn this.#state.update;\n\t}\n\n\t/** Return the latest group sequence observed on this track, if any. */\n\tlatest(): number | undefined {\n\t\treturn this.#state.latest;\n\t}\n\n\t/**\n\t * The track's exclusive final boundary, known once the producer closes cleanly:\n\t * one past the highest sequence produced, or 0 for a track that produced none.\n\t * Groups and datagrams share the sequence namespace, so this can exceed\n\t * `latest() + 1`. Undefined while the track is live or after an abort.\n\t */\n\tfinal(): number | undefined {\n\t\treturn this.#state.final;\n\t}\n\n\t/**\n\t * The newest frame this track has produced, or `undefined` while it has none.\n\t *\n\t * Read from the groups buffered for this subscriber, so nothing is consumed. A newest\n\t * group that has no frames yet falls back to the newest older group that does. It\n\t * reads as `undefined` once the newest group has been evicted or received: what is\n\t * left can no longer say where the edge is.\n\t */\n\tlargest(): Location | undefined {\n\t\tconst latest = this.#state.latest;\n\t\tif (latest === undefined) return undefined;\n\n\t\tconst groups = this.#state.groups.peek();\n\t\tconst newest = groups[groups.length - 1];\n\t\tif (!newest || newest.sequence !== latest) return undefined;\n\n\t\tfor (let i = groups.length - 1; i >= 0; i--) {\n\t\t\tconst count = groups[i].frameCount;\n\t\t\tif (count > 0) return { group: groups[i].sequence, frame: count - 1 };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * An independent subscriber to the same track, with its own cursor and its own replay of\n\t * the retained window.\n\t *\n\t * Reads here do not consume anything this one would deliver, which is what lets a\n\t * publisher read the cache alongside the cursor it is serving from. Resolving the track\n\t * again through the broadcast would not do: a dynamic serve is one request per peer\n\t * subscription, so that mints a second producer the application has to answer separately.\n\t *\n\t * @internal Wire layers only.\n\t */\n\tfork(options?: Subscription): Subscriber {\n\t\tconst producer = this.#state.producer;\n\t\tif (!producer) throw new Error(\"track has no producer to fork from\");\n\t\treturn producer.subscribe(options);\n\t}\n\n\t/** Limit subsequent reads to these groups and return this reader for chaining. */\n\twithGroups(groups: Groups): this {\n\t\tthis.setGroups(groups);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Limit subsequent reads without rewinding read progress or changing the wire request.\n\t * An omitted start preserves the current floor; an omitted end removes the cap.\n\t * Raising the end makes unread buffered groups available again.\n\t */\n\tsetGroups(groups: Groups): void {\n\t\tconst { start, end } = groupBounds(groups);\n\t\tthis.#cursor.update((cursor) => ({ start: Math.max(cursor.start, start), end }));\n\t}\n\n\t// Serving counterpart of setGroups: a named start replaces the floor, matching\n\t// Rust `start_at`. Local readers stay monotonic; only the wire publisher lowers.\n\t#replaceGroups(groups: Groups): void {\n\t\tconst { start, end } = groupBounds(groups);\n\t\tthis.#cursor.update((cursor) => ({\n\t\t\tstart: groups.start === undefined ? cursor.start : start,\n\t\t\tend,\n\t\t}));\n\t}\n\n\t/** Close the track (optionally with an error), closing any pending groups. Idempotent. */\n\tclose(abort?: Error) {\n\t\t// Settle if we're first (the producer may already have); either way drop anything\n\t\t// still buffered. Groups parked at the setGroups cap deliberately outlive a clean\n\t\t// producer close, so the subscriber leaving is what must release them: closing\n\t\t// and clearing wakes a pending read to observe the end instead of hanging.\n\t\tcloseTrackState(this.#state, abort);\n\t\tthis.#state.groups.mutate((groups) => {\n\t\t\tfor (const group of groups) group.close(abort);\n\t\t\tgroups.length = 0;\n\t\t});\n\t\tthis.#frameGroup?.close(abort);\n\t\tthis.#frameGroup = undefined;\n\t\tthis.#state.timeline.clear();\n\t}\n\n\t/**\n\t * Receive every group on this track exactly once, as it becomes available.\n\t *\n\t * Groups may arrive out of order or with gaps due to network conditions; unlike\n\t * {@link Ordered.nextGroup}, one that arrives after a newer group was already returned\n\t * is still delivered. When several groups are buffered, the lowest sequence is\n\t * returned first.\n\t *\n\t * Honors the range set by {@link setGroups}: a group\n\t * beyond the cap stays buffered (not dropped) and is offered once the cap rises, even\n\t * after a clean close, without blocking in-range groups that arrive behind it.\n\t * A group whose presentation time is further behind the live edge than this\n\t * subscriber's `maxAge` is skipped. The default of zero takes the live edge.\n\t * The budget remains attached after return, so a pending frame read rejects if a stalled\n\t * group becomes stale while newer data advances.\n\t *\n\t * The first call commits this track to arrival order: {@link ordered} throws afterwards.\n\t */\n\tasync recvGroup(): Promise<GroupConsumer | undefined> {\n\t\tthis.#live();\n\t\tthis.#mode = \"arrival\";\n\t\tfor (;;) {\n\t\t\tconst recv = this.#tryRecvGroup();\n\t\t\tswitch (recv.kind) {\n\t\t\t\tcase \"group\":\n\t\t\t\t\treturn recv.group;\n\t\t\t\tcase \"done\":\n\t\t\t\t\treturn undefined;\n\t\t\t\tcase \"error\":\n\t\t\t\t\tthrow recv.error;\n\t\t\t}\n\n\t\t\t// Idle, or parked at the boundary waiting for the cap to rise.\n\t\t\tawait Signal.race(this.#state.groups, this.#cursor, this.#state.closed);\n\t\t}\n\t}\n\n\t// Package-internal synchronous half of recvGroup. The lite publisher uses this so applying\n\t// control state, popping the group, and positioning its frames are one JavaScript turn.\n\t#tryRecvGroup(): Recv {\n\t\tconst groups = this.#state.groups.peek();\n\t\tconst { start, end } = this.#cursor.peek();\n\t\twhile (groups.length > 0 && groups[0].sequence < start) groups.shift()?.close();\n\t\tconst drift = this.#drift();\n\n\t\tfor (;;) {\n\t\t\t// The buffer is sequence-sorted, so an in-range group that arrives behind a\n\t\t\t// beyond-cap one sorts in front of it and is never blocked by it.\n\t\t\tconst group = groups[0];\n\t\t\tif (!group || (end !== undefined && group.sequence >= end)) break;\n\t\t\tgroups.shift();\n\t\t\tif (this.#isStale(group, drift)) {\n\t\t\t\tgroup.close();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn { kind: \"group\", group: this.#guard(group) };\n\t\t}\n\n\t\tconst group = groups[0];\n\t\tconst closed = this.#state.closed.peek();\n\t\tif (closed instanceof Error) return { kind: \"error\", error: closed };\n\t\tif (closed === undefined) return { kind: \"idle\" };\n\t\t// A group beyond the cap outlives a clean close: it becomes deliverable if\n\t\t// the cap rises, so the track isn't over while any are held.\n\t\treturn group ? { kind: \"boundary\" } : { kind: \"done\" };\n\t}\n\n\t// Package-internal readiness half of recvGroup. Each registration fires at most once, and\n\t// the caller disposes the losers after whichever source wakes it.\n\t#groupChanged(fn: () => void): Dispose {\n\t\tconst dispose = [this.#state.groups.changed(fn), this.#cursor.changed(fn), this.#state.closed.changed(fn)];\n\t\treturn () => {\n\t\t\tfor (const close of dispose) close();\n\t\t};\n\t}\n\n\t/**\n\t * Take the next buffered group without blocking, honoring the same cursor bounds as\n\t * {@link recvGroup}.\n\t *\n\t * Returns `undefined` when nothing is deliverable right now, which is not by itself the\n\t * end of the track: a group may still arrive, or one may be parked beyond the\n\t * {@link setGroups} cap. Use it to drain what the retained window already holds, where\n\t * waiting for a sequence nothing will republish would park forever.\n\t */\n\ttryRecvGroup(): GroupConsumer | undefined {\n\t\tthis.#live();\n\t\tthis.#mode = \"arrival\";\n\t\tconst recv = this.#tryRecvGroup();\n\t\tif (recv.kind === \"group\") return recv.group;\n\t\tif (recv.kind === \"error\") throw recv.error;\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Receive the next datagram in arrival order.\n\t *\n\t * Datagrams are a separate best-effort channel from groups (see\n\t * {@link Producer.appendDatagram}); they share only the sequence namespace. A consumer\n\t * that falls too far behind silently loses the oldest datagrams. Read this alongside\n\t * {@link recvGroup} (e.g. in a separate loop) to receive both channels concurrently.\n\t * The two cursors are independent: a datagram never moves the group cursor.\n\t */\n\tasync recvDatagram(): Promise<Datagram | undefined> {\n\t\tthis.#live();\n\t\treturn this.#recvDatagram();\n\t}\n\n\t// The datagram cursor, reachable from either handle: unordered by construction, so the\n\t// choice of group order says nothing about it.\n\tasync #recvDatagram(): Promise<Datagram | undefined> {\n\t\tfor (;;) {\n\t\t\tconst datagrams = this.#state.datagrams.peek();\n\n\t\t\tif (datagrams.length > 0) {\n\t\t\t\treturn datagrams.shift();\n\t\t\t}\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed !== undefined) return undefined;\n\n\t\t\tawait Signal.race(this.#state.datagrams, this.#state.closed);\n\t\t}\n\t}\n\n\t// The sequence cursor behind {@link Ordered}, which owns the only public door to it.\n\tasync #nextGroup(): Promise<GroupConsumer | undefined> {\n\t\tfor (;;) {\n\t\t\tconst groups = this.#state.groups.peek();\n\t\t\tconst cursor = this.#cursor.peek();\n\t\t\tconst start = Math.max(cursor.start, this.#nextSequence);\n\t\t\twhile (groups.length > 0 && groups[0].sequence < start) groups.shift()?.close();\n\t\t\t// One anchor for the whole pass, so walking a backlog off stays linear.\n\t\t\tconst drift = this.#drift();\n\n\t\t\tfor (;;) {\n\t\t\t\tconst group = groups[0];\n\t\t\t\tif (!group || (cursor.end !== undefined && group.sequence >= cursor.end)) break;\n\t\t\t\tgroups.shift();\n\t\t\t\tthis.#nextSequence = group.sequence + 1;\n\t\t\t\t// Every frame this group could still hold is past the budget, so keep\n\t\t\t\t// scanning: one pass walks a whole backlog off rather than replaying it.\n\t\t\t\tif (this.#isStale(group, drift)) {\n\t\t\t\t\tgroup.close();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// One cursor: the frame helpers must not keep draining a group this\n\t\t\t\t// read just moved past, or interleaved reads would run backwards.\n\t\t\t\tif (this.#frameGroup && this.#frameGroup.sequence < group.sequence) {\n\t\t\t\t\tthis.#frameGroup.close();\n\t\t\t\t\tthis.#frameGroup = undefined;\n\t\t\t\t}\n\t\t\t\treturn this.#guard(group);\n\t\t\t}\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\t// A group parked above the cap stays deliverable even after a clean close\n\t\t\t// (its frames remain buffered), so keep waiting for a cap raise. Only a\n\t\t\t// drained track reports finished.\n\t\t\tif (closed !== undefined && !groups[0]) return undefined;\n\n\t\t\tawait Signal.race(this.#state.groups, this.#cursor, this.#state.closed);\n\t\t}\n\t}\n\n\t/**\n\t * Reads the next frame across groups, in sequence order, with its group and frame numbers.\n\t * Treat the returned frame bytes as read-only; they are shared with other consumers.\n\t *\n\t * Groups are acquired through the same sequence cursor as {@link Ordered.nextGroup},\n\t * so frames never run backwards: a late lower-sequence group is skipped, and so is\n\t * one every frame of which `maxAge` proves is too old. A group the budget abandons\n\t * mid-stall ends cleanly and the cursor resyncs from the next group; a gap inside a\n\t * group still surfaces as {@link TooFarBehind} or {@link GroupTooLarge}.\n\t */\n\tasync #readFrame(): Promise<({ group: number; frame: number } & Frame) | undefined> {\n\t\tfor (;;) {\n\t\t\tif (!this.#frameGroup) {\n\t\t\t\tthis.#frameGroup = await this.#nextGroup();\n\t\t\t\tif (!this.#frameGroup) return undefined;\n\t\t\t}\n\t\t\tconst group = this.#frameGroup;\n\n\t\t\tlet next: ({ sequence: number } & Frame) | undefined;\n\t\t\ttry {\n\t\t\t\tnext = await group.readFrameSequence();\n\t\t\t} catch (err) {\n\t\t\t\t// The group failed underneath us: resync from the next one, surfacing\n\t\t\t\t// only what the caller can act on (a gap, or the track's own abort).\n\t\t\t\tthis.#frameGroup = undefined;\n\t\t\t\tgroup.close();\n\t\t\t\tif (err instanceof TooFarBehind || err instanceof GroupTooLarge) throw err;\n\t\t\t\tconst closed = this.#state.closed.peek();\n\t\t\t\tif (closed instanceof Error) throw closed;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (next) {\n\t\t\t\treturn {\n\t\t\t\t\tgroup: group.sequence,\n\t\t\t\t\tframe: next.sequence,\n\t\t\t\t\tpayload: next.payload,\n\t\t\t\t\ttimestamp: next.timestamp,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// The group is exhausted (or the budget abandoned its stall); move on.\n\t\t\tthis.#frameGroup = undefined;\n\t\t\tgroup.close();\n\t\t}\n\t}\n\n\t/** Reads the next frame and decodes it as a UTF-8 string. */\n\tasync #readString(): Promise<string | undefined> {\n\t\tconst next = await this.#readFrame();\n\t\tif (!next) return undefined;\n\t\treturn new TextDecoder().decode(next.payload);\n\t}\n\n\t/** Reads the next frame and parses it as JSON. */\n\tasync #readJson(): Promise<unknown | undefined> {\n\t\tconst next = await this.#readString();\n\t\tif (!next) return undefined;\n\t\treturn JSON.parse(next);\n\t}\n\n\t/** Reads the next frame and decodes it as a one-byte boolean, throwing on a malformed frame. */\n\tasync #readBool(): Promise<boolean | undefined> {\n\t\tconst next = await this.#readFrame();\n\t\tif (!next) return undefined;\n\t\tconst payload = next.payload;\n\t\tif (payload.byteLength !== 1 || !(payload[0] === 0 || payload[0] === 1)) throw new Error(\"invalid bool frame\");\n\t\treturn payload[0] === 1;\n\t}\n\n\t/**\n\t * Read this track's groups in sequence order instead of arrival order.\n\t *\n\t * Both cursors draw from the same buffer, so a track is read one way or the other: this\n\t * hands the subscription to the returned {@link Ordered} and leaves this handle inert.\n\t * {@link recvGroup} and {@link recvDatagram} throw afterwards. Throws once a\n\t * {@link recvGroup} call has already committed the track to arrival order.\n\t *\n\t * Datagrams come along: they are a separate cursor either way, so the choice of group\n\t * order says nothing about them, and reading them commits nothing.\n\t */\n\tordered(): Ordered {\n\t\tif (this.#mode === \"ordered\") throw new Error(\"track is already read in sequence order\");\n\t\tif (this.#mode === \"arrival\") throw new Error(\"track is already read in arrival order\");\n\t\tthis.#mode = \"ordered\";\n\t\treturn makeOrdered(this);\n\t}\n\n\t/**\n\t * Update this subscription's options (e.g. priority), triggering a SUBSCRIBE_UPDATE to the\n\t * publisher. Mirrors the Rust `Subscriber::update`.\n\t */\n\tupdate(options: Subscription) {\n\t\tthis.#state.update.set(subscriptionDefaults(options));\n\t}\n}\n\n/**\n * A {@link Subscriber} that reads groups in sequence order.\n *\n * Created by {@link Subscriber.ordered}, which takes the subscription over: the two\n * cursors draw from one buffer, so a track is read one way or the other and never both.\n * Every group this returns has a higher sequence than the last, so a late arrival is\n * skipped rather than delivered out of turn.\n *\n * `maxAge` applies as this cursor reads, exactly as it does on the arrival cursor: a\n * group is skipped once its reach, where its immediate successor begins, is that far\n * behind the newest frame on the track. Nothing weaker convicts it, since the reach is\n * the only proof that every frame it could still hold is past the budget, so a backlog\n * inside the budget is still delivered whole, as a burst in order. The budget follows a\n * group already handed out too: a stalled group's pending frame read rejects once newer\n * content has pulled that far ahead.\n */\nexport class Ordered {\n\t/** The track name. */\n\treadonly name: string;\n\n\t#subscriber: Subscriber;\n\n\tprivate constructor(subscriber: Subscriber) {\n\t\tthis.name = subscriber.name;\n\t\tthis.#subscriber = subscriber;\n\t}\n\n\tstatic {\n\t\tmakeOrdered = (subscriber) => new Ordered(subscriber);\n\t}\n\n\t/** Resolve this track's immutable publisher properties; see {@link Subscriber.info}. */\n\tinfo(): Promise<Info> {\n\t\treturn this.#subscriber.info();\n\t}\n\n\t/** Settles once the track closes; see {@link Producer.closed}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#subscriber.closed;\n\t}\n\n\t/** This subscriber's current options, including defaults and the last {@link update}. */\n\tget subscription(): Getter<Subscription | undefined> {\n\t\treturn this.#subscriber.subscription;\n\t}\n\n\t/** The latest group sequence observed on this track, if any. */\n\tlatest(): number | undefined {\n\t\treturn this.#subscriber.latest();\n\t}\n\n\t/** The track's exclusive final boundary; see {@link Subscriber.final}. */\n\tfinal(): number | undefined {\n\t\treturn this.#subscriber.final();\n\t}\n\n\t/** Limit subsequent reads to these groups and return this reader for chaining. */\n\twithGroups(groups: Groups): this {\n\t\tthis.setGroups(groups);\n\t\treturn this;\n\t}\n\n\t/** Limit subsequent reads to these groups; see {@link Subscriber.setGroups}. */\n\tsetGroups(groups: Groups): void {\n\t\tthis.#subscriber.setGroups(groups);\n\t}\n\n\t/** Update this subscription's options; see {@link Subscriber.update}. */\n\tupdate(options: Subscription) {\n\t\tthis.#subscriber.update(options);\n\t}\n\n\t/** Close the track (optionally with an error), closing any pending groups. Idempotent. */\n\tclose(abort?: Error) {\n\t\tthis.#subscriber.close(abort);\n\t}\n\n\t/**\n\t * Return the next group with a strictly-greater sequence number than the last returned.\n\t *\n\t * Late arrivals (sequence at or below the last returned) are silently skipped, as is a\n\t * group whose every frame is further behind the live edge than `maxAge` (the default of\n\t * zero keeps only what nothing newer has superseded). Honors the bounds set by\n\t * {@link setGroups}.\n\t */\n\tnextGroup(): Promise<GroupConsumer | undefined> {\n\t\treturn ordered_.nextGroup(this.#subscriber);\n\t}\n\n\t/**\n\t * Read the next frame across groups, in sequence order, with its group and frame numbers.\n\t *\n\t * Rides the same cursor as {@link nextGroup} and shares this handle's contract: a\n\t * buffered backlog is drained in full up to the point `maxAge` proves it useless.\n\t * Treat the returned frame bytes as read-only; they are shared with other consumers.\n\t */\n\treadFrame(): Promise<({ group: number; frame: number } & Frame) | undefined> {\n\t\treturn ordered_.readFrame(this.#subscriber);\n\t}\n\n\t/** Read the next frame and decode it as a UTF-8 string. */\n\treadString(): Promise<string | undefined> {\n\t\treturn ordered_.readString(this.#subscriber);\n\t}\n\n\t/** Read the next frame and parse it as JSON. */\n\treadJson(): Promise<unknown | undefined> {\n\t\treturn ordered_.readJson(this.#subscriber);\n\t}\n\n\t/** Read the next frame and decode it as a one-byte boolean, throwing on a malformed frame. */\n\treadBool(): Promise<boolean | undefined> {\n\t\treturn ordered_.readBool(this.#subscriber);\n\t}\n\n\t/**\n\t * Receive the next datagram in arrival order.\n\t *\n\t * Datagrams are a separate best-effort channel from groups (see\n\t * {@link Producer.appendDatagram}); they share only the sequence namespace, and\n\t * neither cursor moves the other. Unordered by construction, so this behaves\n\t * identically on either handle; it is here so a track carrying both channels needs\n\t * one subscription rather than two.\n\t */\n\trecvDatagram(): Promise<Datagram | undefined> {\n\t\treturn ordered_.recvDatagram(this.#subscriber);\n\t}\n}\n"]}
|
package/util/log.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Renders a relay URL without user credentials, query parameters, or fragment. */
|
|
2
|
+
export declare function redact(url: URL): string;
|
|
3
|
+
/** Whether the consumer environment enables development diagnostics. */
|
|
4
|
+
export declare function dev(): boolean;
|
|
5
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/util/log.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAEvC;AAED,wEAAwE;AACxE,wBAAgB,GAAG,IAAI,OAAO,CAO7B"}
|
package/util/log.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* @ts-self-types="./log.d.ts" */
|
|
2
|
+
/** Renders a relay URL without user credentials, query parameters, or fragment. */
|
|
3
|
+
export function redact(url) {
|
|
4
|
+
return `${url.origin}${url.pathname}`;
|
|
5
|
+
}
|
|
6
|
+
/** Whether the consumer environment enables development diagnostics. */
|
|
7
|
+
export function dev() {
|
|
8
|
+
// Bundlers expose a boolean DEV; Bun exposes environment variables as strings.
|
|
9
|
+
// @ts-ignore - Some environments don't recognize import.meta.env
|
|
10
|
+
const env = import.meta.env;
|
|
11
|
+
if (typeof env === "undefined")
|
|
12
|
+
return false;
|
|
13
|
+
if (typeof env.DEV === "boolean")
|
|
14
|
+
return env.DEV;
|
|
15
|
+
return env.NODE_ENV !== "production" && env.MODE !== "production";
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=log.js.map
|
package/util/log.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/util/log.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,UAAU,MAAM,CAAC,GAAQ;IAC9B,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;AACvC,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,GAAG;IAClB,+EAA+E;IAC/E,iEAAiE;IACjE,MAAM,GAAG,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC;IAC5B,IAAI,OAAO,GAAG,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC,GAAG,CAAC;IACjD,OAAO,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC;AACnE,CAAC","sourcesContent":["/** Renders a relay URL without user credentials, query parameters, or fragment. */\nexport function redact(url: URL): string {\n\treturn `${url.origin}${url.pathname}`;\n}\n\n/** Whether the consumer environment enables development diagnostics. */\nexport function dev(): boolean {\n\t// Bundlers expose a boolean DEV; Bun exposes environment variables as strings.\n\t// @ts-ignore - Some environments don't recognize import.meta.env\n\tconst env = import.meta.env;\n\tif (typeof env === \"undefined\") return false;\n\tif (typeof env.DEV === \"boolean\") return env.DEV;\n\treturn env.NODE_ENV !== \"production\" && env.MODE !== \"production\";\n}\n"]}
|
package/wire.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-private capabilities used by the protocol implementations.
|
|
3
|
+
*
|
|
4
|
+
* Public handles register their wire view when they are constructed. Keeping the view in a
|
|
5
|
+
* WeakMap means applications cannot call transport-facing operations on the handles they own,
|
|
6
|
+
* while the protocol layers still share one implementation.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { Dispose, Getter } from "@moq/signals";
|
|
11
|
+
import type * as broadcast from "./broadcast";
|
|
12
|
+
import type { Consumer as GroupConsumer } from "./group";
|
|
13
|
+
import type { Route } from "./hop";
|
|
14
|
+
import type * as origin from "./origin";
|
|
15
|
+
import type * as Path from "./path";
|
|
16
|
+
import type * as track from "./track";
|
|
17
|
+
/** The protocol-facing operations behind a broadcast handle. */
|
|
18
|
+
export interface Broadcast {
|
|
19
|
+
subscribe(name: string, options?: track.Subscription): track.Subscriber;
|
|
20
|
+
resolveTrackInfo(name: string): Promise<track.Info>;
|
|
21
|
+
fetchGroup(name: string, sequence: number, options?: track.FetchGroupOptions): Promise<GroupConsumer>;
|
|
22
|
+
requested(): Promise<track.Request | undefined>;
|
|
23
|
+
}
|
|
24
|
+
/** The protocol-facing operations behind an origin producer. */
|
|
25
|
+
export interface OriginProducer {
|
|
26
|
+
receive(prefix: Path.Valid, route?: Route | {
|
|
27
|
+
hops?: Route["hops"];
|
|
28
|
+
cost?: Route["cost"] | bigint;
|
|
29
|
+
}): origin.Dynamic;
|
|
30
|
+
attach(discovery: boolean): Dispose;
|
|
31
|
+
expect(): Dispose;
|
|
32
|
+
readonly requests: Getter<ReadonlyMap<Path.Valid, origin.RequestSlot> | undefined>;
|
|
33
|
+
changed(): Promise<unknown>;
|
|
34
|
+
answer(path: Path.Valid, front: broadcast.Consumer): Dispose | undefined;
|
|
35
|
+
routes(path: Path.Valid): boolean;
|
|
36
|
+
}
|
|
37
|
+
/** The protocol-facing operations behind an origin consumer. */
|
|
38
|
+
export interface OriginConsumer {
|
|
39
|
+
routes(path: Path.Valid): boolean;
|
|
40
|
+
readonly broadcasts: Getter<ReadonlyMap<Path.Valid, broadcast.Consumer> | undefined>;
|
|
41
|
+
readonly advertised: Getter<ReadonlyMap<Path.Valid, Advertised> | undefined>;
|
|
42
|
+
demand(path: Path.Valid): Promise<broadcast.Consumer | undefined>;
|
|
43
|
+
}
|
|
44
|
+
/** One originated advertisement exposed to the publishing wire. */
|
|
45
|
+
export interface Advertised {
|
|
46
|
+
readonly identity: object;
|
|
47
|
+
readonly route: Route;
|
|
48
|
+
}
|
|
49
|
+
/** The protocol-facing operation behind an established session. */
|
|
50
|
+
export interface Established {
|
|
51
|
+
consume(path: Path.Valid): broadcast.Consumer;
|
|
52
|
+
}
|
|
53
|
+
type View = Broadcast | OriginProducer | OriginConsumer | Established;
|
|
54
|
+
/** Register the package-private view for a handle. */
|
|
55
|
+
export declare function registerWire(handle: object, view: View): void;
|
|
56
|
+
/** Replace selected operations on a broadcast's package-private view. */
|
|
57
|
+
export declare function overrideBroadcastWire(handle: broadcast.Consumer, overrides: Partial<Pick<Broadcast, "resolveTrackInfo" | "fetchGroup">>): void;
|
|
58
|
+
export declare function wireOf(handle: broadcast.Producer | broadcast.Consumer): Broadcast;
|
|
59
|
+
export declare function wireOf(handle: origin.Producer): OriginProducer;
|
|
60
|
+
export declare function wireOf(handle: origin.Consumer): OriginConsumer;
|
|
61
|
+
export declare function wireOf(handle: import("./connection/established.ts").Established): Established;
|
|
62
|
+
/** Install the private Track.Consumer constructor. */
|
|
63
|
+
export declare function registerTrackConsumer(factory: (name: string, source: Broadcast) => track.Consumer): void;
|
|
64
|
+
/** Create a track handle backed by a broadcast's private wire view. */
|
|
65
|
+
export declare function trackOf(name: string, source: broadcast.Producer | broadcast.Consumer): track.Consumer;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=wire.d.ts.map
|
package/wire.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC,gEAAgE;AAChE,MAAM,WAAW,SAAS;IACzB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,UAAU,CAAC;IACxE,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpD,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACtG,SAAS,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;CAChD;AAED,gEAAgE;AAChE,MAAM,WAAW,cAAc;IA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self-types="./wire.d.ts" */
|
|
2
|
+
const views = new WeakMap();
|
|
3
|
+
/** Register the package-private view for a handle. */
|
|
4
|
+
export function registerWire(handle, view) {
|
|
5
|
+
views.set(handle, view);
|
|
6
|
+
}
|
|
7
|
+
/** Replace selected operations on a broadcast's package-private view. */
|
|
8
|
+
export function overrideBroadcastWire(handle, overrides) {
|
|
9
|
+
const view = views.get(handle);
|
|
10
|
+
if (!view)
|
|
11
|
+
throw new Error("broadcast has no wire view");
|
|
12
|
+
views.set(handle, { ...view, ...overrides });
|
|
13
|
+
}
|
|
14
|
+
/** Return the package-private view for a handle. */
|
|
15
|
+
export function wireOf(handle) {
|
|
16
|
+
const view = views.get(handle);
|
|
17
|
+
if (!view)
|
|
18
|
+
throw new Error("handle has no wire view");
|
|
19
|
+
return view;
|
|
20
|
+
}
|
|
21
|
+
let makeTrack;
|
|
22
|
+
/** Install the private Track.Consumer constructor. */
|
|
23
|
+
export function registerTrackConsumer(factory) {
|
|
24
|
+
makeTrack = factory;
|
|
25
|
+
}
|
|
26
|
+
/** Create a track handle backed by a broadcast's private wire view. */
|
|
27
|
+
export function trackOf(name, source) {
|
|
28
|
+
if (!makeTrack)
|
|
29
|
+
throw new Error("track module is not loaded");
|
|
30
|
+
return makeTrack(name, wireOf(source));
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=wire.js.map
|
package/wire.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AA2DA,MAAM,KAAK,GAAG,IAAI,OAAO,EAAgB,CAAC;AAE1C,sDAAsD;AACtD,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,IAAU;IACtD,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,qBAAqB,CACpC,MAA0B,EAC1B,SAAsE;IAEtE,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACzD,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAI,IAAkB,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;AAC7D,CAAC;AAMD,oDAAoD;AACpD,MAAM,UAAU,MAAM,CAAC,MAAc;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,IAAI,SAA4E,CAAC;AAEjF,sDAAsD;AACtD,MAAM,UAAU,qBAAqB,CAAC,OAA4D;IACjG,SAAS,GAAG,OAAO,CAAC;AACrB,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,MAA+C;IACpF,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC9D,OAAO,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AACxC,CAAC","sourcesContent":["/**\n * Package-private capabilities used by the protocol implementations.\n *\n * Public handles register their wire view when they are constructed. Keeping the view in a\n * WeakMap means applications cannot call transport-facing operations on the handles they own,\n * while the protocol layers still share one implementation.\n *\n * @module\n */\nimport type { Dispose, Getter } from \"@moq/signals\";\nimport type * as broadcast from \"./broadcast.ts\";\nimport type { Consumer as GroupConsumer } from \"./group.ts\";\nimport type { Route } from \"./hop.ts\";\nimport type * as origin from \"./origin.ts\";\nimport type * as Path from \"./path.ts\";\nimport type * as track from \"./track.ts\";\n\n/** The protocol-facing operations behind a broadcast handle. */\nexport interface Broadcast {\n\tsubscribe(name: string, options?: track.Subscription): track.Subscriber;\n\tresolveTrackInfo(name: string): Promise<track.Info>;\n\tfetchGroup(name: string, sequence: number, options?: track.FetchGroupOptions): Promise<GroupConsumer>;\n\trequested(): Promise<track.Request | undefined>;\n}\n\n/** The protocol-facing operations behind an origin producer. */\nexport interface OriginProducer {\n\treceive(\n\t\tprefix: Path.Valid,\n\t\troute?: Route | { hops?: Route[\"hops\"]; cost?: Route[\"cost\"] | bigint },\n\t): origin.Dynamic;\n\tattach(discovery: boolean): Dispose;\n\texpect(): Dispose;\n\treadonly requests: Getter<ReadonlyMap<Path.Valid, origin.RequestSlot> | undefined>;\n\tchanged(): Promise<unknown>;\n\tanswer(path: Path.Valid, front: broadcast.Consumer): Dispose | undefined;\n\troutes(path: Path.Valid): boolean;\n}\n\n/** The protocol-facing operations behind an origin consumer. */\nexport interface OriginConsumer {\n\troutes(path: Path.Valid): boolean;\n\treadonly broadcasts: Getter<ReadonlyMap<Path.Valid, broadcast.Consumer> | undefined>;\n\treadonly advertised: Getter<ReadonlyMap<Path.Valid, Advertised> | undefined>;\n\tdemand(path: Path.Valid): Promise<broadcast.Consumer | undefined>;\n}\n\n/** One originated advertisement exposed to the publishing wire. */\nexport interface Advertised {\n\treadonly identity: object;\n\treadonly route: Route;\n}\n\n/** The protocol-facing operation behind an established session. */\nexport interface Established {\n\tconsume(path: Path.Valid): broadcast.Consumer;\n}\n\ntype View = Broadcast | OriginProducer | OriginConsumer | Established;\nconst views = new WeakMap<object, View>();\n\n/** Register the package-private view for a handle. */\nexport function registerWire(handle: object, view: View): void {\n\tviews.set(handle, view);\n}\n\n/** Replace selected operations on a broadcast's package-private view. */\nexport function overrideBroadcastWire(\n\thandle: broadcast.Consumer,\n\toverrides: Partial<Pick<Broadcast, \"resolveTrackInfo\" | \"fetchGroup\">>,\n): void {\n\tconst view = views.get(handle);\n\tif (!view) throw new Error(\"broadcast has no wire view\");\n\tviews.set(handle, { ...(view as Broadcast), ...overrides });\n}\n\nexport function wireOf(handle: broadcast.Producer | broadcast.Consumer): Broadcast;\nexport function wireOf(handle: origin.Producer): OriginProducer;\nexport function wireOf(handle: origin.Consumer): OriginConsumer;\nexport function wireOf(handle: import(\"./connection/established.ts\").Established): Established;\n/** Return the package-private view for a handle. */\nexport function wireOf(handle: object): View {\n\tconst view = views.get(handle);\n\tif (!view) throw new Error(\"handle has no wire view\");\n\treturn view;\n}\n\nlet makeTrack: ((name: string, source: Broadcast) => track.Consumer) | undefined;\n\n/** Install the private Track.Consumer constructor. */\nexport function registerTrackConsumer(factory: (name: string, source: Broadcast) => track.Consumer): void {\n\tmakeTrack = factory;\n}\n\n/** Create a track handle backed by a broadcast's private wire view. */\nexport function trackOf(name: string, source: broadcast.Producer | broadcast.Consumer): track.Consumer {\n\tif (!makeTrack) throw new Error(\"track module is not loaded\");\n\treturn makeTrack(name, wireOf(source));\n}\n"]}
|
package/zod.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type * as z from "@zod/mini";
|
|
|
7
7
|
import type * as group from "./group";
|
|
8
8
|
import type * as track from "./track";
|
|
9
9
|
/** Read the next JSON frame and validate it against the schema. Returns undefined at end of stream. */
|
|
10
|
-
export declare function read<T = unknown>(source: track.
|
|
10
|
+
export declare function read<T = unknown>(source: track.Ordered | group.Consumer, schema: z.ZodMiniType<T>): Promise<T | undefined>;
|
|
11
11
|
/** Validate a value against the schema, then write it as a JSON frame. */
|
|
12
12
|
export declare function write<T = unknown>(source: track.Producer | group.Producer, value: T, schema: z.ZodMiniType<T>): void;
|
|
13
13
|
//# sourceMappingURL=zod.d.ts.map
|
package/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,CAAC,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC,uGAAuG;AACvG,wBAAsB,IAAI,CAAC,CAAC,GAAG,OAAO,EACrC,MAAM,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,CAAC,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC,uGAAuG;AACvG,wBAAsB,IAAI,CAAC,CAAC,GAAG,OAAO,EACrC,MAAM,EAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,EACtC,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GACtB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAIxB;AAED,0EAA0E;AAC1E,wBAAgB,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAG7G"}
|
package/zod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,uGAAuG;AACvG,MAAM,CAAC,KAAK,UAAU,IAAI,CACzB,
|
|
1
|
+
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,uGAAuG;AACvG,MAAM,CAAC,KAAK,UAAU,IAAI,CACzB,MAAsC,EACtC,MAAwB;IAExB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;IACrC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC,CAAC,sDAAsD;IAChG,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,KAAK,CAAc,MAAuC,EAAE,KAAQ,EAAE,MAAwB;IAC7G,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Helpers for reading and writing Zod-validated JSON frames on a track or group.\n *\n * @module\n */\n\nimport type * as z from \"@zod/mini\";\nimport type * as group from \"./group.ts\";\nimport type * as track from \"./track.ts\";\n\n/** Read the next JSON frame and validate it against the schema. Returns undefined at end of stream. */\nexport async function read<T = unknown>(\n\tsource: track.Ordered | group.Consumer,\n\tschema: z.ZodMiniType<T>,\n): Promise<T | undefined> {\n\tconst next = await source.readJson();\n\tif (next === undefined) return undefined; // only treat undefined as EOF, not other falsy values\n\treturn schema.parse(next);\n}\n\n/** Validate a value against the schema, then write it as a JSON frame. */\nexport function write<T = unknown>(source: track.Producer | group.Producer, value: T, schema: z.ZodMiniType<T>) {\n\tconst valid = schema.parse(value);\n\tsource.writeJson(valid);\n}\n"]}
|