@moq/net 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/broadcast.d.ts.map +1 -1
  2. package/broadcast.js +3 -2
  3. package/broadcast.js.map +1 -1
  4. package/connection/accept.d.ts.map +1 -1
  5. package/connection/accept.js +3 -0
  6. package/connection/accept.js.map +1 -1
  7. package/connection/browser.d.ts.map +1 -1
  8. package/connection/browser.js +3 -0
  9. package/connection/browser.js.map +1 -1
  10. package/connection/connect.d.ts.map +1 -1
  11. package/connection/connect.js +11 -7
  12. package/connection/connect.js.map +1 -1
  13. package/group.d.ts +19 -1
  14. package/group.d.ts.map +1 -1
  15. package/group.js +35 -11
  16. package/group.js.map +1 -1
  17. package/ietf/adapter.d.ts.map +1 -1
  18. package/ietf/adapter.js +76 -45
  19. package/ietf/adapter.js.map +1 -1
  20. package/ietf/aliases.d.ts +73 -5
  21. package/ietf/aliases.d.ts.map +1 -1
  22. package/ietf/aliases.js +121 -14
  23. package/ietf/aliases.js.map +1 -1
  24. package/ietf/fetch.d.ts +17 -0
  25. package/ietf/fetch.d.ts.map +1 -1
  26. package/ietf/fetch.js +21 -0
  27. package/ietf/fetch.js.map +1 -1
  28. package/ietf/filter.d.ts +87 -0
  29. package/ietf/filter.d.ts.map +1 -0
  30. package/ietf/filter.js +292 -0
  31. package/ietf/filter.js.map +1 -0
  32. package/ietf/namespace.d.ts +6 -0
  33. package/ietf/namespace.d.ts.map +1 -1
  34. package/ietf/namespace.js +27 -2
  35. package/ietf/namespace.js.map +1 -1
  36. package/ietf/object.d.ts +44 -2
  37. package/ietf/object.d.ts.map +1 -1
  38. package/ietf/object.js +74 -9
  39. package/ietf/object.js.map +1 -1
  40. package/ietf/parameters.d.ts +16 -4
  41. package/ietf/parameters.d.ts.map +1 -1
  42. package/ietf/parameters.js +54 -10
  43. package/ietf/parameters.js.map +1 -1
  44. package/ietf/properties.d.ts +5 -0
  45. package/ietf/properties.d.ts.map +1 -1
  46. package/ietf/properties.js +5 -0
  47. package/ietf/properties.js.map +1 -1
  48. package/ietf/publisher.d.ts.map +1 -1
  49. package/ietf/publisher.js +375 -27
  50. package/ietf/publisher.js.map +1 -1
  51. package/ietf/subscribe.d.ts +38 -7
  52. package/ietf/subscribe.d.ts.map +1 -1
  53. package/ietf/subscribe.js +94 -29
  54. package/ietf/subscribe.js.map +1 -1
  55. package/ietf/subscriber.d.ts.map +1 -1
  56. package/ietf/subscriber.js +148 -35
  57. package/ietf/subscriber.js.map +1 -1
  58. package/ietf/version.d.ts +7 -1
  59. package/ietf/version.d.ts.map +1 -1
  60. package/ietf/version.js +7 -0
  61. package/ietf/version.js.map +1 -1
  62. package/internal.d.ts +16 -1
  63. package/internal.d.ts.map +1 -1
  64. package/internal.js.map +1 -1
  65. package/lite/announce.d.ts.map +1 -1
  66. package/lite/announce.js +7 -7
  67. package/lite/announce.js.map +1 -1
  68. package/lite/publisher.d.ts.map +1 -1
  69. package/lite/publisher.js +4 -2
  70. package/lite/publisher.js.map +1 -1
  71. package/lite/setup.d.ts.map +1 -1
  72. package/lite/setup.js +2 -1
  73. package/lite/setup.js.map +1 -1
  74. package/lite/subscriber.d.ts +1 -6
  75. package/lite/subscriber.d.ts.map +1 -1
  76. package/lite/subscriber.js +98 -23
  77. package/lite/subscriber.js.map +1 -1
  78. package/lite/version.d.ts +4 -0
  79. package/lite/version.d.ts.map +1 -1
  80. package/lite/version.js +15 -0
  81. package/lite/version.js.map +1 -1
  82. package/origin.d.ts +1 -1
  83. package/origin.d.ts.map +1 -1
  84. package/origin.js +1 -1
  85. package/origin.js.map +1 -1
  86. package/package.json +4 -3
  87. package/stream.d.ts.map +1 -1
  88. package/stream.js +3 -5
  89. package/stream.js.map +1 -1
  90. package/track.d.ts +38 -0
  91. package/track.d.ts.map +1 -1
  92. package/track.js +104 -25
  93. package/track.js.map +1 -1
  94. package/util/utf8.d.ts +3 -0
  95. package/util/utf8.d.ts.map +1 -0
  96. package/util/utf8.js +7 -0
  97. package/util/utf8.js.map +1 -0
  98. package/zod.d.ts +1 -1
  99. package/zod.d.ts.map +1 -1
  100. package/zod.js.map +1 -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;AAE1E,OAAO,EAA8C,QAAQ,IAAI,aAAa,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC3G,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAItD,iGAAiG;AACjG,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAK/B;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,KAAK,CAAC;AA+BjC,iEAAiE;AACjE,MAAM,UAAU,YAAY,CAAC,IAAI,GAAkB,EAAE;IACpD,OAAO;QACN,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK;QAC5C,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,sBAAsB;QACrD,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC;QAC5B,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,KAAK;KAC9B,CAAC;AACH,CAAC;AAmBD,oFAAoF;AACpF,sEAAsE;AACtE,SAAS,oBAAoB,CAAC,YAAY,GAAiB,EAAE;IAC5D,OAAO;QACN,QAAQ,EAAE,YAAY,CAAC,QAAQ,IAAI,CAAC;QACpC,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,KAAK;QACtC,UAAU,EAAE,YAAY,CAAC,UAAU,IAAI,CAAC;QACxC,UAAU,EAAE,YAAY,CAAC,UAAU;QACnC,QAAQ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AI;YAAE,OAAO,SAAS,CAAC;QAC5B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,kDAAkD;IAClD,KAAK,CAAC,QAAQ;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,gGAAgG;IAChG,KAAK,CAAC,QAAQ;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,OAAO,CAAC,UAAU,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,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 } 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/**\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\n\tprivate constructor(name: string, producer: Producer) {\n\t\tthis.name = name;\n\t\tthis.#producer = producer;\n\t}\n\n\tstatic {\n\t\thooks.makeRequest = (name, producer) => new Request(name, producer);\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\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\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\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\n\t#next?: number;\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\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\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 group = new GroupProducer(this.#next ?? 0);\n\t\tthis.#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 #next upward (for appendGroup auto-increment).\n\t\tif (group.sequence >= (this.#next ?? 0)) {\n\t\t\tthis.#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 sequence = this.#next ?? 0;\n\t\tthis.#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\tif (datagram.sequence >= (this.#next ?? 0)) {\n\t\t\tthis.#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/** 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 groups = this.#state.groups.peek();\n\t\t\tconst { start, end } = this.#cursor.peek();\n\t\t\twhile (groups.length > 0 && groups[0].sequence < start) groups.shift()?.close();\n\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)) {\n\t\t\t\tgroups.shift();\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\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 && !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 * 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,EAAgC,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAA8C,QAAQ,IAAI,aAAa,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC3G,OAAO,EAAE,KAAK,EAAqE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAItD,iGAAiG;AACjG,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;;;;GAMG;AAC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AAM,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"]}
package/util/utf8.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Decode a protocol string, rejecting bytes that are not valid UTF-8. */
2
+ export declare function decodeUtf8(buffer: Uint8Array): string;
3
+ //# sourceMappingURL=utf8.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utf8.d.ts","sourceRoot":"","sources":["../../src/util/utf8.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAErD"}
package/util/utf8.js ADDED
@@ -0,0 +1,7 @@
1
+ /* @ts-self-types="./utf8.d.ts" */
2
+ const decoder = new TextDecoder("utf-8", { fatal: true });
3
+ /** Decode a protocol string, rejecting bytes that are not valid UTF-8. */
4
+ export function decodeUtf8(buffer) {
5
+ return decoder.decode(buffer);
6
+ }
7
+ //# sourceMappingURL=utf8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utf8.js","sourceRoot":"","sources":["../../src/util/utf8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAE1D,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,MAAkB;IAC5C,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["const decoder = new TextDecoder(\"utf-8\", { fatal: true });\n\n/** Decode a protocol string, rejecting bytes that are not valid UTF-8. */\nexport function decodeUtf8(buffer: Uint8Array): string {\n\treturn decoder.decode(buffer);\n}\n"]}
package/zod.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import type * as z from "zod/mini";
6
+ 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. */
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,UAAU,CAAC;AACnC,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,UAAU,GAAG,KAAK,CAAC,QAAQ,EACzC,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"}
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,UAAU,GAAG,KAAK,CAAC,QAAQ,EACzC,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,MAAyC,EACzC,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.Subscriber | 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"]}
1
+ {"version":3,"file":"zod.js","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,uGAAuG;AACvG,MAAM,CAAC,KAAK,UAAU,IAAI,CACzB,MAAyC,EACzC,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.Subscriber | 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"]}