@moq/net 0.1.3 → 0.1.5

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 (147) hide show
  1. package/announced.d.ts +4 -0
  2. package/announced.d.ts.map +1 -1
  3. package/announced.js +5 -0
  4. package/announced.js.map +1 -1
  5. package/bandwidth.js +1 -0
  6. package/broadcast.d.ts +5 -1
  7. package/broadcast.d.ts.map +1 -1
  8. package/broadcast.js +4 -0
  9. package/broadcast.js.map +1 -1
  10. package/connection/accept.d.ts +2 -1
  11. package/connection/accept.d.ts.map +1 -1
  12. package/connection/accept.js +1 -0
  13. package/connection/accept.js.map +1 -1
  14. package/connection/cert.test.d.ts +2 -0
  15. package/connection/cert.test.d.ts.map +1 -0
  16. package/connection/cert.test.js +26 -0
  17. package/connection/cert.test.js.map +1 -0
  18. package/connection/connect.d.ts +20 -2
  19. package/connection/connect.d.ts.map +1 -1
  20. package/connection/connect.js +50 -8
  21. package/connection/connect.js.map +1 -1
  22. package/connection/established.d.ts +13 -5
  23. package/connection/established.d.ts.map +1 -1
  24. package/connection/established.js +1 -0
  25. package/connection/established.js.map +1 -1
  26. package/connection/handshake.d.ts +2 -2
  27. package/connection/handshake.js +1 -0
  28. package/connection/index.d.ts +4 -4
  29. package/connection/index.js +1 -0
  30. package/connection/reload.d.ts +19 -4
  31. package/connection/reload.d.ts.map +1 -1
  32. package/connection/reload.js +13 -4
  33. package/connection/reload.js.map +1 -1
  34. package/group.d.ts +13 -0
  35. package/group.d.ts.map +1 -1
  36. package/group.js +14 -0
  37. package/group.js.map +1 -1
  38. package/ietf/adapter.d.ts +2 -2
  39. package/ietf/adapter.js +1 -0
  40. package/ietf/connection.d.ts +6 -6
  41. package/ietf/connection.js +1 -0
  42. package/ietf/control.d.ts +11 -11
  43. package/ietf/control.js +1 -0
  44. package/ietf/fetch.d.ts +3 -3
  45. package/ietf/fetch.js +1 -0
  46. package/ietf/goaway.d.ts +2 -2
  47. package/ietf/goaway.js +1 -0
  48. package/ietf/ietf.test.js +1 -0
  49. package/ietf/index.d.ts +17 -17
  50. package/ietf/index.js +1 -0
  51. package/ietf/message.d.ts +1 -1
  52. package/ietf/message.js +1 -0
  53. package/ietf/namespace.d.ts +2 -2
  54. package/ietf/namespace.js +1 -0
  55. package/ietf/object.d.ts +2 -2
  56. package/ietf/object.js +1 -0
  57. package/ietf/parameters.d.ts +2 -2
  58. package/ietf/parameters.js +1 -0
  59. package/ietf/properties.d.ts +2 -2
  60. package/ietf/properties.js +1 -0
  61. package/ietf/publish.d.ts +3 -3
  62. package/ietf/publish.js +1 -0
  63. package/ietf/publish_namespace.d.ts +3 -3
  64. package/ietf/publish_namespace.js +1 -0
  65. package/ietf/publisher.d.ts +7 -7
  66. package/ietf/publisher.js +1 -0
  67. package/ietf/request.d.ts +3 -3
  68. package/ietf/request.js +1 -0
  69. package/ietf/setup.d.ts +3 -3
  70. package/ietf/setup.js +1 -0
  71. package/ietf/subscribe.d.ts +3 -3
  72. package/ietf/subscribe.js +1 -0
  73. package/ietf/subscribe_namespace.d.ts +3 -3
  74. package/ietf/subscribe_namespace.js +1 -0
  75. package/ietf/subscriber.d.ts +8 -8
  76. package/ietf/subscriber.js +1 -0
  77. package/ietf/track.d.ts +3 -3
  78. package/ietf/track.js +1 -0
  79. package/ietf/version.js +1 -0
  80. package/index.d.ts +20 -9
  81. package/index.d.ts.map +1 -1
  82. package/index.js +7 -0
  83. package/index.js.map +1 -1
  84. package/integration.test.js +1 -0
  85. package/lite/announce.d.ts +4 -4
  86. package/lite/announce.js +1 -0
  87. package/lite/connection.d.ts +9 -9
  88. package/lite/connection.js +1 -0
  89. package/lite/fetch.d.ts +3 -3
  90. package/lite/fetch.js +1 -0
  91. package/lite/goaway.d.ts +2 -2
  92. package/lite/goaway.js +1 -0
  93. package/lite/group.d.ts +1 -1
  94. package/lite/group.js +1 -0
  95. package/lite/index.d.ts +10 -10
  96. package/lite/index.js +1 -0
  97. package/lite/message.d.ts +1 -1
  98. package/lite/message.js +1 -0
  99. package/lite/origin.js +1 -0
  100. package/lite/probe.d.ts +2 -2
  101. package/lite/probe.js +1 -0
  102. package/lite/publisher.d.ts +7 -7
  103. package/lite/publisher.js +1 -0
  104. package/lite/session.d.ts +2 -2
  105. package/lite/session.js +1 -0
  106. package/lite/stream.d.ts +5 -5
  107. package/lite/stream.js +1 -0
  108. package/lite/subscribe.d.ts +3 -3
  109. package/lite/subscribe.js +1 -0
  110. package/lite/subscriber.d.ts +9 -9
  111. package/lite/subscriber.js +1 -0
  112. package/lite/version.js +1 -0
  113. package/mock.js +1 -0
  114. package/package.json +2 -2
  115. package/path.d.ts +2 -0
  116. package/path.d.ts.map +1 -1
  117. package/path.js +3 -0
  118. package/path.js.map +1 -1
  119. package/path.test.js +1 -0
  120. package/stream.d.ts +1 -1
  121. package/stream.js +1 -0
  122. package/stream.test.js +1 -0
  123. package/time.d.ts +8 -0
  124. package/time.d.ts.map +1 -1
  125. package/time.js +5 -0
  126. package/time.js.map +1 -1
  127. package/track.d.ts +14 -1
  128. package/track.d.ts.map +1 -1
  129. package/track.js +14 -1
  130. package/track.js.map +1 -1
  131. package/track.test.js +1 -0
  132. package/util/error.js +1 -0
  133. package/util/hex.d.ts +1 -0
  134. package/util/hex.d.ts.map +1 -1
  135. package/util/hex.js +4 -0
  136. package/util/hex.js.map +1 -1
  137. package/util/index.d.ts +1 -1
  138. package/util/index.js +1 -0
  139. package/varint.d.ts +8 -0
  140. package/varint.d.ts.map +1 -1
  141. package/varint.js +9 -0
  142. package/varint.js.map +1 -1
  143. package/varint.test.js +1 -0
  144. package/zod.d.ts +9 -2
  145. package/zod.d.ts.map +1 -1
  146. package/zod.js +8 -1
  147. package/zod.js.map +1 -1
@@ -1,5 +1,5 @@
1
- import * as Ietf from "../ietf/index.ts";
2
- import { Stream } from "../stream.ts";
1
+ import * as Ietf from "../ietf/index";
2
+ import { Stream } from "../stream";
3
3
  /**
4
4
  * Draft-17+ SETUP exchange. Each side opens a uni stream, writes its Setup
5
5
  * message, and reads the peer's Setup off an incoming uni stream. The two
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./handshake.d.ts" */
1
2
  import * as Ietf from "../ietf/index.js";
2
3
  import { Reader, Stream, Writer } from "../stream.js";
3
4
  /**
@@ -1,5 +1,5 @@
1
- export * from "./accept.ts";
2
- export * from "./connect.ts";
3
- export * from "./established.ts";
4
- export * from "./reload.ts";
1
+ export * from "./accept";
2
+ export * from "./connect";
3
+ export * from "./established";
4
+ export * from "./reload";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./index.d.ts" */
1
2
  export * from "./accept.js";
2
3
  export * from "./connect.js";
3
4
  export * from "./established.js";
@@ -1,32 +1,47 @@
1
1
  import { Effect, type Getter, Signal } from "@moq/signals";
2
- import type * as Path from "../path.ts";
3
- import { type ConnectProps, type WebSocketOptions } from "./connect.ts";
4
- import type { Established } from "./established.ts";
2
+ import type * as Path from "../path";
3
+ import { type ConnectProps, type WebSocketOptions, type WebTransportProps } from "./connect";
4
+ import type { Established } from "./established";
5
+ /** Exponential backoff settings for {@link Reload}'s reconnect loop. */
5
6
  export type ReloadDelay = {
6
7
  initial: DOMHighResTimeStamp;
7
8
  multiplier: number;
8
9
  max: DOMHighResTimeStamp;
9
10
  timeout?: DOMHighResTimeStamp;
10
11
  };
12
+ /** Options for {@link Reload}: connect options plus reactive URL/enabled signals and backoff tuning. */
11
13
  export type ReloadProps = ConnectProps & {
12
14
  enabled?: boolean | Signal<boolean>;
13
15
  url?: URL | Signal<URL | undefined>;
14
16
  delay?: ReloadDelay;
15
17
  };
18
+ /** Current state of a {@link Reload} connection. */
16
19
  export type ReloadStatus = "connecting" | "connected" | "disconnected";
20
+ /** Maintains a MoQ connection, reconnecting with exponential backoff when it drops. */
17
21
  export declare class Reload {
18
22
  #private;
23
+ /** Relay URL to connect to; updating it triggers a reconnect. */
19
24
  url: Signal<URL | undefined>;
25
+ /** Whether reconnecting is active. */
20
26
  enabled: Signal<boolean>;
27
+ /** Current connection status. */
21
28
  status: Signal<ReloadStatus>;
29
+ /** The currently established session, or undefined while disconnected. */
22
30
  established: Signal<Established | undefined>;
31
+ /** The set of broadcast paths currently announced by the server, updated reactively. */
23
32
  readonly announced: Getter<Set<Path.Valid>>;
24
- webtransport?: WebTransportOptions;
33
+ /** WebTransport options applied to each connection attempt (not reactive). */
34
+ webtransport?: WebTransportProps;
35
+ /** WebSocket fallback options applied to each connection attempt (not reactive). */
25
36
  websocket: WebSocketOptions | undefined;
37
+ /** Backoff settings for the reconnect loop. */
26
38
  delay: ReloadDelay;
39
+ /** The reactive effect scope driving the connect loop; closed by {@link Reload.close}. */
27
40
  signals: Effect;
41
+ /** Resolves when the reconnect loop stops via {@link Reload.close} or the retry timeout. */
28
42
  closed: Promise<void>;
29
43
  constructor(props?: ReloadProps);
44
+ /** Stop reconnecting, close the current connection, and resolve {@link Reload.closed}. */
30
45
  close(): void;
31
46
  }
32
47
  //# sourceMappingURL=reload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reload.d.ts","sourceRoot":"","sources":["../../src/connection/reload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,KAAK,IAAI,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,KAAK,YAAY,EAAW,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,MAAM,WAAW,GAAG;IAGzB,OAAO,EAAE,mBAAmB,CAAC;IAI7B,UAAU,EAAE,MAAM,CAAC;IAInB,GAAG,EAAE,mBAAmB,CAAC;IAKzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG;IAGxC,OAAO,CAAC,EAAE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B,CAAC;IAKzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAEF,wGAAwG;AACxG,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG;IAGxC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAGpC,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;IAGpC,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,CAAC;AAEvE,uFAAuF;AACvF,qBAAa,MAAM;;IAClB,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;IAE7B,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAEzB,iCAAiC;IACjC,MAAM,uBAA4C;IAElD,0EAA0E;IAC1E,WAAW,kCAAkD;IAK7D,wFAAwF;IACxF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAmB;IAE9D,8EAA8E;IAC9E,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAEjC,oFAAoF;IACpF,SAAS,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAExC,+CAA+C;IAC/C,KAAK,EAAE,WAAW,CAAC;IAEnB,0FAA0F;IAC1F,OAAO,SAAgB;IAEvB,4FAA4F;IAC5F,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBAYV,KAAK,CAAC,EAAE,WAAW;IAiH/B,0FAA0F;IAC1F,KAAK;CAIL"}
@@ -1,22 +1,30 @@
1
+ /* @ts-self-types="./reload.d.ts" */
1
2
  import { Effect, Signal } from "@moq/signals";
2
3
  import { empty as emptyPath } from "../path.js";
3
4
  import { connect } from "./connect.js";
5
+ /** Maintains a MoQ connection, reconnecting with exponential backoff when it drops. */
4
6
  export class Reload {
7
+ /** Relay URL to connect to; updating it triggers a reconnect. */
5
8
  url;
9
+ /** Whether reconnecting is active. */
6
10
  enabled;
11
+ /** Current connection status. */
7
12
  status = new Signal("disconnected");
13
+ /** The currently established session, or undefined while disconnected. */
8
14
  established = new Signal(undefined);
9
15
  // All actively announced broadcast paths, updated reactively.
10
16
  #announced = new Signal(new Set());
17
+ /** The set of broadcast paths currently announced by the server, updated reactively. */
11
18
  announced = this.#announced;
12
- // WebTransport options (not reactive).
19
+ /** WebTransport options applied to each connection attempt (not reactive). */
13
20
  webtransport;
14
- // WebSocket (fallback) options (not reactive).
21
+ /** WebSocket fallback options applied to each connection attempt (not reactive). */
15
22
  websocket;
16
- // Not reactive, but can be updated.
23
+ /** Backoff settings for the reconnect loop. */
17
24
  delay;
25
+ /** The reactive effect scope driving the connect loop; closed by {@link Reload.close}. */
18
26
  signals = new Effect();
19
- // Resolves when the reconnect loop stops (close() or timeout).
27
+ /** Resolves when the reconnect loop stops via {@link Reload.close} or the retry timeout. */
20
28
  closed;
21
29
  #closedResolve;
22
30
  #closedReject;
@@ -120,6 +128,7 @@ export class Reload {
120
128
  }
121
129
  });
122
130
  }
131
+ /** Stop reconnecting, close the current connection, and resolve {@link Reload.closed}. */
123
132
  close() {
124
133
  this.signals.close();
125
134
  this.#closedResolve();
@@ -1 +1 @@
1
- {"version":3,"file":"reload.js","sourceRoot":"","sources":["../../src/connection/reload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAqB,OAAO,EAAyB,MAAM,cAAc,CAAC;AAoCjF,MAAM,OAAO,MAAM;IAClB,GAAG,CAA0B;IAC7B,OAAO,CAAkB;IAEzB,MAAM,GAAG,IAAI,MAAM,CAAe,cAAc,CAAC,CAAC;IAClD,WAA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AAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;wBACjC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;4BAClB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;wBACxB,CAAC;6BAAM,CAAC;4BACP,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;wBAC3B,CAAC;oBACF,CAAC,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC/B,MAAM,GAAG,CAAC;YACX,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,cAAc,EAAE,CAAC;IACvB,CAAC;CACD","sourcesContent":["import { Effect, type Getter, Signal } from \"@moq/signals\";\nimport type * as Path from \"../path.ts\";\nimport { empty as emptyPath } from \"../path.ts\";\nimport { type ConnectProps, connect, type WebSocketOptions } from \"./connect.ts\";\nimport type { Established } from \"./established.ts\";\n\nexport type ReloadDelay = {\n\t// The delay in milliseconds before reconnecting.\n\t// default: 1000\n\tinitial: DOMHighResTimeStamp;\n\n\t// The multiplier for the delay.\n\t// default: 2\n\tmultiplier: number;\n\n\t// The maximum delay in milliseconds.\n\t// default: 30000\n\tmax: DOMHighResTimeStamp;\n\n\t// Maximum total time in milliseconds to spend retrying before giving up.\n\t// Resets after each successful connection. Set to 0 for unlimited retries.\n\t// default: 300000 (5 minutes)\n\ttimeout?: DOMHighResTimeStamp;\n};\n\nexport type ReloadProps = ConnectProps & {\n\t// Whether to reload the connection when it disconnects.\n\t// default: true\n\tenabled?: boolean | Signal<boolean>;\n\n\t// The URL of the relay server.\n\turl?: URL | Signal<URL | undefined>;\n\n\t// The delay for the reload.\n\tdelay?: ReloadDelay;\n};\n\nexport type ReloadStatus = \"connecting\" | \"connected\" | \"disconnected\";\n\nexport class Reload {\n\turl: Signal<URL | undefined>;\n\tenabled: Signal<boolean>;\n\n\tstatus = new Signal<ReloadStatus>(\"disconnected\");\n\testablished = new Signal<Established | undefined>(undefined);\n\n\t// All actively announced broadcast paths, updated reactively.\n\t#announced = new Signal<Set<Path.Valid>>(new Set());\n\treadonly announced: Getter<Set<Path.Valid>> = this.#announced;\n\n\t// WebTransport options (not reactive).\n\twebtransport?: WebTransportOptions;\n\n\t// WebSocket (fallback) options (not reactive).\n\twebsocket: WebSocketOptions | undefined;\n\n\t// Not reactive, but can be updated.\n\tdelay: ReloadDelay;\n\n\tsignals = new Effect();\n\n\t// Resolves when the reconnect loop stops (close() or timeout).\n\tclosed: Promise<void>;\n\t#closedResolve!: () => void;\n\t#closedReject!: (err: Error) => void;\n\n\t#delay: DOMHighResTimeStamp;\n\n\t// Timestamp when the current retry sequence started (for timeout).\n\t#retryStart: DOMHighResTimeStamp | undefined;\n\n\t// Increased by 1 each time to trigger a reload.\n\t#tick = new Signal(0);\n\n\tconstructor(props?: ReloadProps) {\n\t\tthis.url = Signal.from(props?.url);\n\t\tthis.enabled = Signal.from(props?.enabled ?? false);\n\t\tthis.delay = props?.delay ?? { initial: 1000, multiplier: 2, max: 30000 };\n\t\tthis.webtransport = props?.webtransport;\n\t\tthis.websocket = props?.websocket;\n\n\t\tthis.#delay = this.delay.initial;\n\n\t\tthis.closed = new Promise((resolve, reject) => {\n\t\t\tthis.#closedResolve = resolve;\n\t\t\tthis.#closedReject = reject;\n\t\t});\n\n\t\t// Create a reactive root so cleanup is easier.\n\t\tthis.signals.run(this.#connect.bind(this));\n\t\tthis.signals.run(this.#runAnnounced.bind(this));\n\t}\n\n\t#connect(effect: Effect): void {\n\t\t// Will retry when the tick changes.\n\t\teffect.get(this.#tick);\n\n\t\tconst enabled = effect.get(this.enabled);\n\t\tif (!enabled) return;\n\n\t\tconst url = effect.get(this.url);\n\t\tif (!url) return;\n\n\t\teffect.set(this.status, \"connecting\", \"disconnected\");\n\n\t\teffect.spawn(async () => {\n\t\t\ttry {\n\t\t\t\tconst pending = connect(url, { websocket: this.websocket, webtransport: this.webtransport });\n\n\t\t\t\tconst connection = await Promise.race([effect.cancel, pending]);\n\t\t\t\tif (!connection) {\n\t\t\t\t\tpending.then((conn) => conn.close()).catch(() => {});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\teffect.set(this.established, connection);\n\t\t\t\teffect.cleanup(() => connection.close());\n\n\t\t\t\teffect.set(this.status, \"connected\", \"disconnected\");\n\n\t\t\t\t// Reset the exponential backoff and timeout on success.\n\t\t\t\tthis.#delay = this.delay.initial;\n\t\t\t\tthis.#retryStart = undefined;\n\n\t\t\t\tawait Promise.race([effect.cancel, connection.closed]);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.warn(\"connection error:\", err);\n\n\t\t\t\t// Track retry start for timeout.\n\t\t\t\tthis.#retryStart ??= performance.now();\n\n\t\t\t\tconst timeout = this.delay.timeout ?? 300000;\n\t\t\t\tif (timeout > 0) {\n\t\t\t\t\tconst elapsed = performance.now() - this.#retryStart;\n\t\t\t\t\tif (elapsed >= timeout) {\n\t\t\t\t\t\tconsole.warn(\"reconnect timed out\");\n\t\t\t\t\t\tthis.#closedReject(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst tick = this.#tick.peek() + 1;\n\t\t\t\teffect.timer(() => this.#tick.update((prev) => Math.max(prev, tick)), this.#delay);\n\n\t\t\t\tthis.#delay = Math.min(this.#delay * this.delay.multiplier, this.delay.max);\n\t\t\t}\n\t\t});\n\t}\n\n\t#runAnnounced(effect: Effect): void {\n\t\tthis.#announced.set(new Set());\n\n\t\tconst conn = effect.get(this.established);\n\t\tif (!conn) return;\n\n\t\teffect.cleanup(() => this.#announced.set(new Set()));\n\n\t\t// Cloudflare's relay does not yet support SUBSCRIBE_NAMESPACE, so\n\t\t// skip announce subscriptions entirely for those hosts.\n\t\tif (conn.url.hostname.endsWith(\"mediaoverquic.com\")) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst announced = conn.announced(emptyPath());\n\t\teffect.cleanup(() => announced.close());\n\n\t\teffect.spawn(async () => {\n\t\t\ttry {\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst entry = await Promise.race([effect.cancel, announced.next()]);\n\t\t\t\t\tif (!entry) break;\n\n\t\t\t\t\tthis.#announced.mutate((active) => {\n\t\t\t\t\t\tif (entry.active) {\n\t\t\t\t\t\t\tactive.add(entry.path);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tactive.delete(entry.path);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tthis.#announced.set(new Set());\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t});\n\t}\n\n\tclose() {\n\t\tthis.signals.close();\n\t\tthis.#closedResolve();\n\t}\n}\n"]}
1
+ {"version":3,"file":"reload.js","sourceRoot":"","sources":["../../src/connection/reload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAqB,OAAO,EAAiD,MAAM,cAAc,CAAC;AAuCzG,uFAAuF;AACvF,MAAM,OAAO,MAAM;IAClB,iEAAiE;IACjE,GAAG,CAA0B;IAE7B,sCAAsC;IACtC,OAAO,CAAkB;IAEzB,iCAAiC;IACjC,MAAM,GAAG,IAAI,MAAM,CAAe,cAAc,CAAC,CAAC;IAElD,0EAA0E;IAC1E,WAAW,GAAG,IAAI,MAAM,CAA0B,SAAS,CAAC,CAAC;IAE7D,8DAA8D;IAC9D,UAAU,GAAG,IAAI,MAAM,CAAkB,IAAI,GAAG,EAAE,CAAC,CAAC;IAEpD,wF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B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;wBACxB,CAAC;6BAAM,CAAC;4BACP,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;wBAC3B,CAAC;oBACF,CAAC,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC/B,MAAM,GAAG,CAAC;YACX,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,0FAA0F;IAC1F,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,cAAc,EAAE,CAAC;IACvB,CAAC;CACD","sourcesContent":["import { Effect, type Getter, Signal } from \"@moq/signals\";\nimport type * as Path from \"../path.ts\";\nimport { empty as emptyPath } from \"../path.ts\";\nimport { type ConnectProps, connect, type WebSocketOptions, type WebTransportProps } from \"./connect.ts\";\nimport type { Established } from \"./established.ts\";\n\n/** Exponential backoff settings for {@link Reload}'s reconnect loop. */\nexport type ReloadDelay = {\n\t// The delay in milliseconds before reconnecting.\n\t// default: 1000\n\tinitial: DOMHighResTimeStamp;\n\n\t// The multiplier for the delay.\n\t// default: 2\n\tmultiplier: number;\n\n\t// The maximum delay in milliseconds.\n\t// default: 30000\n\tmax: DOMHighResTimeStamp;\n\n\t// Maximum total time in milliseconds to spend retrying before giving up.\n\t// Resets after each successful connection. Set to 0 for unlimited retries.\n\t// default: 300000 (5 minutes)\n\ttimeout?: DOMHighResTimeStamp;\n};\n\n/** Options for {@link Reload}: connect options plus reactive URL/enabled signals and backoff tuning. */\nexport type ReloadProps = ConnectProps & {\n\t// Whether to reload the connection when it disconnects.\n\t// default: true\n\tenabled?: boolean | Signal<boolean>;\n\n\t// The URL of the relay server.\n\turl?: URL | Signal<URL | undefined>;\n\n\t// The delay for the reload.\n\tdelay?: ReloadDelay;\n};\n\n/** Current state of a {@link Reload} connection. */\nexport type ReloadStatus = \"connecting\" | \"connected\" | \"disconnected\";\n\n/** Maintains a MoQ connection, reconnecting with exponential backoff when it drops. */\nexport class Reload {\n\t/** Relay URL to connect to; updating it triggers a reconnect. */\n\turl: Signal<URL | undefined>;\n\n\t/** Whether reconnecting is active. */\n\tenabled: Signal<boolean>;\n\n\t/** Current connection status. */\n\tstatus = new Signal<ReloadStatus>(\"disconnected\");\n\n\t/** The currently established session, or undefined while disconnected. */\n\testablished = new Signal<Established | undefined>(undefined);\n\n\t// All actively announced broadcast paths, updated reactively.\n\t#announced = new Signal<Set<Path.Valid>>(new Set());\n\n\t/** The set of broadcast paths currently announced by the server, updated reactively. */\n\treadonly announced: Getter<Set<Path.Valid>> = this.#announced;\n\n\t/** WebTransport options applied to each connection attempt (not reactive). */\n\twebtransport?: WebTransportProps;\n\n\t/** WebSocket fallback options applied to each connection attempt (not reactive). */\n\twebsocket: WebSocketOptions | undefined;\n\n\t/** Backoff settings for the reconnect loop. */\n\tdelay: ReloadDelay;\n\n\t/** The reactive effect scope driving the connect loop; closed by {@link Reload.close}. */\n\tsignals = new Effect();\n\n\t/** Resolves when the reconnect loop stops via {@link Reload.close} or the retry timeout. */\n\tclosed: Promise<void>;\n\t#closedResolve!: () => void;\n\t#closedReject!: (err: Error) => void;\n\n\t#delay: DOMHighResTimeStamp;\n\n\t// Timestamp when the current retry sequence started (for timeout).\n\t#retryStart: DOMHighResTimeStamp | undefined;\n\n\t// Increased by 1 each time to trigger a reload.\n\t#tick = new Signal(0);\n\n\tconstructor(props?: ReloadProps) {\n\t\tthis.url = Signal.from(props?.url);\n\t\tthis.enabled = Signal.from(props?.enabled ?? false);\n\t\tthis.delay = props?.delay ?? { initial: 1000, multiplier: 2, max: 30000 };\n\t\tthis.webtransport = props?.webtransport;\n\t\tthis.websocket = props?.websocket;\n\n\t\tthis.#delay = this.delay.initial;\n\n\t\tthis.closed = new Promise((resolve, reject) => {\n\t\t\tthis.#closedResolve = resolve;\n\t\t\tthis.#closedReject = reject;\n\t\t});\n\n\t\t// Create a reactive root so cleanup is easier.\n\t\tthis.signals.run(this.#connect.bind(this));\n\t\tthis.signals.run(this.#runAnnounced.bind(this));\n\t}\n\n\t#connect(effect: Effect): void {\n\t\t// Will retry when the tick changes.\n\t\teffect.get(this.#tick);\n\n\t\tconst enabled = effect.get(this.enabled);\n\t\tif (!enabled) return;\n\n\t\tconst url = effect.get(this.url);\n\t\tif (!url) return;\n\n\t\teffect.set(this.status, \"connecting\", \"disconnected\");\n\n\t\teffect.spawn(async () => {\n\t\t\ttry {\n\t\t\t\tconst pending = connect(url, { websocket: this.websocket, webtransport: this.webtransport });\n\n\t\t\t\tconst connection = await Promise.race([effect.cancel, pending]);\n\t\t\t\tif (!connection) {\n\t\t\t\t\tpending.then((conn) => conn.close()).catch(() => {});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\teffect.set(this.established, connection);\n\t\t\t\teffect.cleanup(() => connection.close());\n\n\t\t\t\teffect.set(this.status, \"connected\", \"disconnected\");\n\n\t\t\t\t// Reset the exponential backoff and timeout on success.\n\t\t\t\tthis.#delay = this.delay.initial;\n\t\t\t\tthis.#retryStart = undefined;\n\n\t\t\t\tawait Promise.race([effect.cancel, connection.closed]);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.warn(\"connection error:\", err);\n\n\t\t\t\t// Track retry start for timeout.\n\t\t\t\tthis.#retryStart ??= performance.now();\n\n\t\t\t\tconst timeout = this.delay.timeout ?? 300000;\n\t\t\t\tif (timeout > 0) {\n\t\t\t\t\tconst elapsed = performance.now() - this.#retryStart;\n\t\t\t\t\tif (elapsed >= timeout) {\n\t\t\t\t\t\tconsole.warn(\"reconnect timed out\");\n\t\t\t\t\t\tthis.#closedReject(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst tick = this.#tick.peek() + 1;\n\t\t\t\teffect.timer(() => this.#tick.update((prev) => Math.max(prev, tick)), this.#delay);\n\n\t\t\t\tthis.#delay = Math.min(this.#delay * this.delay.multiplier, this.delay.max);\n\t\t\t}\n\t\t});\n\t}\n\n\t#runAnnounced(effect: Effect): void {\n\t\tthis.#announced.set(new Set());\n\n\t\tconst conn = effect.get(this.established);\n\t\tif (!conn) return;\n\n\t\teffect.cleanup(() => this.#announced.set(new Set()));\n\n\t\t// Cloudflare's relay does not yet support SUBSCRIBE_NAMESPACE, so\n\t\t// skip announce subscriptions entirely for those hosts.\n\t\tif (conn.url.hostname.endsWith(\"mediaoverquic.com\")) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst announced = conn.announced(emptyPath());\n\t\teffect.cleanup(() => announced.close());\n\n\t\teffect.spawn(async () => {\n\t\t\ttry {\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst entry = await Promise.race([effect.cancel, announced.next()]);\n\t\t\t\t\tif (!entry) break;\n\n\t\t\t\t\tthis.#announced.mutate((active) => {\n\t\t\t\t\t\tif (entry.active) {\n\t\t\t\t\t\t\tactive.add(entry.path);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tactive.delete(entry.path);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tthis.#announced.set(new Set());\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Stop reconnecting, close the current connection, and resolve {@link Reload.closed}. */\n\tclose() {\n\t\tthis.signals.close();\n\t\tthis.#closedResolve();\n\t}\n}\n"]}
package/group.d.ts CHANGED
@@ -1,12 +1,17 @@
1
1
  import { Signal } from "@moq/signals";
2
+ /** Reactive backing state for a {@link Group}: buffered frames, a closed flag, and the running frame count. */
2
3
  export declare class GroupState {
3
4
  frames: Signal<Uint8Array<ArrayBufferLike>[]>;
4
5
  closed: Signal<boolean | Error>;
5
6
  total: Signal<number>;
6
7
  }
8
+ /** An ordered stream of frames within a track, delivered over a single QUIC stream. */
7
9
  export declare class Group {
10
+ /** Sequence number of this group within its track. */
8
11
  readonly sequence: number;
12
+ /** Reactive backing state. */
9
13
  state: GroupState;
14
+ /** Resolves with the abort error (or undefined) once closed. */
10
15
  readonly closed: Promise<Error | undefined>;
11
16
  constructor(sequence: number);
12
17
  /**
@@ -14,21 +19,29 @@ export declare class Group {
14
19
  * @param frame - The frame to write
15
20
  */
16
21
  writeFrame(frame: Uint8Array): void;
22
+ /** Write a string as a single UTF-8 encoded frame. */
17
23
  writeString(str: string): void;
24
+ /** Write a value as a single JSON-encoded frame. */
18
25
  writeJson(json: unknown): void;
26
+ /** Write a boolean as a single one-byte frame. */
19
27
  writeBool(bool: boolean): void;
20
28
  /**
21
29
  * Reads the next frame from the group.
22
30
  * @returns A promise that resolves to the next frame or undefined
23
31
  */
24
32
  readFrame(): Promise<Uint8Array | undefined>;
33
+ /** Reads the next frame along with its sequence number within the group. */
25
34
  readFrameSequence(): Promise<{
26
35
  sequence: number;
27
36
  data: Uint8Array;
28
37
  } | undefined>;
38
+ /** Reads the next frame and decodes it as a UTF-8 string. */
29
39
  readString(): Promise<string | undefined>;
40
+ /** Reads the next frame and parses it as JSON. */
30
41
  readJson(): Promise<unknown | undefined>;
42
+ /** Reads the next frame and decodes it as a one-byte boolean. */
31
43
  readBool(): Promise<boolean | undefined>;
44
+ /** Closes the group, optionally with an error to abort readers. */
32
45
  close(abort?: Error): void;
33
46
  }
34
47
  //# sourceMappingURL=group.d.ts.map
package/group.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,qBAAa,UAAU;IACtB,MAAM,wCAAgC;IACtC,MAAM,0BAAsC;IAC5C,KAAK,iBAAyB;CAC9B;AAED,qBAAa,KAAK;IACjB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;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,CAAC,GAAG,EAAE,MAAM;IAIvB,oDAAoD;IACpD,SAAS,CAAC,IAAI,EAAE,OAAO;IAIvB,kDAAkD;IAClD,SAAS,CAAC,IAAI,EAAE,OAAO;IAIvB;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAclD,4EAA4E;IACtE,iBAAiB,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,SAAS,CAAC;IActF,6DAA6D;IACvD,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK/C,kDAAkD;IAC5C,QAAQ,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAK9C,iEAAiE;IAC3D,QAAQ,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAK9C,mEAAmE;IACnE,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK;CAGnB"}
package/group.js CHANGED
@@ -1,12 +1,18 @@
1
+ /* @ts-self-types="./group.d.ts" */
1
2
  import { Signal } from "@moq/signals";
3
+ /** Reactive backing state for a {@link Group}: buffered frames, a closed flag, and the running frame count. */
2
4
  export class GroupState {
3
5
  frames = new Signal([]);
4
6
  closed = new Signal(false);
5
7
  total = new Signal(0); // The total number of frames in the group thus far
6
8
  }
9
+ /** An ordered stream of frames within a track, delivered over a single QUIC stream. */
7
10
  export class Group {
11
+ /** Sequence number of this group within its track. */
8
12
  sequence;
13
+ /** Reactive backing state. */
9
14
  state = new GroupState();
15
+ /** Resolves with the abort error (or undefined) once closed. */
10
16
  closed;
11
17
  constructor(sequence) {
12
18
  this.sequence = sequence;
@@ -32,12 +38,15 @@ export class Group {
32
38
  });
33
39
  this.state.total.update((total) => total + 1);
34
40
  }
41
+ /** Write a string as a single UTF-8 encoded frame. */
35
42
  writeString(str) {
36
43
  this.writeFrame(new TextEncoder().encode(str));
37
44
  }
45
+ /** Write a value as a single JSON-encoded frame. */
38
46
  writeJson(json) {
39
47
  this.writeString(JSON.stringify(json));
40
48
  }
49
+ /** Write a boolean as a single one-byte frame. */
41
50
  writeBool(bool) {
42
51
  this.writeFrame(new Uint8Array([bool ? 1 : 0]));
43
52
  }
@@ -59,6 +68,7 @@ export class Group {
59
68
  await Signal.race(this.state.frames, this.state.closed);
60
69
  }
61
70
  }
71
+ /** Reads the next frame along with its sequence number within the group. */
62
72
  async readFrameSequence() {
63
73
  for (;;) {
64
74
  const frames = this.state.frames.peek();
@@ -73,18 +83,22 @@ export class Group {
73
83
  await Signal.race(this.state.frames, this.state.closed);
74
84
  }
75
85
  }
86
+ /** Reads the next frame and decodes it as a UTF-8 string. */
76
87
  async readString() {
77
88
  const frame = await this.readFrame();
78
89
  return frame ? new TextDecoder().decode(frame) : undefined;
79
90
  }
91
+ /** Reads the next frame and parses it as JSON. */
80
92
  async readJson() {
81
93
  const frame = await this.readString();
82
94
  return frame ? JSON.parse(frame) : undefined;
83
95
  }
96
+ /** Reads the next frame and decodes it as a one-byte boolean. */
84
97
  async readBool() {
85
98
  const frame = await this.readFrame();
86
99
  return frame ? frame[0] === 1 : undefined;
87
100
  }
101
+ /** Closes the group, optionally with an error to abort readers. */
88
102
  close(abort) {
89
103
  this.state.closed.set(abort ?? true);
90
104
  }
package/group.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"group.js","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,OAAO,UAAU;IACtB,MAAM,GAAG,IAAI,MAAM,CAAe,EAAE,CAAC,CAAC;IACtC,MAAM,GAAG,IAAI,MAAM,CAAkB,KAAK,CAAC,CAAC;IAC5C,KAAK,GAAG,IAAI,MAAM,CAAS,CAAC,CAAC,CAAC,CAAC,mDAAmD;CAClF;AAED,MAAM,OAAO,KAAK;IACR,QAAQ,CAAS;IAE1B,KAAK,GAAG,IAAI,UAAU,EAAE,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AAK,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAED,KAAK,CAAC,UAAU;QACf,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,QAAQ;QACb,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,QAAQ;QACb,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,KAAa;QAClB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IACtC,CAAC;CACD","sourcesContent":["import { Signal } from \"@moq/signals\";\n\nexport class GroupState {\n\tframes = new Signal<Uint8Array[]>([]);\n\tclosed = new Signal<boolean | Error>(false);\n\ttotal = new Signal<number>(0); // The total number of frames in the group thus far\n}\n\nexport class Group {\n\treadonly sequence: number;\n\n\tstate = new GroupState();\n\treadonly closed: Promise<Error | undefined>;\n\n\tconstructor(sequence: number) {\n\t\tthis.sequence = sequence;\n\n\t\t// Cache the closed promise to avoid recreating it every time.\n\t\tthis.closed = new Promise((resolve) => {\n\t\t\tconst dispose = this.state.closed.subscribe((closed) => {\n\t\t\t\tif (!closed) return;\n\t\t\t\tresolve(closed instanceof Error ? closed : undefined);\n\t\t\t\tdispose();\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Writes a frame to the group.\n\t * @param frame - The frame to write\n\t */\n\twriteFrame(frame: Uint8Array) {\n\t\tif (this.state.closed.peek()) throw new Error(\"group is closed\");\n\n\t\tthis.state.frames.mutate((frames) => {\n\t\t\tframes.push(frame);\n\t\t});\n\n\t\tthis.state.total.update((total) => total + 1);\n\t}\n\n\twriteString(str: string) {\n\t\tthis.writeFrame(new TextEncoder().encode(str));\n\t}\n\n\twriteJson(json: unknown) {\n\t\tthis.writeString(JSON.stringify(json));\n\t}\n\n\twriteBool(bool: boolean) {\n\t\tthis.writeFrame(new Uint8Array([bool ? 1 : 0]));\n\t}\n\n\t/**\n\t * Reads the next frame from the group.\n\t * @returns A promise that resolves to the next frame or undefined\n\t */\n\tasync readFrame(): Promise<Uint8Array | undefined> {\n\t\tfor (;;) {\n\t\t\tconst frames = this.state.frames.peek();\n\t\t\tconst frame = frames.shift();\n\t\t\tif (frame) return frame;\n\n\t\t\tconst closed = this.state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed) return;\n\n\t\t\tawait Signal.race(this.state.frames, this.state.closed);\n\t\t}\n\t}\n\n\tasync readFrameSequence(): Promise<{ sequence: number; data: Uint8Array } | undefined> {\n\t\tfor (;;) {\n\t\t\tconst frames = this.state.frames.peek();\n\t\t\tconst frame = frames.shift();\n\t\t\tif (frame) return { sequence: this.state.total.peek() - frames.length - 1, data: frame };\n\n\t\t\tconst closed = this.state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed) return;\n\n\t\t\tawait Signal.race(this.state.frames, this.state.closed);\n\t\t}\n\t}\n\n\tasync readString(): Promise<string | undefined> {\n\t\tconst frame = await this.readFrame();\n\t\treturn frame ? new TextDecoder().decode(frame) : undefined;\n\t}\n\n\tasync readJson(): Promise<unknown | undefined> {\n\t\tconst frame = await this.readString();\n\t\treturn frame ? JSON.parse(frame) : undefined;\n\t}\n\n\tasync readBool(): Promise<boolean | undefined> {\n\t\tconst frame = await this.readFrame();\n\t\treturn frame ? frame[0] === 1 : undefined;\n\t}\n\n\tclose(abort?: Error) {\n\t\tthis.state.closed.set(abort ?? true);\n\t}\n}\n"]}
1
+ {"version":3,"file":"group.js","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,+GAA+G;AAC/G,MAAM,OAAO,UAAU;IACtB,MAAM,GAAG,IAAI,MAAM,CAAe,EAAE,CAAC,CAAC;IACtC,MAAM,GAAG,IAAI,MAAM,CAAkB,KAAK,CAAC,CAAC;IAC5C,KAAK,GAAG,IAAI,MAAM,CAAS,CAAC,CAAC,CAAC,CAAC,mDAAmD;CAClF;AAED,uFAAuF;AACvF,MAAM,OAAO,KAAK;IACjB,sDAAsD;IAC7C,QAAQ,CAAS;IAE1B,8BAA8B;IAC9B,KAAK,GAAG,IAAI,UAAU,EAAE,CAAC;IAEzB,gEAAgE;IACvD,MAAM,CAA6B;IAE5C,YAAY,QAAgB;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,8DAA8D;QAC9D,IAAI,CAAC,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACrC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;gBACtD,IAAI,CAAC,MAAM;oBAAE,OAAO;gBACpB,OAAO,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;gBACtD,OAAO,EAAE,CAAC;YACX,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,KAAiB;QAC3B,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB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,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3C,CAAC;IAED,mEAAmE;IACnE,KAAK,CAAC,KAAa;QAClB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IACtC,CAAC;CACD","sourcesContent":["import { Signal } from \"@moq/signals\";\n\n/** Reactive backing state for a {@link Group}: buffered frames, a closed flag, and the running frame count. */\nexport class GroupState {\n\tframes = new Signal<Uint8Array[]>([]);\n\tclosed = new Signal<boolean | Error>(false);\n\ttotal = new Signal<number>(0); // The total number of frames in the group thus far\n}\n\n/** An ordered stream of frames within a track, delivered over a single QUIC stream. */\nexport class Group {\n\t/** Sequence number of this group within its track. */\n\treadonly sequence: number;\n\n\t/** Reactive backing state. */\n\tstate = new GroupState();\n\n\t/** Resolves with the abort error (or undefined) once closed. */\n\treadonly closed: Promise<Error | undefined>;\n\n\tconstructor(sequence: number) {\n\t\tthis.sequence = sequence;\n\n\t\t// Cache the closed promise to avoid recreating it every time.\n\t\tthis.closed = new Promise((resolve) => {\n\t\t\tconst dispose = this.state.closed.subscribe((closed) => {\n\t\t\t\tif (!closed) return;\n\t\t\t\tresolve(closed instanceof Error ? closed : undefined);\n\t\t\t\tdispose();\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Writes a frame to the group.\n\t * @param frame - The frame to write\n\t */\n\twriteFrame(frame: Uint8Array) {\n\t\tif (this.state.closed.peek()) throw new Error(\"group is closed\");\n\n\t\tthis.state.frames.mutate((frames) => {\n\t\t\tframes.push(frame);\n\t\t});\n\n\t\tthis.state.total.update((total) => total + 1);\n\t}\n\n\t/** Write a string as a single UTF-8 encoded frame. */\n\twriteString(str: string) {\n\t\tthis.writeFrame(new TextEncoder().encode(str));\n\t}\n\n\t/** Write a value as a single JSON-encoded frame. */\n\twriteJson(json: unknown) {\n\t\tthis.writeString(JSON.stringify(json));\n\t}\n\n\t/** Write a boolean as a single one-byte frame. */\n\twriteBool(bool: boolean) {\n\t\tthis.writeFrame(new Uint8Array([bool ? 1 : 0]));\n\t}\n\n\t/**\n\t * Reads the next frame from the group.\n\t * @returns A promise that resolves to the next frame or undefined\n\t */\n\tasync readFrame(): Promise<Uint8Array | undefined> {\n\t\tfor (;;) {\n\t\t\tconst frames = this.state.frames.peek();\n\t\t\tconst frame = frames.shift();\n\t\t\tif (frame) return frame;\n\n\t\t\tconst closed = this.state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed) return;\n\n\t\t\tawait Signal.race(this.state.frames, this.state.closed);\n\t\t}\n\t}\n\n\t/** Reads the next frame along with its sequence number within the group. */\n\tasync readFrameSequence(): Promise<{ sequence: number; data: Uint8Array } | undefined> {\n\t\tfor (;;) {\n\t\t\tconst frames = this.state.frames.peek();\n\t\t\tconst frame = frames.shift();\n\t\t\tif (frame) return { sequence: this.state.total.peek() - frames.length - 1, data: frame };\n\n\t\t\tconst closed = this.state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed) return;\n\n\t\t\tawait Signal.race(this.state.frames, this.state.closed);\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 frame = await this.readFrame();\n\t\treturn frame ? new TextDecoder().decode(frame) : undefined;\n\t}\n\n\t/** Reads the next frame and parses it as JSON. */\n\tasync readJson(): Promise<unknown | undefined> {\n\t\tconst frame = await this.readString();\n\t\treturn frame ? JSON.parse(frame) : undefined;\n\t}\n\n\t/** Reads the next frame and decodes it as a one-byte boolean. */\n\tasync readBool(): Promise<boolean | undefined> {\n\t\tconst frame = await this.readFrame();\n\t\treturn frame ? frame[0] === 1 : undefined;\n\t}\n\n\t/** Closes the group, optionally with an error to abort readers. */\n\tclose(abort?: Error) {\n\t\tthis.state.closed.set(abort ?? true);\n\t}\n}\n"]}
package/ietf/adapter.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Stream } from "../stream.ts";
2
- import { type IetfVersion } from "./version.ts";
1
+ import { Stream } from "../stream";
2
+ import { type IetfVersion } from "./version";
3
3
  /**
4
4
  * Interface for opening outgoing bidi streams and allocating request IDs.
5
5
  * Implemented by both ControlStreamAdapter (v14-v16) and NativeSession (v17).
package/ietf/adapter.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./adapter.d.ts" */
1
2
  import { Mutex } from "async-mutex";
2
3
  import { Reader, Stream } from "../stream.js";
3
4
  import * as Varint from "../varint.js";
@@ -1,9 +1,9 @@
1
- import type { Announced } from "../announced.ts";
2
- import type { Broadcast } from "../broadcast.ts";
3
- import type { Established } from "../connection/established.ts";
4
- import * as Path from "../path.ts";
5
- import { type Stream } from "../stream.ts";
6
- import { type IetfVersion } from "./version.ts";
1
+ import type { Announced } from "../announced";
2
+ import type { Broadcast } from "../broadcast";
3
+ import type { Established } from "../connection/established";
4
+ import * as Path from "../path";
5
+ import { type Stream } from "../stream";
6
+ import { type IetfVersion } from "./version";
7
7
  /**
8
8
  * Represents a connection to a MoQ server using moq-transport protocol.
9
9
  *
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./connection.d.ts" */
1
2
  import * as Path from "../path.js";
2
3
  import { Readers } from "../stream.js";
3
4
  import { ControlStreamAdapter, NativeSession } from "./adapter.js";
package/ietf/control.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import type { Stream as StreamInner } from "../stream.ts";
2
- import { Fetch, FetchCancel, FetchError, FetchOk } from "./fetch.ts";
3
- import { GoAway } from "./goaway.ts";
4
- import { Publish, PublishDone, PublishError, PublishOk } from "./publish.ts";
5
- import { PublishNamespace, PublishNamespaceCancel, PublishNamespaceDone, PublishNamespaceError, PublishNamespaceOk } from "./publish_namespace.ts";
6
- import { MaxRequestId, RequestError, RequestOk, RequestsBlocked } from "./request.ts";
7
- import * as Setup from "./setup.ts";
8
- import { Subscribe, SubscribeError, SubscribeOk, SubscribeUpdate, Unsubscribe } from "./subscribe.ts";
9
- import { SubscribeNamespaceError, SubscribeNamespaceLegacy, SubscribeNamespaceOk, UnsubscribeNamespace } from "./subscribe_namespace.ts";
10
- import { TrackStatus, TrackStatusRequest } from "./track.ts";
11
- import { type IetfVersion } from "./version.ts";
1
+ import type { Stream as StreamInner } from "../stream";
2
+ import { Fetch, FetchCancel, FetchError, FetchOk } from "./fetch";
3
+ import { GoAway } from "./goaway";
4
+ import { Publish, PublishDone, PublishError, PublishOk } from "./publish";
5
+ import { PublishNamespace, PublishNamespaceCancel, PublishNamespaceDone, PublishNamespaceError, PublishNamespaceOk } from "./publish_namespace";
6
+ import { MaxRequestId, RequestError, RequestOk, RequestsBlocked } from "./request";
7
+ import * as Setup from "./setup";
8
+ import { Subscribe, SubscribeError, SubscribeOk, SubscribeUpdate, Unsubscribe } from "./subscribe";
9
+ import { SubscribeNamespaceError, SubscribeNamespaceLegacy, SubscribeNamespaceOk, UnsubscribeNamespace } from "./subscribe_namespace";
10
+ import { TrackStatus, TrackStatusRequest } from "./track";
11
+ import { type IetfVersion } from "./version";
12
12
  declare const MessagesV14: {
13
13
  readonly [Setup.ClientSetup.id]: typeof Setup.ClientSetup;
14
14
  readonly [Setup.ServerSetup.id]: typeof Setup.ServerSetup;
package/ietf/control.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./control.d.ts" */
1
2
  import { Mutex } from "async-mutex";
2
3
  import { Fetch, FetchCancel, FetchError, FetchOk } from "./fetch.js";
3
4
  import { GoAway } from "./goaway.js";
package/ietf/fetch.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type * as Path from "../path.ts";
2
- import type { Reader, Writer } from "../stream.ts";
3
- import type { IetfVersion } from "./version.ts";
1
+ import type * as Path from "../path";
2
+ import type { Reader, Writer } from "../stream";
3
+ import type { IetfVersion } from "./version";
4
4
  export declare class Fetch {
5
5
  #private;
6
6
  static id: number;
package/ietf/fetch.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./fetch.d.ts" */
1
2
  import * as Message from "./message.js";
2
3
  export class Fetch {
3
4
  static id = 0x16;
package/ietf/goaway.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Reader, Writer } from "../stream.ts";
2
- import { type IetfVersion } from "./version.ts";
1
+ import type { Reader, Writer } from "../stream";
2
+ import { type IetfVersion } from "./version";
3
3
  export declare class GoAway {
4
4
  #private;
5
5
  static id: number;
package/ietf/goaway.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./goaway.d.ts" */
1
2
  import * as Message from "./message.js";
2
3
  import { Version } from "./version.js";
3
4
  export class GoAway {
package/ietf/ietf.test.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./ietf.test.d.ts" */
1
2
  import { expect, test } from "bun:test";
2
3
  import * as Path from "../path.js";
3
4
  import { Reader, Writer } from "../stream.js";
package/ietf/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- export * from "./adapter.ts";
2
- export * from "./connection.ts";
3
- export * from "./control.ts";
4
- export * from "./fetch.ts";
5
- export * from "./goaway.ts";
6
- export * from "./object.ts";
7
- export * from "./parameters.ts";
8
- export * from "./publish.ts";
9
- export * from "./publish_namespace.ts";
10
- export * from "./publisher.ts";
11
- export * from "./request.ts";
12
- export * from "./setup.ts";
13
- export * from "./subscribe.ts";
14
- export * from "./subscribe_namespace.ts";
15
- export * from "./subscriber.ts";
16
- export * from "./track.ts";
17
- export * from "./version.ts";
1
+ export * from "./adapter";
2
+ export * from "./connection";
3
+ export * from "./control";
4
+ export * from "./fetch";
5
+ export * from "./goaway";
6
+ export * from "./object";
7
+ export * from "./parameters";
8
+ export * from "./publish";
9
+ export * from "./publish_namespace";
10
+ export * from "./publisher";
11
+ export * from "./request";
12
+ export * from "./setup";
13
+ export * from "./subscribe";
14
+ export * from "./subscribe_namespace";
15
+ export * from "./subscriber";
16
+ export * from "./track";
17
+ export * from "./version";
18
18
  //# sourceMappingURL=index.d.ts.map
package/ietf/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./index.d.ts" */
1
2
  export * from "./adapter.js";
2
3
  export * from "./connection.js";
3
4
  export * from "./control.js";
package/ietf/message.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Reader, Writer } from "../stream.ts";
1
+ import { Reader, Writer } from "../stream";
2
2
  export declare function encode(writer: Writer, f: (w: Writer) => Promise<void>): Promise<void>;
3
3
  export declare function decode<T>(reader: Reader, f: (r: Reader) => Promise<T>): Promise<T>;
4
4
  //# sourceMappingURL=message.d.ts.map
package/ietf/message.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./message.d.ts" */
1
2
  import { Reader, Writer } from "../stream.js";
2
3
  // Encodes a message with a u16 (16-bit) size prefix as per draft-14.
3
4
  export async function encode(writer, f) {
@@ -1,5 +1,5 @@
1
- import * as Path from "../path.ts";
2
- import type { Reader, Writer } from "../stream.ts";
1
+ import * as Path from "../path";
2
+ import type { Reader, Writer } from "../stream";
3
3
  export declare function encode(w: Writer, namespace: Path.Valid): Promise<void>;
4
4
  export declare function decode(r: Reader): Promise<Path.Valid>;
5
5
  //# sourceMappingURL=namespace.d.ts.map
package/ietf/namespace.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./namespace.d.ts" */
1
2
  import * as Path from "../path.js";
2
3
  export async function encode(w, namespace) {
3
4
  if (namespace === "") {
package/ietf/object.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Reader, Writer } from "../stream.ts";
2
- import { type IetfVersion } from "./version.ts";
1
+ import type { Reader, Writer } from "../stream";
2
+ import { type IetfVersion } from "./version";
3
3
  export interface GroupFlags {
4
4
  hasExtensions: boolean;
5
5
  hasSubgroup: boolean;
package/ietf/object.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./object.d.ts" */
1
2
  import { Version } from "./version.js";
2
3
  const GROUP_END = 0x03;
3
4
  // draft-18 adds bit 0x40 (FIRST_OBJECT) to the subgroup header type per spec
@@ -1,5 +1,5 @@
1
- import type { Reader, Writer } from "../stream.ts";
2
- import { type IetfVersion } from "./version.ts";
1
+ import type { Reader, Writer } from "../stream";
2
+ import { type IetfVersion } from "./version";
3
3
  export declare const SetupOption: {
4
4
  readonly Path: 1n;
5
5
  readonly MaxRequestId: 2n;
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./parameters.d.ts" */
1
2
  import * as Varint from "../varint.js";
2
3
  import { Version } from "./version.js";
3
4
  /// Setup Option key constants (separate namespace from Message Parameters).
@@ -1,4 +1,4 @@
1
- import type { Reader } from "../stream.ts";
2
- import { type IetfVersion } from "./version.ts";
1
+ import type { Reader } from "../stream";
2
+ import { type IetfVersion } from "./version";
3
3
  export declare function skip(r: Reader, version: IetfVersion): Promise<void>;
4
4
  //# sourceMappingURL=properties.d.ts.map
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./properties.d.ts" */
1
2
  import { Version } from "./version.js";
2
3
  /// Skip Track Properties from the remaining bytes of a message.
3
4
  ///
package/ietf/publish.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type * as Path from "../path.ts";
2
- import type { Reader, Writer } from "../stream.ts";
3
- import { type IetfVersion } from "./version.ts";
1
+ import type * as Path from "../path";
2
+ import type { Reader, Writer } from "../stream";
3
+ import { type IetfVersion } from "./version";
4
4
  export declare class Publish {
5
5
  #private;
6
6
  static id: number;
package/ietf/publish.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./publish.d.ts" */
1
2
  import * as Message from "./message.js";
2
3
  import * as Namespace from "./namespace.js";
3
4
  import { Parameters } from "./parameters.js";
@@ -1,6 +1,6 @@
1
- import type * as Path from "../path.ts";
2
- import type { Reader, Writer } from "../stream.ts";
3
- import { type IetfVersion } from "./version.ts";
1
+ import type * as Path from "../path";
2
+ import type { Reader, Writer } from "../stream";
3
+ import { type IetfVersion } from "./version";
4
4
  export declare class PublishNamespace {
5
5
  #private;
6
6
  static id: number;
@@ -1,3 +1,4 @@
1
+ /* @ts-self-types="./publish_namespace.d.ts" */
1
2
  import * as Message from "./message.js";
2
3
  import * as Namespace from "./namespace.js";
3
4
  import { Parameters } from "./parameters.js";