@moq/net 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/broadcast.d.ts +21 -7
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +38 -16
- package/broadcast.js.map +1 -1
- package/connection/accept.js +6 -4
- package/connection/accept.js.map +1 -1
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +5 -4
- package/connection/connect.js.map +1 -1
- package/connection/forward.js +54 -47
- package/connection/forward.js.map +1 -1
- package/connection/goaway.d.ts +34 -0
- package/connection/goaway.d.ts.map +1 -0
- package/connection/goaway.js +176 -0
- package/connection/goaway.js.map +1 -0
- package/connection/handshake.d.ts +4 -2
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +42 -10
- package/connection/handshake.js.map +1 -1
- package/connection/pool.d.ts +16 -1
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +32 -10
- package/connection/pool.js.map +1 -1
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +184 -30
- package/connection/reload.js.map +1 -1
- package/error.d.ts +11 -0
- package/error.d.ts.map +1 -1
- package/error.js +14 -0
- package/error.js.map +1 -1
- package/errors.d.ts +1 -1
- package/errors.d.ts.map +1 -1
- package/errors.js +1 -1
- package/errors.js.map +1 -1
- package/group.d.ts.map +1 -1
- package/group.js +5 -4
- package/group.js.map +1 -1
- package/hop.d.ts +8 -0
- package/hop.d.ts.map +1 -1
- package/hop.js +16 -0
- package/hop.js.map +1 -1
- package/ietf/adapter.d.ts +4 -0
- package/ietf/adapter.d.ts.map +1 -1
- package/ietf/adapter.js +19 -8
- package/ietf/adapter.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +3 -3
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +110 -37
- package/ietf/connection.js.map +1 -1
- package/ietf/fetch.d.ts +7 -20
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +52 -22
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +2 -0
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +4 -0
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +9 -1
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +20 -0
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -1
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +1 -1
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +1 -1
- package/ietf/index.js.map +1 -1
- package/ietf/object.d.ts +7 -6
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +37 -33
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +7 -0
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +62 -12
- package/ietf/parameters.js.map +1 -1
- package/ietf/publish_namespace.d.ts +2 -2
- package/ietf/publish_namespace.js +2 -2
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +287 -172
- package/ietf/publisher.js.map +1 -1
- package/ietf/subscribe.d.ts +7 -1
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +22 -14
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +2 -3
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +57 -42
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.d.ts +2 -0
- package/ietf/token.d.ts.map +1 -0
- package/ietf/token.js +99 -0
- package/ietf/token.js.map +1 -0
- package/ietf/track.d.ts +4 -0
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +6 -20
- package/ietf/track.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/internal.d.ts +12 -3
- package/internal.d.ts.map +1 -1
- package/internal.js +32 -0
- package/internal.js.map +1 -1
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +7 -4
- package/lite/announce.js.map +1 -1
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +22 -7
- package/lite/connection.js.map +1 -1
- package/lite/datagram.d.ts +3 -2
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +7 -8
- package/lite/datagram.js.map +1 -1
- package/lite/group.d.ts +12 -8
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +37 -16
- package/lite/group.js.map +1 -1
- package/lite/message.d.ts +2 -2
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +14 -5
- package/lite/message.js.map +1 -1
- package/lite/publisher.js +19 -37
- package/lite/publisher.js.map +1 -1
- package/lite/setup.d.ts +1 -1
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +22 -19
- package/lite/setup.js.map +1 -1
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +206 -127
- package/lite/subscriber.js.map +1 -1
- package/origin.d.ts +9 -1
- package/origin.d.ts.map +1 -1
- package/origin.js +341 -146
- package/origin.js.map +1 -1
- package/package.json +2 -2
- package/stream.d.ts +77 -12
- package/stream.d.ts.map +1 -1
- package/stream.js +359 -122
- package/stream.js.map +1 -1
- package/tail.d.ts +7 -0
- package/tail.d.ts.map +1 -1
- package/tail.js +68 -22
- package/tail.js.map +1 -1
- package/track.d.ts +14 -3
- package/track.d.ts.map +1 -1
- package/track.js +170 -76
- package/track.js.map +1 -1
- package/util/abort.d.ts +2 -0
- package/util/abort.d.ts.map +1 -0
- package/util/abort.js +20 -0
- package/util/abort.js.map +1 -0
- package/util/u64.d.ts +39 -0
- package/util/u64.d.ts.map +1 -0
- package/util/u64.js +83 -0
- package/util/u64.js.map +1 -0
- package/util/varint.d.ts +29 -0
- package/util/varint.d.ts.map +1 -0
- package/util/varint.js +198 -0
- package/util/varint.js.map +1 -0
- package/varint.d.ts +10 -6
- package/varint.d.ts.map +1 -1
- package/varint.js +40 -237
- package/varint.js.map +1 -1
- package/wire.d.ts +17 -3
- package/wire.d.ts.map +1 -1
- package/wire.js.map +1 -1
- package/ietf/control.d.ts +0 -135
- package/ietf/control.d.ts.map +0 -1
- package/ietf/control.js +0 -242
- package/ietf/control.js.map +0 -1
package/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE/F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,kFAAkF;AAClF,4EAA4E;AAC5E,SAAS,QAAQ,CAAC,MAAe,EAAE,OAAqB;IACvD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAChD,OAAO,IAAI,KAAK,UAAU,CAAC,QAAQ,IAAI,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AACzG,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC5B,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,8CAA8C;AAEtF;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAAqB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AQ,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AAED,8CAA8C;AAC9C,MAAM,OAAO,OAAO;IACnB,OAAO,CAA0D;IACjE,QAAQ,CAAe;IAEvB,YAAY,IAAkB,EAAE,OAAqB;QACpD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,6BAA6B,CAAC,SAAS,EAE1D,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACT,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO;QACtB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACD","sourcesContent":["import { race } from \"@moq/signals\";\nimport { fromTransport, StreamCode, StreamError, toStreamCode, toTransport } from \"./error.ts\";\nimport type { IetfVersion } from \"./ietf/version.ts\";\nimport { Version } from \"./ietf/version.ts\";\nimport { TimeoutError, withTimeout } from \"./util/timeout.ts\";\nimport { decodeUtf8 } from \"./util/utf8.ts\";\nimport * as Varint from \"./varint.ts\";\n\n// Decode raw transport errors before mapping so they cannot bypass the negotiated\n// registry. Ordinary errors already send 0 and retain their local identity.\nfunction withCode(reason: unknown, version?: IetfVersion): unknown {\n\tconst decoded = fromTransport(reason, { version });\n\tconst code = toStreamCode(decoded, { version });\n\treturn code === StreamCode.Internal && decoded === reason ? reason : toTransport(code, decoded.message);\n}\n\nconst MAX_U31 = 2 ** 31 - 1;\nconst MAX_READ_SIZE = 1024 * 1024 * 64; // don't allocate more than 64MB for a message\n\n/**\n * Options handed to the transport for one outgoing stream.\n *\n * `waitUntilAvailable` waits for the peer's concurrent stream limit to free a slot instead\n * of rejecting with a `QuotaExceededError`, which is what we want for the streams a session\n * opens occasionally. `@types/web` doesn't declare it yet, hence the intersection.\n */\nexport function sendOptions(options?: OpenOptions): WebTransportSendStreamOptions & { waitUntilAvailable?: boolean } {\n\treturn { sendOrder: options?.sendOrder, waitUntilAvailable: options?.waitUntilAvailable ?? true };\n}\n\n// How long any open may wait for the peer to free a stream slot. Every open needs this,\n// whether or not it asked to wait: an implementation may park an over-limit open rather\n// than rejecting it, and a peer can advertise a stream limit of zero and never raise it.\n// Matches the subscribe budget.\nconst OPEN_TIMEOUT_MS = 10_000;\n\n/**\n * Bound an open that would otherwise park until the peer grants stream credit, restoring\n * the pre-waitUntilAvailable failure after a grace period. A stream arriving after the\n * deadline is discarded, since nobody is waiting for it any more.\n */\nasync function openWithin<T>(opening: Promise<T>, timeout: number, discard: (stream: T) => void): Promise<T> {\n\ttry {\n\t\treturn await withTimeout(opening, timeout, `stream open timed out after ${timeout}ms waiting for a slot`);\n\t} catch (err: unknown) {\n\t\topening.then(discard).catch(() => void 0);\n\t\tthrow err;\n\t}\n}\n\nfunction isLeadingOnes(version?: IetfVersion): boolean {\n\treturn (\n\t\tversion !== undefined &&\n\t\tversion !== Version.DRAFT_14 &&\n\t\tversion !== Version.DRAFT_15 &&\n\t\tversion !== Version.DRAFT_16\n\t);\n}\n\n/**\n * The `WebTransportSendStream` that every outgoing stream is, narrowed to the one attribute\n * this package uses. The DOM types available here still describe them as plain\n * `WritableStream`s, so the interface has to be named structurally.\n *\n * `sendOrder` is optional because it is absent until set, and stays absent on an\n * implementation that doesn't carry the interface at all.\n *\n * @see https://www.w3.org/TR/webtransport/#webtransportsendstream\n */\nexport type SendStream = WritableStream<Uint8Array> & { sendOrder?: number };\n\n/** Options for opening an outgoing stream. */\nexport interface OpenOptions {\n\t/** The negotiated IETF version, which selects the varint encoding. */\n\tversion?: IetfVersion;\n\n\t/**\n\t * The transport send order, where HIGHER values are transmitted first.\n\t * Left to the transport's default when unset.\n\t */\n\tsendOrder?: number;\n\n\t/**\n\t * Reject if the peer hasn't freed a stream slot within this many milliseconds. Defaults\n\t * to 10s. There is no way to wait indefinitely: a peer can advertise a stream limit of\n\t * zero and never raise it, so every open needs a way out.\n\t */\n\ttimeout?: number;\n\n\t/**\n\t * Ask the transport to wait for a stream slot rather than failing when the peer's\n\t * concurrent stream limit is exhausted. Defaults to true.\n\t *\n\t * Set it false on a path that opens streams faster than the peer can retire them. The\n\t * transport queues the opens it can't satisfy and serves them in order, with no way to\n\t * cancel one, so waiting there spends returning credit on whatever was requested first\n\t * rather than on what matters now.\n\t */\n\twaitUntilAvailable?: boolean;\n}\n\n/** Options for {@link Writer.tryOpen}. */\nexport interface TryOpenOptions extends OpenOptions {\n\t/** Give up once this resolves. */\n\tcancel: Promise<void>;\n}\n\nexport class Stream {\n\treader: Reader;\n\twriter: Writer;\n\n\t/** Wrap the two halves of a transport stream. */\n\tconstructor(props: {\n\t\twritable: WritableStream<Uint8Array>;\n\t\treadable: ReadableStream<Uint8Array>;\n\t\tversion?: IetfVersion;\n\t});\n\t/** Pair halves that were opened separately, as the SETUP exchange does. */\n\tconstructor(props: { writer: Writer; reader: Reader });\n\tconstructor(props: {\n\t\twritable?: WritableStream<Uint8Array>;\n\t\treadable?: ReadableStream<Uint8Array>;\n\t\twriter?: Writer;\n\t\treader?: Reader;\n\t\tversion?: IetfVersion;\n\t}) {\n\t\tconst writer = props.writer ?? (props.writable && new Writer(props.writable, props.version));\n\t\tconst reader = props.reader ?? (props.readable && new Reader(props.readable, undefined, props.version));\n\t\tif (!writer || !reader) throw new Error(\"stream needs both halves\");\n\n\t\tthis.writer = writer;\n\t\tthis.reader = reader;\n\t}\n\n\tstatic async accept(quic: WebTransport, version?: IetfVersion): Promise<Stream | undefined> {\n\t\tfor (;;) {\n\t\t\tconst reader =\n\t\t\t\tquic.incomingBidirectionalStreams.getReader() as ReadableStreamDefaultReader<WebTransportBidirectionalStream>;\n\t\t\tconst next = await reader.read();\n\t\t\treader.releaseLock();\n\n\t\t\tif (next.done) return;\n\t\t\tconst { readable, writable } = next.value;\n\t\t\treturn new Stream({ readable, writable, version });\n\t\t}\n\t}\n\n\t/**\n\t * Open an outgoing bidirectional stream.\n\t * @param quic - The session to open it on\n\t * @param options - The version its varints encode with, and the send order ranking it\n\t * against the session's other streams\n\t */\n\tstatic async open(quic: WebTransport, options?: OpenOptions): Promise<Stream> {\n\t\tconst { readable, writable } = await openWithin(\n\t\t\tquic.createBidirectionalStream(sendOptions(options)),\n\t\t\toptions?.timeout ?? OPEN_TIMEOUT_MS,\n\t\t\t(stream) => {\n\t\t\t\tvoid stream.writable.abort().catch(() => void 0);\n\t\t\t\tvoid stream.readable.cancel().catch(() => void 0);\n\t\t\t},\n\t\t);\n\t\treturn new Stream({ readable, writable, version: options?.version });\n\t}\n\n\tclose() {\n\t\tthis.writer.close();\n\t\t// A routine unsubscribe, so send CANCELLED. A bare Error would put 0 on the wire,\n\t\t// which the stream registry reads as INTERNAL_ERROR: the peer would log a failure\n\t\t// for every subscription we walk away from.\n\t\tthis.reader.stop(new StreamError(StreamCode.Cancel, { message: \"cancel\" }));\n\t}\n\n\tabort(reason: Error) {\n\t\tthis.writer.reset(reason);\n\t\tthis.reader.stop(reason);\n\t}\n}\n\n// Reader wraps a stream and provides convience methods for reading pieces from a stream\n// Unfortunately we can't use a BYOB reader because it's not supported with WebTransport+WebWorkers yet.\nexport class Reader {\n\t#buffer: Uint8Array;\n\t#stream?: ReadableStream<Uint8Array>; // if undefined, the buffer is consumed then EOF\n\t#reader?: ReadableStreamDefaultReader<Uint8Array>;\n\t#closed?: Promise<void>;\n\tversion?: IetfVersion;\n\n\t// Either stream or buffer MUST be provided.\n\tconstructor(stream: ReadableStream<Uint8Array>, buffer?: Uint8Array, version?: IetfVersion);\n\tconstructor(stream: undefined, buffer: Uint8Array, version?: IetfVersion);\n\tconstructor(stream?: ReadableStream<Uint8Array>, buffer?: Uint8Array, version?: IetfVersion) {\n\t\tthis.#buffer = buffer ?? new Uint8Array();\n\t\tthis.#stream = stream;\n\t\tthis.#reader = this.#stream?.getReader();\n\t\tthis.version = version;\n\t}\n\n\t// Adds more data to the buffer, returning true if more data was added.\n\tasync #fill(): Promise<boolean> {\n\t\tif (!this.#reader) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Every read of this stream funnels through here, so decoding the peer's reset code\n\t\t// once is enough to keep the raw transport error out of every caller (and every app).\n\t\tconst result = await this.#reader.read().catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: this.version });\n\t\t});\n\n\t\tif (result.done) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (result.value.byteLength === 0) {\n\t\t\tthrow new Error(\"unexpected empty chunk\");\n\t\t}\n\n\t\tconst buffer = result.value;\n\n\t\tif (this.#buffer.byteLength === 0) {\n\t\t\tthis.#buffer = new Uint8Array(buffer);\n\t\t} else {\n\t\t\tconst temp = new Uint8Array(this.#buffer.byteLength + buffer.byteLength);\n\t\t\ttemp.set(this.#buffer);\n\t\t\ttemp.set(buffer, this.#buffer.byteLength);\n\t\t\tthis.#buffer = temp;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t// Add more data to the buffer until it's at least size bytes.\n\tasync #fillTo(size: number) {\n\t\tif (size > MAX_READ_SIZE) {\n\t\t\tthrow new Error(`read size ${size} exceeds max size ${MAX_READ_SIZE}`);\n\t\t}\n\n\t\twhile (this.#buffer.byteLength < size) {\n\t\t\tif (!(await this.#fill())) {\n\t\t\t\tthrow new Error(\"unexpected end of stream\");\n\t\t\t}\n\t\t}\n\t}\n\n\t// Consumes the first size bytes of the buffer.\n\t#slice(size: number): Uint8Array {\n\t\tconst result = new Uint8Array(this.#buffer.buffer, this.#buffer.byteOffset, size);\n\t\tthis.#buffer = new Uint8Array(\n\t\t\tthis.#buffer.buffer,\n\t\t\tthis.#buffer.byteOffset + size,\n\t\t\tthis.#buffer.byteLength - size,\n\t\t);\n\n\t\treturn result;\n\t}\n\n\tasync read(size: number): Promise<Uint8Array> {\n\t\tif (size === 0) return new Uint8Array();\n\n\t\tawait this.#fillTo(size);\n\t\treturn this.#slice(size);\n\t}\n\n\tasync readAll(): Promise<Uint8Array> {\n\t\twhile (await this.#fill()) {\n\t\t\t// keep going\n\t\t}\n\t\treturn this.#slice(this.#buffer.byteLength);\n\t}\n\n\tasync string(): Promise<string> {\n\t\tconst length = await this.u53();\n\t\tconst buffer = await this.read(length);\n\t\treturn decodeUtf8(buffer);\n\t}\n\n\tasync bool(): Promise<boolean> {\n\t\tconst v = await this.u8();\n\t\tif (v === 0) return false;\n\t\tif (v === 1) return true;\n\t\tthrow new Error(\"invalid bool value\");\n\t}\n\n\tasync u8(): Promise<number> {\n\t\tawait this.#fillTo(1);\n\t\treturn this.#slice(1)[0];\n\t}\n\n\tasync u16(): Promise<number> {\n\t\tawait this.#fillTo(2);\n\t\tconst view = new DataView(this.#buffer.buffer, this.#buffer.byteOffset, 2);\n\t\tconst result = view.getUint16(0);\n\t\tthis.#slice(2);\n\t\treturn result;\n\t}\n\n\t// Returns a Number using 53-bits, the max Javascript can use for integer math.\n\tasync u53(): Promise<number> {\n\t\tconst v = await this.u62();\n\t\tif (v > Varint.MAX_U53) {\n\t\t\tthrow new Error(`value larger than 53-bits: ${v.toString()}`);\n\t\t}\n\n\t\treturn Number(v);\n\t}\n\n\t// NOTE: Returns a bigint instead of a number since it may be larger than 53-bits\n\tasync u62(): Promise<bigint> {\n\t\tif (isLeadingOnes(this.version)) {\n\t\t\treturn this.#readLeadingOnes();\n\t\t}\n\t\treturn this.#readQuicVarint();\n\t}\n\n\tasync #readQuicVarint(): Promise<bigint> {\n\t\tawait this.#fillTo(1);\n\t\tconst size = (this.#buffer[0] & 0xc0) >> 6;\n\n\t\tif (size === 0) {\n\t\t\tconst first = this.#slice(1)[0];\n\t\t\treturn BigInt(first) & 0x3fn;\n\t\t}\n\t\tif (size === 1) {\n\t\t\tawait this.#fillTo(2);\n\t\t\tconst slice = this.#slice(2);\n\t\t\tconst view = new DataView(slice.buffer, slice.byteOffset, slice.byteLength);\n\n\t\t\treturn BigInt(view.getUint16(0)) & 0x3fffn;\n\t\t}\n\t\tif (size === 2) {\n\t\t\tawait this.#fillTo(4);\n\t\t\tconst slice = this.#slice(4);\n\t\t\tconst view = new DataView(slice.buffer, slice.byteOffset, slice.byteLength);\n\n\t\t\treturn BigInt(view.getUint32(0)) & 0x3fffffffn;\n\t\t}\n\t\tawait this.#fillTo(8);\n\t\tconst slice = this.#slice(8);\n\t\tconst view = new DataView(slice.buffer, slice.byteOffset, slice.byteLength);\n\n\t\treturn view.getBigUint64(0) & 0x3fffffffffffffffn;\n\t}\n\n\tasync #readLeadingOnes(): Promise<bigint> {\n\t\tawait this.#fillTo(1);\n\t\tconst b = this.#buffer[0];\n\n\t\t// Count leading 1-bits\n\t\tlet ones = 0;\n\t\tfor (let bit = 7; bit >= 0; bit--) {\n\t\t\tif (b & (1 << bit)) ones++;\n\t\t\telse break;\n\t\t}\n\n\t\t// 1111110x is a 7-byte form. Draft-17 rejects it; draft-18+ allows it per #1595.\n\t\tif (ones === 6 && this.version === Version.DRAFT_17) {\n\t\t\tthrow new Error(\"invalid leading-ones varint: 1111110x prefix is reserved on draft-17\");\n\t\t}\n\n\t\tlet totalSize: number;\n\t\tif (ones <= 5) totalSize = ones + 1;\n\t\telse if (ones === 6) totalSize = 7;\n\t\telse if (ones === 7) totalSize = 8;\n\t\telse totalSize = 9; // ones === 8\n\n\t\tawait this.#fillTo(totalSize);\n\t\tconst slice = this.#slice(totalSize);\n\n\t\tconst [value] = Varint.decodeLeadingOnes(slice);\n\t\treturn value;\n\t}\n\n\t// Returns false if there is more data to read, blocking if it hasn't been received yet.\n\tasync done(): Promise<boolean> {\n\t\tif (this.#buffer.byteLength > 0) return false;\n\t\treturn !(await this.#fill());\n\t}\n\n\tstop(reason: unknown) {\n\t\tthis.#reader?.cancel(withCode(reason, this.version)).catch(() => void 0);\n\t}\n\n\t// Decoded like #fill: a caller racing this against a read must not get a different error\n\t// shape depending on which one won. Derived once, so racing it per frame doesn't allocate.\n\tget closed(): Promise<void> {\n\t\tthis.#closed ??= (this.#reader?.closed ?? Promise.resolve()).catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: this.version });\n\t\t});\n\t\treturn this.#closed;\n\t}\n}\n\n// Writer wraps a stream and writes chunks of data\nexport class Writer {\n\t#writer: WritableStreamDefaultWriter<Uint8Array>;\n\t#stream: WritableStream<Uint8Array>;\n\t#closed?: Promise<void>;\n\n\t// Scratch buffer for writing varints.\n\t// Fixed at 9 bytes (leading-ones max).\n\t#scratch: ArrayBuffer;\n\n\tversion?: IetfVersion;\n\n\tconstructor(stream: WritableStream<Uint8Array>, version?: IetfVersion) {\n\t\tthis.#stream = stream;\n\t\tthis.#scratch = new ArrayBuffer(9);\n\t\tthis.#writer = this.#stream.getWriter();\n\t\tthis.version = version;\n\t}\n\n\t/**\n\t * Rank this stream against the session's others, where HIGHER values are sent first.\n\t *\n\t * A send order only schedules the local end, so a stream the peer opened has to be ranked\n\t * here rather than at the peer's {@link open}.\n\t *\n\t * The spec makes `sendOrder` a settable attribute on every {@link SendStream}. Where the\n\t * interface isn't implemented (Chrome as of writing, a mock, a polyfill) this just sets an\n\t * ignored property, the same way an ignored `sendOrder` option does at {@link open}.\n\t */\n\tsetPriority(sendOrder: number) {\n\t\t(this.#stream as SendStream).sendOrder = sendOrder;\n\t}\n\n\tasync bool(v: boolean) {\n\t\tawait this.write(setUint8(this.#scratch, v ? 1 : 0));\n\t}\n\n\tasync u8(v: number) {\n\t\tif (!Number.isInteger(v) || v < 0 || v > 255) {\n\t\t\tthrow new RangeError(`invalid u8: ${v}`);\n\t\t}\n\t\tawait this.write(setUint8(this.#scratch, v));\n\t}\n\n\tasync u16(v: number) {\n\t\tawait this.write(setUint16(this.#scratch, v));\n\t}\n\n\tasync i32(v: number) {\n\t\tif (Math.abs(v) > MAX_U31) {\n\t\t\tthrow new Error(`overflow, value larger than 32-bits: ${v.toString()}`);\n\t\t}\n\n\t\t// We don't use a VarInt, so it always takes 4 bytes.\n\t\t// This could be improved but nothing is standardized yet.\n\t\tawait this.write(setInt32(this.#scratch, v));\n\t}\n\n\tasync u53(v: number) {\n\t\tif (!Number.isSafeInteger(v) || v < 0) {\n\t\t\tthrow new RangeError(`invalid u53: ${v}`);\n\t\t}\n\t\tif (isLeadingOnes(this.version)) {\n\t\t\tawait this.write(Varint.encodeLeadingOnesTo(this.#scratch, v));\n\t\t} else {\n\t\t\tawait this.write(Varint.encodeTo(this.#scratch, v));\n\t\t}\n\t}\n\n\tasync u62(v: bigint) {\n\t\tif (isLeadingOnes(this.version)) {\n\t\t\tawait this.write(Varint.encodeLeadingOnesTo(this.#scratch, v));\n\t\t} else {\n\t\t\tawait this.write(Varint.encodeTo(this.#scratch, v));\n\t\t}\n\t}\n\n\tasync write(v: Uint8Array) {\n\t\t// Mirrors Reader.#fill: every write funnels through here, so a STOP_SENDING from the\n\t\t// peer surfaces as a typed code rather than the transport's own error shape.\n\t\tawait this.#writer.write(v).catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: this.version });\n\t\t});\n\t}\n\n\tasync string(str: string) {\n\t\tconst data = new TextEncoder().encode(str);\n\t\tawait this.u53(data.byteLength);\n\t\tawait this.write(data);\n\t}\n\n\tclose() {\n\t\tthis.#writer.close().catch(() => void 0);\n\t}\n\n\t// Mirrors Reader.closed: a STOP_SENDING reaches a caller racing this with the same\n\t// typed code it would get from a write.\n\tget closed(): Promise<void> {\n\t\tthis.#closed ??= this.#writer.closed.catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: this.version });\n\t\t});\n\t\treturn this.#closed;\n\t}\n\n\treset(reason: unknown) {\n\t\tthis.#writer.abort(withCode(reason, this.version)).catch(() => void 0);\n\t}\n\n\t/**\n\t * Open an outgoing unidirectional stream.\n\t * @param quic - The session to open it on\n\t * @param options - The version its varints encode with, and the send order ranking it\n\t * against the session's other streams\n\t */\n\tstatic async open(quic: WebTransport, options?: OpenOptions): Promise<Writer> {\n\t\tconst writable = await openWithin(\n\t\t\tquic.createUnidirectionalStream(sendOptions(options)) as Promise<WritableStream<Uint8Array>>,\n\t\t\toptions?.timeout ?? OPEN_TIMEOUT_MS,\n\t\t\t(stream) => void stream.abort().catch(() => void 0),\n\t\t);\n\n\t\treturn new Writer(writable, options?.version);\n\t}\n\n\t/**\n\t * Like {@link Writer.open}, but gives up when `cancel` settles or `timeout` elapses,\n\t * returning undefined so the caller can drop whatever it meant to send. A stream that\n\t * opens after that is reset rather than leaked. A real transport failure still throws.\n\t *\n\t * Worth using even with `waitUntilAvailable: false`, since an implementation may park\n\t * an over-limit open instead of rejecting it.\n\t */\n\tstatic async tryOpen(quic: WebTransport, options: TryOpenOptions): Promise<Writer | undefined> {\n\t\t// Raced ahead of the open, so an already-cancelled caller wins even against a slot\n\t\t// that is free right now. `race` rather than `Promise.race`: the caller shares one\n\t\t// `cancel` across every group of a subscription, which must not gain a reaction per call.\n\t\tconst open = Writer.open(quic, options);\n\n\t\t// Resets a stream that opens after we gave up; a no-op if the open itself failed.\n\t\tconst abandon = () => {\n\t\t\tconst abandoned = new Error(\"abandoned waiting for a stream slot\");\n\t\t\topen.then((w) => w.reset(abandoned)).catch(() => void 0);\n\t\t};\n\n\t\ttry {\n\t\t\tconst stream = await race([options.cancel, open]);\n\t\t\tif (stream) return stream;\n\t\t} catch (err: unknown) {\n\t\t\t// open already discarded the late stream on its way out.\n\t\t\tif (err instanceof TimeoutError) return undefined;\n\t\t\t// A rejected `cancel` still leaves the open pending.\n\t\t\tabandon();\n\t\t\tthrow err;\n\t\t}\n\n\t\tabandon();\n\t\treturn undefined;\n\t}\n}\n\nfunction setUint8(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst buffer = new Uint8Array(dst, 0, 1);\n\tbuffer[0] = v;\n\treturn buffer;\n}\n\nfunction setUint16(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst view = new DataView(dst, 0, 2);\n\tview.setUint16(0, v);\n\treturn new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n}\n\nfunction setInt32(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst view = new DataView(dst, 0, 4);\n\tview.setInt32(0, v);\n\treturn new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n}\n\n// Returns the next stream from the connection\nexport class Readers {\n\t#reader: ReadableStreamDefaultReader<ReadableStream<Uint8Array>>;\n\t#version?: IetfVersion;\n\n\tconstructor(quic: WebTransport, version?: IetfVersion) {\n\t\tthis.#reader = quic.incomingUnidirectionalStreams.getReader() as ReadableStreamDefaultReader<\n\t\t\tReadableStream<Uint8Array>\n\t\t>;\n\t\tthis.#version = version;\n\t}\n\n\tasync next(): Promise<Reader | undefined> {\n\t\tconst next = await this.#reader.read();\n\t\tif (next.done) return;\n\t\treturn new Reader(next.value, undefined, this.#version);\n\t}\n\n\tclose() {\n\t\tthis.#reader.cancel();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE/F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,IAAI,EAA+B,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,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G,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,QAAQ,CAAC,GAAgB,EAAE,CAAS;IAC5C,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AAED,8CAA8C;AAC9C,MAAM,OAAO,OAAO;IACnB,OAAO,CAA0D;IACjE,QAAQ,CAAgB;IAExB,YAAY,IAAkB,EAAE,OAAsB;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,6BAA6B,CAAC,SAAS,EAE1D,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACT,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO;QACtB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACD","sourcesContent":["import { race } from \"@moq/signals\";\nimport { fromTransport, StreamCode, StreamError, toStreamCode, toTransport } from \"./error.ts\";\nimport type { IetfVersion } from \"./ietf/version.ts\";\nimport { Version } from \"./ietf/version.ts\";\nimport { Version as Lite, type Version as LiteVersion } from \"./lite/version.ts\";\nimport { TimeoutError, withTimeout } from \"./util/timeout.ts\";\nimport { POW32, toBigInt, toNumber, U64 } from \"./util/u64.ts\";\nimport { decodeUtf8 } from \"./util/utf8.ts\";\nimport {\n\tlengthLeadingOnes,\n\tlengthQuic,\n\tparts,\n\tpeekLeadingOnes,\n\tpeekQuic,\n\treadLeadingOnes,\n\treadQuic,\n\tsplit,\n\twriteLeadingOnes,\n\twriteQuic,\n} from \"./util/varint.ts\";\n\n// Decode raw transport errors before mapping so they cannot bypass the negotiated\n// registry. Ordinary errors already send 0 and retain their local identity.\nfunction withCode(reason: unknown, stream: StreamVersion): unknown {\n\tconst version = asIetf(stream);\n\tconst decoded = fromTransport(reason, { version });\n\tconst code = toStreamCode(decoded, { version });\n\treturn code === StreamCode.Internal && decoded === reason ? reason : toTransport(code, decoded.message);\n}\n\nconst MAX_U31 = 2 ** 31 - 1;\nconst MAX_READ_SIZE = 1024 * 1024 * 64; // don't allocate more than 64MB for a message\n\n/**\n * Options handed to the transport for one outgoing stream.\n *\n * `waitUntilAvailable` waits for the peer's concurrent stream limit to free a slot instead\n * of rejecting with a `QuotaExceededError`, which is what we want for the streams a session\n * opens occasionally. `@types/web` doesn't declare it yet, hence the intersection.\n */\nexport function sendOptions(options?: OpenOptions): WebTransportSendStreamOptions & { waitUntilAvailable?: boolean } {\n\treturn { sendOrder: options?.sendOrder, waitUntilAvailable: options?.waitUntilAvailable ?? true };\n}\n\n// How long any open may wait for the peer to free a stream slot. Every open needs this,\n// whether or not it asked to wait: an implementation may park an over-limit open rather\n// than rejecting it, and a peer can advertise a stream limit of zero and never raise it.\n// Matches the subscribe budget.\nconst OPEN_TIMEOUT_MS = 10_000;\n\n/**\n * Bound an open that would otherwise park until the peer grants stream credit, restoring\n * the pre-waitUntilAvailable failure after a grace period. A stream arriving after the\n * deadline is discarded, since nobody is waiting for it any more.\n */\nasync function openWithin<T>(opening: Promise<T>, timeout: number, discard: (stream: T) => void): Promise<T> {\n\ttry {\n\t\treturn await withTimeout(opening, timeout, `stream open timed out after ${timeout}ms waiting for a slot`);\n\t} catch (err: unknown) {\n\t\topening.then(discard).catch(() => void 0);\n\t\tthrow err;\n\t}\n}\n\n/**\n * The version a stream's bytes follow: a moq-transport draft or a moq-lite draft. Required on\n * every stream so the varint form never defaults silently; a stream opened before negotiation\n * names the version its handshake is encoded with.\n */\nexport type StreamVersion = IetfVersion | LiteVersion;\n\nconst LITE: ReadonlySet<number> = new Set(Object.values(Lite));\n\nfunction isLite(version: StreamVersion): version is LiteVersion {\n\treturn LITE.has(version);\n}\n\n/** The moq-transport draft a stream follows, or undefined on moq-lite, whose stream codes are the same on every draft. */\nexport function asIetf(version: StreamVersion): IetfVersion | undefined {\n\treturn isLite(version) ? undefined : version;\n}\n\n// Every draft newer than these counts leading ones, so a new version falls forward.\nfunction isLeadingOnes(version: StreamVersion): boolean {\n\tswitch (version) {\n\t\tcase Version.DRAFT_14:\n\t\tcase Version.DRAFT_15:\n\t\tcase Version.DRAFT_16:\n\t\tcase Lite.DRAFT_01:\n\t\tcase Lite.DRAFT_02:\n\t\tcase Lite.DRAFT_03:\n\t\tcase Lite.DRAFT_04:\n\t\tcase Lite.DRAFT_05:\n\t\tcase Lite.DRAFT_06:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n\n// Encode `hi`/`lo` into `dst` in the varint form `version` uses: QUIC up to 2^62-1, leading-ones up to 2^64-1.\nfunction encodeTo(dst: ArrayBuffer, hi: number, lo: number, version: StreamVersion): Uint8Array {\n\tlet buf: Uint8Array;\n\tif (isLeadingOnes(version)) {\n\t\tbuf = new Uint8Array(dst, 0, lengthLeadingOnes(hi, lo));\n\t\twriteLeadingOnes(buf, hi, lo, buf.length);\n\t} else {\n\t\tbuf = new Uint8Array(dst, 0, lengthQuic(hi, lo));\n\t\twriteQuic(buf, hi, lo, buf.length);\n\t}\n\treturn buf;\n}\n\n/** Encode one varint in the form `version` uses, for a body written outside a {@link Writer}. */\nexport function encodeVarint(v: number | bigint, version: StreamVersion): Uint8Array {\n\tconst lo = split(v);\n\treturn encodeTo(new ArrayBuffer(9), parts.hi, lo, version);\n}\n\n/**\n * The `WebTransportSendStream` that every outgoing stream is, narrowed to the one attribute\n * this package uses. The DOM types available here still describe them as plain\n * `WritableStream`s, so the interface has to be named structurally.\n *\n * `sendOrder` is optional because it is absent until set, and stays absent on an\n * implementation that doesn't carry the interface at all.\n *\n * @see https://www.w3.org/TR/webtransport/#webtransportsendstream\n */\nexport type SendStream = WritableStream<Uint8Array> & { sendOrder?: number };\n\n/** Options for opening an outgoing stream. */\nexport interface OpenOptions {\n\t/** The negotiated version, which selects the varint encoding. */\n\tversion: StreamVersion;\n\n\t/**\n\t * The transport send order, where HIGHER values are transmitted first.\n\t * Left to the transport's default when unset.\n\t */\n\tsendOrder?: number;\n\n\t/**\n\t * Reject if the peer hasn't freed a stream slot within this many milliseconds. Defaults\n\t * to 10s. There is no way to wait indefinitely: a peer can advertise a stream limit of\n\t * zero and never raise it, so every open needs a way out.\n\t */\n\ttimeout?: number;\n\n\t/**\n\t * Ask the transport to wait for a stream slot rather than failing when the peer's\n\t * concurrent stream limit is exhausted. Defaults to true.\n\t *\n\t * Set it false on a path that opens streams faster than the peer can retire them. The\n\t * transport queues the opens it can't satisfy and serves them in order, with no way to\n\t * cancel one, so waiting there spends returning credit on whatever was requested first\n\t * rather than on what matters now.\n\t */\n\twaitUntilAvailable?: boolean;\n}\n\n/** Options for {@link Writer.tryOpen}. */\nexport interface TryOpenOptions extends OpenOptions {\n\t/** Give up once this resolves. */\n\tcancel: Promise<void>;\n}\n\nexport class Stream {\n\treader: Reader;\n\twriter: Writer;\n\n\t/** Wrap the two halves of a transport stream. */\n\tconstructor(props: {\n\t\twritable: WritableStream<Uint8Array>;\n\t\treadable: ReadableStream<Uint8Array>;\n\t\tversion: StreamVersion;\n\t});\n\t/** Pair halves that were opened separately, as the SETUP exchange does. */\n\tconstructor(props: { writer: Writer; reader: Reader });\n\tconstructor(props: {\n\t\twritable?: WritableStream<Uint8Array>;\n\t\treadable?: ReadableStream<Uint8Array>;\n\t\twriter?: Writer;\n\t\treader?: Reader;\n\t\tversion?: StreamVersion;\n\t}) {\n\t\tconst version = props.version;\n\t\tconst writer = props.writer ?? (props.writable && version !== undefined && new Writer(props.writable, version));\n\t\tconst reader =\n\t\t\tprops.reader ?? (props.readable && version !== undefined && new Reader(props.readable, undefined, version));\n\t\tif (!writer || !reader) throw new Error(\"stream needs both halves\");\n\n\t\tthis.writer = writer;\n\t\tthis.reader = reader;\n\t}\n\n\tstatic async accept(quic: WebTransport, version: StreamVersion): Promise<Stream | undefined> {\n\t\tfor (;;) {\n\t\t\tconst reader =\n\t\t\t\tquic.incomingBidirectionalStreams.getReader() as ReadableStreamDefaultReader<WebTransportBidirectionalStream>;\n\t\t\tconst next = await reader.read();\n\t\t\treader.releaseLock();\n\n\t\t\tif (next.done) return;\n\t\t\tconst { readable, writable } = next.value;\n\t\t\treturn new Stream({ readable, writable, version });\n\t\t}\n\t}\n\n\t/**\n\t * Open an outgoing bidirectional stream.\n\t * @param quic - The session to open it on\n\t * @param options - The version its varints encode with, and the send order ranking it\n\t * against the session's other streams\n\t */\n\tstatic async open(quic: WebTransport, options: OpenOptions): Promise<Stream> {\n\t\tconst { readable, writable } = await openWithin(\n\t\t\tquic.createBidirectionalStream(sendOptions(options)),\n\t\t\toptions?.timeout ?? OPEN_TIMEOUT_MS,\n\t\t\t(stream) => {\n\t\t\t\tvoid stream.writable.abort().catch(() => void 0);\n\t\t\t\tvoid stream.readable.cancel().catch(() => void 0);\n\t\t\t},\n\t\t);\n\t\treturn new Stream({ readable, writable, version: options.version });\n\t}\n\n\tclose() {\n\t\tthis.writer.close();\n\t\t// A routine unsubscribe, so send CANCELLED. A bare Error would put 0 on the wire,\n\t\t// which the stream registry reads as INTERNAL_ERROR: the peer would log a failure\n\t\t// for every subscription we walk away from.\n\t\tthis.reader.stop(new StreamError(StreamCode.Cancel, { message: \"cancel\" }));\n\t}\n\n\tabort(reason: Error) {\n\t\tthis.writer.reset(reason);\n\t\tthis.reader.stop(reason);\n\t}\n}\n\n// Reader wraps a stream and provides convience methods for reading pieces from a stream\n// Unfortunately we can't use a BYOB reader because it's not supported with WebTransport+WebWorkers yet.\nexport class Reader {\n\t// Contiguous unread bytes, followed by chunks not yet joined onto it. Joining only once a\n\t// read needs the bytes keeps a frame arriving in N chunks linear rather than quadratic.\n\t#buffer: Uint8Array;\n\t#chunks: Uint8Array[] = [];\n\t#chunked = 0; // bytes across #chunks\n\t#stream?: ReadableStream<Uint8Array>; // if undefined, the buffer is consumed then EOF\n\t#reader?: ReadableStreamDefaultReader<Uint8Array>;\n\t#closed?: Promise<void>;\n\t// The decode that last ran short and how far, so a retry can wait for those bytes.\n\t#short?: { decode: (c: Cursor) => unknown; err: Short };\n\tversion: StreamVersion;\n\n\t// Either stream or buffer MUST be provided.\n\tconstructor(stream: ReadableStream<Uint8Array>, buffer: Uint8Array | undefined, version: StreamVersion);\n\tconstructor(stream: undefined, buffer: Uint8Array, version: StreamVersion);\n\tconstructor(\n\t\tstream: ReadableStream<Uint8Array> | undefined,\n\t\tbuffer: Uint8Array | undefined,\n\t\tversion: StreamVersion,\n\t) {\n\t\tthis.#buffer = buffer ?? new Uint8Array();\n\t\tthis.#stream = stream;\n\t\tthis.#reader = this.#stream?.getReader();\n\t\tthis.version = version;\n\t}\n\n\t// Adds more data to the buffer, returning true if more data was added.\n\tasync #fill(): Promise<boolean> {\n\t\tif (!this.#reader) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Every read of this stream funnels through here, so decoding the peer's reset code\n\t\t// once is enough to keep the raw transport error out of every caller (and every app).\n\t\tconst result = await this.#reader.read().catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\n\t\tif (result.done) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (result.value.byteLength === 0) {\n\t\t\tthrow new Error(\"unexpected empty chunk\");\n\t\t}\n\n\t\tthis.#chunks.push(result.value);\n\t\tthis.#chunked += result.value.byteLength;\n\n\t\treturn true;\n\t}\n\n\t// Add more data to the buffer until it's at least size bytes.\n\tasync #fillTo(size: number) {\n\t\tif (size > MAX_READ_SIZE) {\n\t\t\tthrow new Error(`read size ${size} exceeds max size ${MAX_READ_SIZE}`);\n\t\t}\n\n\t\tif (this.#buffer.byteLength >= size) return;\n\n\t\twhile (this.#buffer.byteLength + this.#chunked < size) {\n\t\t\tif (!(await this.#fill())) {\n\t\t\t\tthrow new UnexpectedEnd();\n\t\t\t}\n\t\t}\n\n\t\tthis.#join();\n\t}\n\n\t// Move every pending chunk into the buffer, copying only when there's more than one piece.\n\t#join() {\n\t\tif (this.#chunks.length === 0) return;\n\n\t\tif (this.#buffer.byteLength === 0 && this.#chunks.length === 1) {\n\t\t\tthis.#buffer = this.#chunks[0];\n\t\t} else {\n\t\t\tconst joined = new Uint8Array(this.#buffer.byteLength + this.#chunked);\n\t\t\tjoined.set(this.#buffer);\n\t\t\tlet offset = this.#buffer.byteLength;\n\t\t\tfor (const chunk of this.#chunks) {\n\t\t\t\tjoined.set(chunk, offset);\n\t\t\t\toffset += chunk.byteLength;\n\t\t\t}\n\t\t\tthis.#buffer = joined;\n\t\t}\n\n\t\tthis.#chunks = [];\n\t\tthis.#chunked = 0;\n\t}\n\n\t// Consumes the first size bytes of the buffer.\n\t#slice(size: number): Uint8Array {\n\t\tconst result = new Uint8Array(this.#buffer.buffer, this.#buffer.byteOffset, size);\n\t\tthis.#buffer = new Uint8Array(\n\t\t\tthis.#buffer.buffer,\n\t\t\tthis.#buffer.byteOffset + size,\n\t\t\tthis.#buffer.byteLength - size,\n\t\t);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Run a synchronous decode over the buffered bytes and consume what it read.\n\t *\n\t * Returns undefined and consumes nothing when the decode ran past the buffered bytes, so a\n\t * caller can drain every complete message already here without waiting on the stream.\n\t */\n\ttryDecode<T extends NonNullable<unknown>>(decode: (c: Cursor) => T): T | undefined {\n\t\tconst result = this.#try(decode);\n\t\treturn result instanceof Short ? undefined : result;\n\t}\n\n\t/** Run a synchronous decode, filling from the stream until it has the bytes it needs. */\n\tasync decode<T>(decode: (c: Cursor) => T): Promise<T> {\n\t\tfor (;;) {\n\t\t\tconst result = this.#try(decode);\n\t\t\tif (!(result instanceof Short)) return result;\n\t\t\tawait this.#fillTo(result.need);\n\t\t}\n\t}\n\n\t// Like decode, but leaves the bytes buffered for the next read.\n\tasync #peek<T>(decode: (c: Cursor) => T): Promise<T> {\n\t\tfor (;;) {\n\t\t\tconst result = this.#try(decode, false);\n\t\t\tif (!(result instanceof Short)) return result;\n\t\t\tawait this.#fillTo(result.need);\n\t\t}\n\t}\n\n\t/** Like {@link decode}, but returns undefined if the stream ends cleanly first. */\n\tasync decodeMaybe<T>(decode: (c: Cursor) => T): Promise<T | undefined> {\n\t\tif (await this.done()) return undefined;\n\t\treturn this.decode(decode);\n\t}\n\n\t#try<T>(decode: (c: Cursor) => T, consume = true): T | Short {\n\t\t// A retry of the decode that last ran short, before the bytes it needs have arrived,\n\t\t// would only throw again. Every decode reads at least a byte, so none can succeed on\n\t\t// an empty buffer either.\n\t\tconst available = this.#buffer.byteLength + this.#chunked;\n\t\tif (available === 0) return EMPTY;\n\t\tif (decode === this.#short?.decode && available < this.#short.err.need) return this.#short.err;\n\n\t\tthis.#join();\n\t\tconst cursor = new Cursor(this.#buffer, this.version);\n\t\ttry {\n\t\t\tconst result = decode(cursor);\n\t\t\tif (consume) this.#slice(cursor.offset);\n\t\t\tthis.#short = undefined;\n\t\t\treturn result;\n\t\t} catch (err: unknown) {\n\t\t\tif (!(err instanceof Short)) throw err;\n\t\t\t// Filling could never satisfy it, so retrying would spin.\n\t\t\tif (err.need <= this.#buffer.byteLength) throw new Error(\"decode ran short of bytes it already had\");\n\t\t\tthis.#short = { decode, err };\n\t\t\treturn err;\n\t\t}\n\t}\n\n\tasync read(size: number): Promise<Uint8Array> {\n\t\tif (size === 0) return new Uint8Array();\n\t\treturn this.decode((c) => c.read(size));\n\t}\n\n\tasync readAll(): Promise<Uint8Array> {\n\t\twhile (await this.#fill()) {\n\t\t\t// keep going\n\t\t}\n\t\tthis.#join();\n\t\treturn this.#slice(this.#buffer.byteLength);\n\t}\n\n\t// Reads to the end of the stream, dropping every byte instead of buffering it.\n\tasync discard(): Promise<void> {\n\t\tthis.#buffer = new Uint8Array();\n\t\tdo {\n\t\t\tthis.#chunks = [];\n\t\t\tthis.#chunked = 0;\n\t\t} while (await this.#fill());\n\t}\n\n\tasync string(): Promise<string> {\n\t\treturn this.decode(STRING);\n\t}\n\n\tasync bool(): Promise<boolean> {\n\t\treturn this.decode(BOOL);\n\t}\n\n\tasync u8(): Promise<number> {\n\t\treturn this.decode(U8);\n\t}\n\n\tasync u16(): Promise<number> {\n\t\treturn this.decode(U16);\n\t}\n\n\t// Returns a Number using 53-bits, the max Javascript can use for integer math.\n\tasync u53(): Promise<number> {\n\t\treturn this.decode(U53);\n\t}\n\n\t// NOTE: Returns a bigint instead of a number since it may be larger than 53-bits\n\tasync u62(): Promise<bigint> {\n\t\treturn this.decode(U62);\n\t}\n\n\t/** Like {@link u62}, but leaves the varint buffered, so a stream's type can be read twice. */\n\tasync peekU62(): Promise<bigint> {\n\t\treturn this.#peek(U62);\n\t}\n\n\tasync varint(): Promise<U64> {\n\t\treturn this.decode(VARINT);\n\t}\n\n\t// Returns false if there is more data to read, blocking if it hasn't been received yet.\n\tasync done(): Promise<boolean> {\n\t\tif (this.#buffer.byteLength > 0 || this.#chunked > 0) return false;\n\t\treturn !(await this.#fill());\n\t}\n\n\tstop(reason: unknown) {\n\t\tthis.#reader?.cancel(withCode(reason, this.version)).catch(() => void 0);\n\t}\n\n\t// Decoded like #fill: a caller racing this against a read must not get a different error\n\t// shape depending on which one won. Derived once, so racing it per frame doesn't allocate.\n\tget closed(): Promise<void> {\n\t\tthis.#closed ??= (this.#reader?.closed ?? Promise.resolve()).catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\t\treturn this.#closed;\n\t}\n}\n\n/** The stream ended cleanly partway through a read. */\nexport class UnexpectedEnd extends Error {\n\tconstructor() {\n\t\tsuper(\"unexpected end of stream\");\n\t}\n}\n\n// Thrown by a Cursor read that runs past the buffered bytes, carrying how many bytes from the\n// start of the buffer the decode needs. Not an Error: it ends every chunk, so it must not\n// capture a stack.\nclass Short {\n\treadonly need: number;\n\n\tconstructor(need: number) {\n\t\tthis.need = need;\n\t}\n}\n\nconst EMPTY = new Short(1);\n\n/**\n * A synchronous view over a {@link Reader}'s buffered bytes, handed to {@link Reader.decode}.\n *\n * A read past the buffered bytes throws an internal signal that the Reader catches: it consumes\n * nothing, fills, and runs the decode again from the start. A decode must therefore not mutate\n * anything before its last read, must not swallow what it throws, and must read at least a byte.\n */\nexport class Cursor {\n\treadonly version: StreamVersion;\n\t#buffer: Uint8Array;\n\t#offset = 0;\n\t// Resolved once, since every varint read branches on it.\n\t#leadingOnes: boolean;\n\t// First bytes below this are a whole 1-byte varint, and below this + 0x40 a 2-byte one whose\n\t// value is the low 6 bits and the next byte. Both formats share that shape; only the bound moves.\n\t#short: number;\n\t// First bytes below this are a varint of at most 4 bytes: 0xc0 for QUIC, 0xf0 for leading-ones.\n\t#word: number;\n\n\tconstructor(buffer: Uint8Array, version: StreamVersion) {\n\t\tthis.#buffer = buffer;\n\t\tthis.version = version;\n\t\tthis.#leadingOnes = isLeadingOnes(version);\n\t\tthis.#short = this.#leadingOnes ? 0x80 : 0x40;\n\t\tthis.#word = this.#leadingOnes ? 0xf0 : 0xc0;\n\t}\n\n\t/** How many bytes have been read. */\n\tget offset(): number {\n\t\treturn this.#offset;\n\t}\n\n\t/** How many buffered bytes are left to read. */\n\tget remaining(): number {\n\t\treturn this.#buffer.byteLength - this.#offset;\n\t}\n\n\t/**\n\t * Decode the next `size` bytes on their own. Running past them, or leaving any unread, is\n\t * malformed rather than a reason to wait for more.\n\t */\n\texact<T>(size: number, decode: (c: Cursor) => T): T {\n\t\tconst inner = new Cursor(this.read(size), this.version);\n\t\tlet result: T;\n\t\ttry {\n\t\t\tresult = decode(inner);\n\t\t} catch (err: unknown) {\n\t\t\tif (err instanceof Short) throw new Error(`message is shorter than its fields: ${size} bytes`);\n\t\t\tthrow err;\n\t\t}\n\t\tif (inner.remaining > 0) throw new Error(`message has ${inner.remaining} unread bytes`);\n\t\treturn result;\n\t}\n\n\t#ensure(size: number) {\n\t\tconst need = this.#offset + size;\n\t\t// Checked here too, and on the whole decode like the fill, since bytes that are already\n\t\t// buffered never reach the fill.\n\t\tif (need > MAX_READ_SIZE) throw new Error(`read size ${need} exceeds max size ${MAX_READ_SIZE}`);\n\t\tif (need > this.#buffer.byteLength) throw new Short(need);\n\t}\n\n\t/** Read `size` bytes, as a view onto the buffer rather than a copy. */\n\tread(size: number): Uint8Array {\n\t\tthis.#ensure(size);\n\t\tconst start = this.#offset;\n\t\tthis.#offset += size;\n\t\treturn this.#buffer.subarray(start, this.#offset);\n\t}\n\n\tstring(): string {\n\t\treturn decodeUtf8(this.read(this.u53()));\n\t}\n\n\tbool(): boolean {\n\t\tconst v = this.u8();\n\t\tif (v === 0) return false;\n\t\tif (v === 1) return true;\n\t\tthrow new Error(\"invalid bool value\");\n\t}\n\n\tu8(): number {\n\t\tthis.#ensure(1);\n\t\treturn this.#buffer[this.#offset++];\n\t}\n\n\tu16(): number {\n\t\tthis.#ensure(2);\n\t\tconst b = this.#buffer;\n\t\tconst o = this.#offset;\n\t\tthis.#offset += 2;\n\t\treturn (b[o] << 8) | b[o + 1];\n\t}\n\n\t/** Read a varint as a `number`, throwing if it is above `Number.MAX_SAFE_INTEGER`. */\n\tu53(): number {\n\t\t// Most varints are 1 or 2 bytes, which skip the general decode.\n\t\tthis.#ensure(1);\n\t\tconst b = this.#buffer;\n\t\tconst o = this.#offset;\n\t\tconst first = b[o];\n\t\tif (first < this.#short) {\n\t\t\tthis.#offset = o + 1;\n\t\t\treturn first;\n\t\t}\n\t\tif (first < this.#short + 0x40) {\n\t\t\tthis.#ensure(2);\n\t\t\tthis.#offset = o + 2;\n\t\t\treturn ((first & 0x3f) << 8) | b[o + 1];\n\t\t}\n\t\t// Up to 4 bytes still fits 28 (leading-ones) or 30 (QUIC) bits, with no upper half.\n\t\tif (first < this.#word) {\n\t\t\tconst size = this.#leadingOnes ? peekLeadingOnes(first) : 4;\n\t\t\tthis.#ensure(size);\n\t\t\tthis.#offset = o + size;\n\t\t\tif (size === 3) return ((first & 0x1f) << 16) | (b[o + 1] << 8) | b[o + 2];\n\t\t\treturn ((first & (this.#leadingOnes ? 0x0f : 0x3f)) << 24) | (b[o + 1] << 16) | (b[o + 2] << 8) | b[o + 3];\n\t\t}\n\t\tconst lo = this.#varint();\n\t\treturn toNumber(parts.hi, lo);\n\t}\n\n\t/** Read a varint as a bigint. A leading-ones varint may exceed 62 bits. */\n\tu62(): bigint {\n\t\tconst lo = this.#varint();\n\t\treturn toBigInt(parts.hi, lo);\n\t}\n\n\t/** Read a varint. */\n\tvarint(): U64 {\n\t\tconst lo = this.#varint();\n\t\treturn new U64(parts.hi, lo);\n\t}\n\n\t// Decode the next varint in the version's format, returning its lower half and leaving the upper in `parts`.\n\t#varint(): number {\n\t\tthis.#ensure(1);\n\t\tconst b = this.#buffer;\n\t\tconst o = this.#offset;\n\t\tlet size: number;\n\t\tif (this.#leadingOnes) {\n\t\t\tsize = peekLeadingOnes(b[o]);\n\t\t\t// 1111110x is a 7-byte form. Draft-17 rejects it; draft-18+ allows it per #1595.\n\t\t\tif (size === 7 && this.version === Version.DRAFT_17) {\n\t\t\t\tthrow new Error(\"invalid leading-ones varint: 1111110x prefix is reserved on draft-17\");\n\t\t\t}\n\t\t\tthis.#ensure(size);\n\t\t\tthis.#offset += size;\n\t\t\treturn readLeadingOnes(b, o, size);\n\t\t}\n\t\tsize = peekQuic(b[o]);\n\t\tthis.#ensure(size);\n\t\tthis.#offset += size;\n\t\treturn readQuic(b, o, size);\n\t}\n}\n\n// Shared decodes for the Reader's async primitives, so a read allocates no closure.\nconst STRING = (c: Cursor) => c.string();\nconst BOOL = (c: Cursor) => c.bool();\nconst U8 = (c: Cursor) => c.u8();\nconst U16 = (c: Cursor) => c.u16();\nconst U53 = (c: Cursor) => c.u53();\nconst U62 = (c: Cursor) => c.u62();\nconst VARINT = (c: Cursor) => c.varint();\n\n// Writer wraps a stream and writes chunks of data\nexport class Writer {\n\t#writer: WritableStreamDefaultWriter<Uint8Array>;\n\t#stream: WritableStream<Uint8Array>;\n\t#closed?: Promise<void>;\n\n\t// Scratch buffer for each primitive write, sized for the longest (a 9-byte leading-ones varint).\n\t#scratch: ArrayBuffer;\n\n\tversion: StreamVersion;\n\n\tconstructor(stream: WritableStream<Uint8Array>, version: StreamVersion) {\n\t\tthis.#stream = stream;\n\t\tthis.#scratch = new ArrayBuffer(9);\n\t\tthis.#writer = this.#stream.getWriter();\n\t\tthis.version = version;\n\t}\n\n\t/**\n\t * Rank this stream against the session's others, where HIGHER values are sent first.\n\t *\n\t * A send order only schedules the local end, so a stream the peer opened has to be ranked\n\t * here rather than at the peer's {@link open}.\n\t *\n\t * The spec makes `sendOrder` a settable attribute on every {@link SendStream}. Where the\n\t * interface isn't implemented (Chrome as of writing, a mock, a polyfill) this just sets an\n\t * ignored property, the same way an ignored `sendOrder` option does at {@link open}.\n\t */\n\tsetPriority(sendOrder: number) {\n\t\t(this.#stream as SendStream).sendOrder = sendOrder;\n\t}\n\n\tasync bool(v: boolean) {\n\t\tawait this.write(setUint8(this.#scratch, v ? 1 : 0));\n\t}\n\n\tasync u8(v: number) {\n\t\tif (!Number.isInteger(v) || v < 0 || v > 255) {\n\t\t\tthrow new RangeError(`invalid u8: ${v}`);\n\t\t}\n\t\tawait this.write(setUint8(this.#scratch, v));\n\t}\n\n\tasync u16(v: number) {\n\t\tawait this.write(setUint16(this.#scratch, v));\n\t}\n\n\tasync i32(v: number) {\n\t\tif (Math.abs(v) > MAX_U31) {\n\t\t\tthrow new Error(`overflow, value larger than 32-bits: ${v.toString()}`);\n\t\t}\n\n\t\t// We don't use a varint, so it always takes 4 bytes.\n\t\t// This could be improved but nothing is standardized yet.\n\t\tawait this.write(setInt32(this.#scratch, v));\n\t}\n\n\tasync u53(v: number) {\n\t\tif (!Number.isSafeInteger(v) || v < 0) {\n\t\t\tthrow new RangeError(`invalid u53: ${v}`);\n\t\t}\n\t\tawait this.#varint(Math.floor(v / POW32), v >>> 0);\n\t}\n\n\tasync u62(v: bigint) {\n\t\tconst lo = split(v);\n\t\tawait this.#varint(parts.hi, lo);\n\t}\n\n\tasync varint(v: U64) {\n\t\tawait this.#varint(v.hi, v.lo);\n\t}\n\n\t#varint(hi: number, lo: number): Promise<void> {\n\t\treturn this.write(encodeTo(this.#scratch, hi, lo, this.version));\n\t}\n\n\tasync write(v: Uint8Array) {\n\t\t// Mirrors Reader.#fill: every write funnels through here, so a STOP_SENDING from the\n\t\t// peer surfaces as a typed code rather than the transport's own error shape.\n\t\tawait this.#writer.write(v).catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\t}\n\n\tasync string(str: string) {\n\t\tconst data = new TextEncoder().encode(str);\n\t\tawait this.u53(data.byteLength);\n\t\tawait this.write(data);\n\t}\n\n\tclose() {\n\t\tthis.#writer.close().catch(() => void 0);\n\t}\n\n\t// Mirrors Reader.closed: a STOP_SENDING reaches a caller racing this with the same\n\t// typed code it would get from a write.\n\tget closed(): Promise<void> {\n\t\tthis.#closed ??= this.#writer.closed.catch((err: unknown) => {\n\t\t\tthrow fromTransport(err, { version: asIetf(this.version) });\n\t\t});\n\t\treturn this.#closed;\n\t}\n\n\treset(reason: unknown) {\n\t\tthis.#writer.abort(withCode(reason, this.version)).catch(() => void 0);\n\t}\n\n\t/**\n\t * Open an outgoing unidirectional stream.\n\t * @param quic - The session to open it on\n\t * @param options - The version its varints encode with, and the send order ranking it\n\t * against the session's other streams\n\t */\n\tstatic async open(quic: WebTransport, options: OpenOptions): Promise<Writer> {\n\t\tconst writable = await openWithin(\n\t\t\tquic.createUnidirectionalStream(sendOptions(options)) as Promise<WritableStream<Uint8Array>>,\n\t\t\toptions?.timeout ?? OPEN_TIMEOUT_MS,\n\t\t\t(stream) => void stream.abort().catch(() => void 0),\n\t\t);\n\n\t\treturn new Writer(writable, options.version);\n\t}\n\n\t/**\n\t * Like {@link Writer.open}, but gives up when `cancel` settles or `timeout` elapses,\n\t * returning undefined so the caller can drop whatever it meant to send. A stream that\n\t * opens after that is reset rather than leaked. A real transport failure still throws.\n\t *\n\t * Worth using even with `waitUntilAvailable: false`, since an implementation may park\n\t * an over-limit open instead of rejecting it.\n\t */\n\tstatic async tryOpen(quic: WebTransport, options: TryOpenOptions): Promise<Writer | undefined> {\n\t\t// Raced ahead of the open, so an already-cancelled caller wins even against a slot\n\t\t// that is free right now. `race` rather than `Promise.race`: the caller shares one\n\t\t// `cancel` across every group of a subscription, which must not gain a reaction per call.\n\t\tconst open = Writer.open(quic, options);\n\n\t\t// Resets a stream that opens after we gave up; a no-op if the open itself failed.\n\t\tconst abandon = () => {\n\t\t\tconst abandoned = new Error(\"abandoned waiting for a stream slot\");\n\t\t\topen.then((w) => w.reset(abandoned)).catch(() => void 0);\n\t\t};\n\n\t\ttry {\n\t\t\tconst stream = await race([options.cancel, open]);\n\t\t\tif (stream) return stream;\n\t\t} catch (err: unknown) {\n\t\t\t// open already discarded the late stream on its way out.\n\t\t\tif (err instanceof TimeoutError) return undefined;\n\t\t\t// A rejected `cancel` still leaves the open pending.\n\t\t\tabandon();\n\t\t\tthrow err;\n\t\t}\n\n\t\tabandon();\n\t\treturn undefined;\n\t}\n}\n\nfunction setUint8(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst buffer = new Uint8Array(dst, 0, 1);\n\tbuffer[0] = v;\n\treturn buffer;\n}\n\nfunction setUint16(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst view = new DataView(dst, 0, 2);\n\tview.setUint16(0, v);\n\treturn new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n}\n\nfunction setInt32(dst: ArrayBuffer, v: number): Uint8Array {\n\tconst view = new DataView(dst, 0, 4);\n\tview.setInt32(0, v);\n\treturn new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n}\n\n// Returns the next stream from the connection\nexport class Readers {\n\t#reader: ReadableStreamDefaultReader<ReadableStream<Uint8Array>>;\n\t#version: StreamVersion;\n\n\tconstructor(quic: WebTransport, version: StreamVersion) {\n\t\tthis.#reader = quic.incomingUnidirectionalStreams.getReader() as ReadableStreamDefaultReader<\n\t\t\tReadableStream<Uint8Array>\n\t\t>;\n\t\tthis.#version = version;\n\t}\n\n\tasync next(): Promise<Reader | undefined> {\n\t\tconst next = await this.#reader.read();\n\t\tif (next.done) return;\n\t\treturn new Reader(next.value, undefined, this.#version);\n\t}\n\n\tclose() {\n\t\tthis.#reader.cancel();\n\t}\n}\n"]}
|
package/tail.d.ts
CHANGED
|
@@ -8,4 +8,11 @@ import { Milli } from "./time";
|
|
|
8
8
|
* IETF, and on moq-lite when the subscription has no max age to bound it with.
|
|
9
9
|
*/
|
|
10
10
|
export declare const TAIL_GRACE_MS: Milli;
|
|
11
|
+
/** How a {@link Tail} measures its grace. */
|
|
12
|
+
export interface TailOptions {
|
|
13
|
+
/** How long to wait for a group that cannot be accounted for. Read each time it is needed. */
|
|
14
|
+
grace?: () => Milli;
|
|
15
|
+
/** The clock, in `performance.now()` milliseconds. */
|
|
16
|
+
now?: () => number;
|
|
17
|
+
}
|
|
11
18
|
//# sourceMappingURL=tail.d.ts.map
|
package/tail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tail.d.ts","sourceRoot":"","sources":["../src/tail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,OAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"tail.d.ts","sourceRoot":"","sources":["../src/tail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,OAAc,CAAC;AASzC,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC3B,8FAA8F;IAC9F,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;IACpB,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACnB"}
|
package/tail.js
CHANGED
|
@@ -20,16 +20,27 @@ const MAX_TIMEOUT_MS = 2 ** 31 - 1;
|
|
|
20
20
|
* the publisher dropped them) and how many streams are still being read, and {@link settle}
|
|
21
21
|
* waits on them.
|
|
22
22
|
*
|
|
23
|
+
* A lost datagram is not owed: it leaves a hole that waits out the grace like a stream reset
|
|
24
|
+
* before its header.
|
|
25
|
+
*
|
|
23
26
|
* @internal
|
|
24
27
|
*/
|
|
25
28
|
export class Tail {
|
|
26
|
-
// Disjoint, sorted,
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
+
// Disjoint, sorted, non-adjacent runs of accounted sequences. A gap older than the grace
|
|
30
|
+
// can no longer be waited for, so it folds into the runs around it, which bounds this by
|
|
31
|
+
// the gaps opened within the grace rather than every gap in the subscription. A fold is
|
|
32
|
+
// final: a later, longer grace or a lowered floor cannot reopen it.
|
|
33
|
+
#runs = [];
|
|
29
34
|
// Group streams whose header arrived, and those still being read.
|
|
30
35
|
#streams = 0;
|
|
31
36
|
#active = 0;
|
|
32
37
|
#changed = new Signal(0);
|
|
38
|
+
#grace;
|
|
39
|
+
#now;
|
|
40
|
+
constructor(options = {}) {
|
|
41
|
+
this.#grace = options.grace ?? (() => TAIL_GRACE_MS);
|
|
42
|
+
this.#now = options.now ?? (() => performance.now());
|
|
43
|
+
}
|
|
33
44
|
/** Group streams whose header arrived, whether they finished or were reset. */
|
|
34
45
|
get streams() {
|
|
35
46
|
return this.#streams;
|
|
@@ -55,27 +66,41 @@ export class Tail {
|
|
|
55
66
|
account(start, end) {
|
|
56
67
|
this.#account(start, end);
|
|
57
68
|
}
|
|
69
|
+
/** Restart the age of every gap reaching into `[start, end)`, which the demand newly asks for. */
|
|
70
|
+
demand(start, end) {
|
|
71
|
+
if (start >= end)
|
|
72
|
+
return;
|
|
73
|
+
const now = this.#now();
|
|
74
|
+
let below = 0;
|
|
75
|
+
this.#runs = this.#runs.map((run) => {
|
|
76
|
+
const reached = below < end && start < run.start;
|
|
77
|
+
below = run.end;
|
|
78
|
+
return reached ? { ...run, since: now } : run;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
58
81
|
/** Whether every sequence in `[start, end)` is accounted for. */
|
|
59
82
|
covers(start, end) {
|
|
60
83
|
if (start >= end)
|
|
61
84
|
return true;
|
|
62
|
-
//
|
|
63
|
-
return this.#
|
|
85
|
+
// Runs are merged on insert, so one run covers the span or none does.
|
|
86
|
+
return this.#runs.some((run) => run.start <= start && end <= run.end);
|
|
64
87
|
}
|
|
65
88
|
/**
|
|
66
|
-
* Wait until every stream is read to its end and `complete()` holds, or
|
|
67
|
-
*
|
|
89
|
+
* Wait until every stream is read to its end and `complete()` holds, or the grace passes
|
|
90
|
+
* with nothing left being read, or `closed` settles.
|
|
68
91
|
*
|
|
69
92
|
* A stream still being read is always waited for: a group ends on its own stream's FIN
|
|
70
93
|
* or reset, never because its track ended. The grace only gives up on streams that never
|
|
71
94
|
* arrived.
|
|
72
95
|
*/
|
|
73
|
-
async settle(complete,
|
|
96
|
+
async settle(complete, closed) {
|
|
97
|
+
// A gap that aged past the grace since the last insert is no longer waited for either.
|
|
98
|
+
this.#expire(this.#now());
|
|
74
99
|
let expired = false;
|
|
75
100
|
const timer = setTimeout(() => {
|
|
76
101
|
expired = true;
|
|
77
102
|
this.#bump();
|
|
78
|
-
}, Math.min(grace, MAX_TIMEOUT_MS));
|
|
103
|
+
}, Math.min(this.#grace(), MAX_TIMEOUT_MS));
|
|
79
104
|
try {
|
|
80
105
|
while (closed.peek() === undefined) {
|
|
81
106
|
if (this.#active === 0 && (expired || complete()))
|
|
@@ -90,30 +115,51 @@ export class Tail {
|
|
|
90
115
|
#account(start, end) {
|
|
91
116
|
if (start >= end)
|
|
92
117
|
return;
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
let
|
|
118
|
+
const now = this.#now();
|
|
119
|
+
const runs = [];
|
|
120
|
+
let merged;
|
|
96
121
|
let placed = false;
|
|
97
|
-
for (const
|
|
98
|
-
if (
|
|
99
|
-
|
|
122
|
+
for (const run of this.#runs) {
|
|
123
|
+
if (run.end < start) {
|
|
124
|
+
runs.push(run);
|
|
100
125
|
}
|
|
101
|
-
else if (
|
|
126
|
+
else if (end < run.start) {
|
|
127
|
+
// Splitting a gap leaves both halves as late as it was.
|
|
102
128
|
if (!placed)
|
|
103
|
-
|
|
129
|
+
runs.push(merged ?? { start, end, since: run.since });
|
|
104
130
|
placed = true;
|
|
105
|
-
|
|
131
|
+
runs.push(run);
|
|
106
132
|
}
|
|
107
133
|
else {
|
|
108
|
-
|
|
109
|
-
|
|
134
|
+
merged = {
|
|
135
|
+
start: Math.min(merged?.start ?? start, run.start),
|
|
136
|
+
end: Math.max(merged?.end ?? end, run.end),
|
|
137
|
+
since: merged?.since ?? run.since,
|
|
138
|
+
};
|
|
110
139
|
}
|
|
111
140
|
}
|
|
141
|
+
// A run past every other one opens a new gap.
|
|
112
142
|
if (!placed)
|
|
113
|
-
|
|
114
|
-
this.#
|
|
143
|
+
runs.push(merged ?? { start, end, since: now });
|
|
144
|
+
this.#runs = runs;
|
|
145
|
+
this.#expire(now);
|
|
115
146
|
this.#bump();
|
|
116
147
|
}
|
|
148
|
+
// Fold every gap older than the grace into the runs around it.
|
|
149
|
+
#expire(now) {
|
|
150
|
+
const grace = this.#grace();
|
|
151
|
+
const runs = [];
|
|
152
|
+
for (const run of this.#runs) {
|
|
153
|
+
const below = runs.at(-1);
|
|
154
|
+
if (below && now - run.since >= grace) {
|
|
155
|
+
runs[runs.length - 1] = { ...below, end: run.end };
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
runs.push(run);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
this.#runs = runs;
|
|
162
|
+
}
|
|
117
163
|
#bump() {
|
|
118
164
|
this.#changed.update((revision) => revision + 1);
|
|
119
165
|
}
|
package/tail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tail.js","sourceRoot":"","sources":["../src/tail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAEzC,gFAAgF;AAChF,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAEnC;;;;;;;;;GASG;AACH,MAAM,OAAO,IAAI;IAChB,0FAA0F;IAC1F,8EAA8E;IAC9E,UAAU,GAAuB,EAAE,CAAC;IACpC,kEAAkE;IAClE,QAAQ,GAAG,CAAC,CAAC;IACb,OAAO,GAAG,CAAC,CAAC;IACZ,QAAQ,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;IAEzB,+EAA+E;IAC/E,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,QAAgB;QACpB,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC;QAEtC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,OAAO,GAAG,EAAE;YACX,IAAI,MAAM;gBAAE,OAAO;YACnB,MAAM,GAAG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riber waits for a group stream it cannot account for once the publisher\n * has ended the subscription.\n *\n * A group reset before its header arrived leaves no trace, and QUIC does not order streams,\n * so a stream opened before the end can still be in flight after it. This bounds the wait on\n * IETF, and on moq-lite when the subscription has no max age to bound it with.\n */\nexport const TAIL_GRACE_MS = Milli(1000);\n\n// setTimeout truncates a longer delay to a signed 32-bit int and fires at once.\nconst MAX_TIMEOUT_MS = 2 ** 31 - 1;\n\n/**\n * The group streams a subscription has received, so its end can wait for the ones still owed.\n *\n * A publisher ends a subscription before every group stream it opened has necessarily\n * arrived. This records which sequences are accounted for (a stream's header arrived, or\n * the publisher dropped them) and how many streams are still being read, and {@link settle}\n * waits on them.\n *\n * @internal\n */\nexport class Tail {\n\t// Disjoint, sorted, exclusive-end ranges of accounted sequences. A gap splits a range, so\n\t// this stays as small as the number of gaps rather than the number of groups.\n\t#accounted: [number, number][] = [];\n\t// Group streams whose header arrived, and those still being read.\n\t#streams = 0;\n\t#active = 0;\n\t#changed = new Signal(0);\n\n\t/** Group streams whose header arrived, whether they finished or were reset. */\n\tget streams(): number {\n\t\treturn this.#streams;\n\t}\n\n\t/**\n\t * Record a group stream whose header arrived. Returns the call that marks it read to\n\t * its end, which is idempotent.\n\t */\n\topen(sequence: number): () => void {\n\t\tthis.#streams += 1;\n\t\tthis.#active += 1;\n\t\tthis.#account(sequence, sequence + 1);\n\n\t\tlet closed = false;\n\t\treturn () => {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tthis.#active -= 1;\n\t\t\tthis.#bump();\n\t\t};\n\t}\n\n\t/** Record sequences `[start, end)` as accounted for without a stream: dropped, or a datagram. */\n\taccount(start: number, end: number): void {\n\t\tthis.#account(start, end);\n\t}\n\n\t/** Whether every sequence in `[start, end)` is accounted for. */\n\tcovers(start: number, end: number): boolean {\n\t\tif (start >= end) return true;\n\t\t// Ranges are merged on insert, so one range covers the span or none does.\n\t\treturn this.#accounted.some(([lo, hi]) => lo <= start && end <= hi);\n\t}\n\n\t/**\n\t * Wait until every stream is read to its end and `complete()` holds, or `grace`\n\t * milliseconds pass with nothing left being read, or `closed` settles.\n\t *\n\t * A stream still being read is always waited for: a group ends on its own stream's FIN\n\t * or reset, never because its track ended. The grace only gives up on streams that never\n\t * arrived.\n\t */\n\tasync settle(complete: () => boolean, grace: Milli, closed: GetPromise<unknown>): Promise<void> {\n\t\tlet expired = false;\n\t\tconst timer = setTimeout(\n\t\t\t() => {\n\t\t\t\texpired = true;\n\t\t\t\tthis.#bump();\n\t\t\t},\n\t\t\tMath.min(grace, MAX_TIMEOUT_MS),\n\t\t);\n\t\ttry {\n\t\t\twhile (closed.peek() === undefined) {\n\t\t\t\tif (this.#active === 0 && (expired || complete())) return;\n\t\t\t\tawait Signal.race(this.#changed, closed);\n\t\t\t}\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t}\n\n\t#account(start: number, end: number): void {\n\t\tif (start >= end) return;\n\n\t\tconst merged: [number, number][] = [];\n\t\tlet lo = start;\n\t\tlet hi = end;\n\t\tlet placed = false;\n\t\tfor (const range of this.#accounted) {\n\t\t\tif (range[1] < lo) {\n\t\t\t\tmerged.push(range);\n\t\t\t} else if (hi < range[0]) {\n\t\t\t\tif (!placed) merged.push([lo, hi]);\n\t\t\t\tplaced = true;\n\t\t\t\tmerged.push(range);\n\t\t\t} else {\n\t\t\t\tlo = Math.min(lo, range[0]);\n\t\t\t\thi = Math.max(hi, range[1]);\n\t\t\t}\n\t\t}\n\t\tif (!placed) merged.push([lo, hi]);\n\t\tthis.#accounted = merged;\n\t\tthis.#bump();\n\t}\n\n\t#bump(): void {\n\t\tthis.#changed.update((revision) => revision + 1);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tail.js","sourceRoot":"","sources":["../src/tail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC;;;;;;;GAOG;AACH,MA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,EAAE,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC;CACD","sourcesContent":["import { type GetPromise, Signal } from \"@moq/signals\";\nimport { Milli } from \"./time.ts\";\n\n/**\n * How long a subscriber waits for a group stream it cannot account for once the publisher\n * has ended the subscription.\n *\n * A group reset before its header arrived leaves no trace, and QUIC does not order streams,\n * so a stream opened before the end can still be in flight after it. This bounds the wait on\n * IETF, and on moq-lite when the subscription has no max age to bound it with.\n */\nexport const TAIL_GRACE_MS = Milli(1000);\n\n// setTimeout truncates a longer delay to a signed 32-bit int and fires at once.\nconst MAX_TIMEOUT_MS = 2 ** 31 - 1;\n\n// A run of accounted sequences `[start, end)`, and when the gap below it opened (in\n// `performance.now()` milliseconds), which is when its missing groups became late.\ntype Run = { start: number; end: number; since: number };\n\n/** How a {@link Tail} measures its grace. */\nexport interface TailOptions {\n\t/** How long to wait for a group that cannot be accounted for. Read each time it is needed. */\n\tgrace?: () => Milli;\n\t/** The clock, in `performance.now()` milliseconds. */\n\tnow?: () => number;\n}\n\n/**\n * The group streams a subscription has received, so its end can wait for the ones still owed.\n *\n * A publisher ends a subscription before every group stream it opened has necessarily\n * arrived. This records which sequences are accounted for (a stream's header arrived, or\n * the publisher dropped them) and how many streams are still being read, and {@link settle}\n * waits on them.\n *\n * A lost datagram is not owed: it leaves a hole that waits out the grace like a stream reset\n * before its header.\n *\n * @internal\n */\nexport class Tail {\n\t// Disjoint, sorted, non-adjacent runs of accounted sequences. A gap older than the grace\n\t// can no longer be waited for, so it folds into the runs around it, which bounds this by\n\t// the gaps opened within the grace rather than every gap in the subscription. A fold is\n\t// final: a later, longer grace or a lowered floor cannot reopen it.\n\t#runs: Run[] = [];\n\t// Group streams whose header arrived, and those still being read.\n\t#streams = 0;\n\t#active = 0;\n\t#changed = new Signal(0);\n\t#grace: () => Milli;\n\t#now: () => number;\n\n\tconstructor(options: TailOptions = {}) {\n\t\tthis.#grace = options.grace ?? (() => TAIL_GRACE_MS);\n\t\tthis.#now = options.now ?? (() => performance.now());\n\t}\n\n\t/** Group streams whose header arrived, whether they finished or were reset. */\n\tget streams(): number {\n\t\treturn this.#streams;\n\t}\n\n\t/**\n\t * Record a group stream whose header arrived. Returns the call that marks it read to\n\t * its end, which is idempotent.\n\t */\n\topen(sequence: number): () => void {\n\t\tthis.#streams += 1;\n\t\tthis.#active += 1;\n\t\tthis.#account(sequence, sequence + 1);\n\n\t\tlet closed = false;\n\t\treturn () => {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tthis.#active -= 1;\n\t\t\tthis.#bump();\n\t\t};\n\t}\n\n\t/** Record sequences `[start, end)` as accounted for without a stream: dropped, or a datagram. */\n\taccount(start: number, end: number): void {\n\t\tthis.#account(start, end);\n\t}\n\n\t/** Restart the age of every gap reaching into `[start, end)`, which the demand newly asks for. */\n\tdemand(start: number, end: number): void {\n\t\tif (start >= end) return;\n\t\tconst now = this.#now();\n\t\tlet below = 0;\n\t\tthis.#runs = this.#runs.map((run) => {\n\t\t\tconst reached = below < end && start < run.start;\n\t\t\tbelow = run.end;\n\t\t\treturn reached ? { ...run, since: now } : run;\n\t\t});\n\t}\n\n\t/** Whether every sequence in `[start, end)` is accounted for. */\n\tcovers(start: number, end: number): boolean {\n\t\tif (start >= end) return true;\n\t\t// Runs are merged on insert, so one run covers the span or none does.\n\t\treturn this.#runs.some((run) => run.start <= start && end <= run.end);\n\t}\n\n\t/**\n\t * Wait until every stream is read to its end and `complete()` holds, or the grace passes\n\t * with nothing left being read, or `closed` settles.\n\t *\n\t * A stream still being read is always waited for: a group ends on its own stream's FIN\n\t * or reset, never because its track ended. The grace only gives up on streams that never\n\t * arrived.\n\t */\n\tasync settle(complete: () => boolean, closed: GetPromise<unknown>): Promise<void> {\n\t\t// A gap that aged past the grace since the last insert is no longer waited for either.\n\t\tthis.#expire(this.#now());\n\n\t\tlet expired = false;\n\t\tconst timer = setTimeout(\n\t\t\t() => {\n\t\t\t\texpired = true;\n\t\t\t\tthis.#bump();\n\t\t\t},\n\t\t\tMath.min(this.#grace(), MAX_TIMEOUT_MS),\n\t\t);\n\t\ttry {\n\t\t\twhile (closed.peek() === undefined) {\n\t\t\t\tif (this.#active === 0 && (expired || complete())) return;\n\t\t\t\tawait Signal.race(this.#changed, closed);\n\t\t\t}\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t}\n\n\t#account(start: number, end: number): void {\n\t\tif (start >= end) return;\n\n\t\tconst now = this.#now();\n\t\tconst runs: Run[] = [];\n\t\tlet merged: Run | undefined;\n\t\tlet placed = false;\n\t\tfor (const run of this.#runs) {\n\t\t\tif (run.end < start) {\n\t\t\t\truns.push(run);\n\t\t\t} else if (end < run.start) {\n\t\t\t\t// Splitting a gap leaves both halves as late as it was.\n\t\t\t\tif (!placed) runs.push(merged ?? { start, end, since: run.since });\n\t\t\t\tplaced = true;\n\t\t\t\truns.push(run);\n\t\t\t} else {\n\t\t\t\tmerged = {\n\t\t\t\t\tstart: Math.min(merged?.start ?? start, run.start),\n\t\t\t\t\tend: Math.max(merged?.end ?? end, run.end),\n\t\t\t\t\tsince: merged?.since ?? run.since,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\t// A run past every other one opens a new gap.\n\t\tif (!placed) runs.push(merged ?? { start, end, since: now });\n\t\tthis.#runs = runs;\n\t\tthis.#expire(now);\n\t\tthis.#bump();\n\t}\n\n\t// Fold every gap older than the grace into the runs around it.\n\t#expire(now: number): void {\n\t\tconst grace = this.#grace();\n\t\tconst runs: Run[] = [];\n\t\tfor (const run of this.#runs) {\n\t\t\tconst below = runs.at(-1);\n\t\t\tif (below && now - run.since >= grace) {\n\t\t\t\truns[runs.length - 1] = { ...below, end: run.end };\n\t\t\t} else {\n\t\t\t\truns.push(run);\n\t\t\t}\n\t\t}\n\t\tthis.#runs = runs;\n\t}\n\n\t#bump(): void {\n\t\tthis.#changed.update((revision) => revision + 1);\n\t}\n}\n"]}
|
package/track.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface Info {
|
|
|
39
39
|
* or non-finite value and a result past `Number.MAX_SAFE_INTEGER`.
|
|
40
40
|
*/
|
|
41
41
|
maxAge: Milli;
|
|
42
|
-
/** Tie-break priority between subscriptions of equal subscriber priority (`0..=255
|
|
42
|
+
/** Tie-break priority between subscriptions of equal subscriber priority (`0..=255`, higher first). Defaults to `127`. */
|
|
43
43
|
priority: number;
|
|
44
44
|
}
|
|
45
45
|
/** Fill in any unset {@link Info} fields with their defaults. */
|
|
@@ -109,6 +109,13 @@ export declare class Request {
|
|
|
109
109
|
export interface FetchGroupOptions {
|
|
110
110
|
/** Delivery priority for the fetch stream. Defaults to `0`. */
|
|
111
111
|
priority?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Abandons this fetch, rejecting with the signal's reason. Concurrent fetches of the same
|
|
114
|
+
* group share one stream, cancelled only once every caller has left. An already-aborted
|
|
115
|
+
* signal rejects before anything is sent, and aborting after the group resolves has no
|
|
116
|
+
* effect; close the group instead.
|
|
117
|
+
*/
|
|
118
|
+
signal?: AbortSignal;
|
|
112
119
|
}
|
|
113
120
|
/**
|
|
114
121
|
* A lazy handle to a track on a consumed broadcast.
|
|
@@ -157,7 +164,7 @@ export declare class Producer {
|
|
|
157
164
|
*/
|
|
158
165
|
info(): Promise<Info>;
|
|
159
166
|
/**
|
|
160
|
-
* Publisher priority from the committed {@link Info}, or
|
|
167
|
+
* Publisher priority from the committed {@link Info}, or the default before {@link accept}.
|
|
161
168
|
*
|
|
162
169
|
* Higher is served first. Hang publishers set this from `Catalog.PRIORITY` so
|
|
163
170
|
* audio outranks video on the wire and in the bandwidth allocator.
|
|
@@ -241,7 +248,11 @@ export declare class Producer {
|
|
|
241
248
|
* Close the track and every subscriber, mirroring the abort to their groups. Idempotent.
|
|
242
249
|
*
|
|
243
250
|
* A clean close keeps the end {@link finishAt} declared, or declares one past the highest
|
|
244
|
-
* sequence produced; an abort ends without one.
|
|
251
|
+
* sequence produced; an abort ends without one. Subscribers still draining get the
|
|
252
|
+
* finished groups first, then the end or the abort. An abort after the declared end
|
|
253
|
+
* settled (reached, with every group below it finished) is a clean close. The groups
|
|
254
|
+
* left behind still age out after the track's `maxAge`, so a stale subscriber can't pin
|
|
255
|
+
* them.
|
|
245
256
|
*/
|
|
246
257
|
close(abort?: Error): void;
|
|
247
258
|
/** Append a frame as its own single-frame group. */
|
package/track.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,MAAM,EAAgB,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,QAAQ,IAAI,aAAa,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AASnG,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAG7D,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,MAAM,EAAgB,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,QAAQ,IAAI,aAAa,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AASnG,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAG7D,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAS9C,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,OAAc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