@moq/net 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +3 -2
- package/broadcast.js.map +1 -1
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +3 -0
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +3 -0
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +11 -7
- package/connection/connect.js.map +1 -1
- package/group.d.ts +19 -1
- package/group.d.ts.map +1 -1
- package/group.js +35 -11
- package/group.js.map +1 -1
- package/ietf/adapter.d.ts.map +1 -1
- package/ietf/adapter.js +76 -45
- package/ietf/adapter.js.map +1 -1
- package/ietf/aliases.d.ts +73 -5
- package/ietf/aliases.d.ts.map +1 -1
- package/ietf/aliases.js +121 -14
- package/ietf/aliases.js.map +1 -1
- package/ietf/fetch.d.ts +17 -0
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +21 -0
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +87 -0
- package/ietf/filter.d.ts.map +1 -0
- package/ietf/filter.js +292 -0
- package/ietf/filter.js.map +1 -0
- package/ietf/namespace.d.ts +6 -0
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +27 -2
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +44 -2
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +74 -9
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +16 -4
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +54 -10
- package/ietf/parameters.js.map +1 -1
- package/ietf/properties.d.ts +5 -0
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +5 -0
- package/ietf/properties.js.map +1 -1
- package/ietf/publisher.d.ts.map +1 -1
- package/ietf/publisher.js +375 -27
- package/ietf/publisher.js.map +1 -1
- package/ietf/subscribe.d.ts +38 -7
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +94 -29
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscriber.d.ts.map +1 -1
- package/ietf/subscriber.js +148 -35
- package/ietf/subscriber.js.map +1 -1
- package/ietf/version.d.ts +7 -1
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +7 -0
- package/ietf/version.js.map +1 -1
- package/internal.d.ts +16 -1
- package/internal.d.ts.map +1 -1
- package/internal.js.map +1 -1
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +7 -7
- package/lite/announce.js.map +1 -1
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +4 -2
- package/lite/publisher.js.map +1 -1
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +2 -1
- package/lite/setup.js.map +1 -1
- package/lite/subscriber.d.ts +1 -6
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +98 -23
- package/lite/subscriber.js.map +1 -1
- package/lite/version.d.ts +4 -0
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +15 -0
- package/lite/version.js.map +1 -1
- package/origin.d.ts +1 -1
- package/origin.d.ts.map +1 -1
- package/origin.js +1 -1
- package/origin.js.map +1 -1
- package/package.json +4 -3
- package/stream.d.ts.map +1 -1
- package/stream.js +3 -5
- package/stream.js.map +1 -1
- package/track.d.ts +38 -0
- package/track.d.ts.map +1 -1
- package/track.js +104 -25
- package/track.js.map +1 -1
- package/util/utf8.d.ts +3 -0
- package/util/utf8.d.ts.map +1 -0
- package/util/utf8.js +7 -0
- package/util/utf8.js.map +1 -0
- package/zod.d.ts +1 -1
- package/zod.d.ts.map +1 -1
- package/zod.js.map +1 -1
package/ietf/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/ietf/adapter.ts"],"names":[],"mappings":"AAAA,OAA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mC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5E,CAAC;IACF,CAAC;IAED,KAAK;QACJ,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAEzC,4BAA4B;QAC5B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC5C,IAAI,CAAC;gBACJ,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACR,iBAAiB;YAClB,CAAC;QACF,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAEtB,uCAAuC;QACvC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC5C,MAAM,CAAC,SAAS,CAAC,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAE3B,2BAA2B;QAC3B,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAAC;QACpC,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;QAElC,+BAA+B;QAC/B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,qBAAqB;YAAE,OAAO,EAAE,CAAC;QAC5D,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;IACjC,CAAC;CACD","sourcesContent":["import { Mutex } from \"async-mutex\";\nimport { Reader, Stream, type Writer } from \"../stream.ts\";\nimport * as Varint from \"../varint.ts\";\nimport * as Namespace from \"./namespace.ts\";\nimport { type IetfVersion, Version } from \"./version.ts\";\n\n/**\n * Interface for opening outgoing bidi streams and allocating request IDs.\n * Implemented by both ControlStreamAdapter (v14-v16) and NativeSession (v17).\n */\nexport interface Session {\n\topenBi(): Stream | Promise<Stream>;\n\topenNativeBi?(): Promise<Stream>;\n\tacceptBi(): Promise<Stream | undefined>;\n\tnextRequestId(): Promise<bigint | undefined>;\n\tclose(): void;\n\treadonly version: IetfVersion;\n}\n\n/**\n * v17 native session — thin wrapper around WebTransport.\n * Each request gets its own real bidi stream; no control stream multiplexing.\n */\nexport class NativeSession implements Session {\n\t#quic: WebTransport;\n\t// moq-transport reserves even request IDs for the client and odd for the server,\n\t// so the two peers' ID spaces never overlap.\n\t#requestId: bigint;\n\treadonly version: IetfVersion;\n\n\tconstructor(quic: WebTransport, version: IetfVersion, client: boolean) {\n\t\tthis.#quic = quic;\n\t\tthis.version = version;\n\t\tthis.#requestId = client ? 0n : 1n;\n\t}\n\n\tasync openBi(): Promise<Stream> {\n\t\treturn Stream.open(this.#quic, { version: this.version });\n\t}\n\n\tasync acceptBi(): Promise<Stream | undefined> {\n\t\treturn Stream.accept(this.#quic, this.version);\n\t}\n\n\tasync nextRequestId(): Promise<bigint | undefined> {\n\t\tconst id = this.#requestId;\n\t\tthis.#requestId += 2n;\n\t\treturn id;\n\t}\n\n\t/** Closes the underlying WebTransport session. */\n\tclose() {\n\t\tthis.#quic.close();\n\t}\n}\n\n// Route classification for control stream messages.\nconst Route = {\n\tNewRequest: 0, // Create virtual bidi stream, push initial message\n\tResponse: 1, // Push message to existing stream (keep open)\n\tErrorResponse: 2, // Push message to existing stream, then close\n\tCloseStream: 3, // Close stream recv (no bytes pushed)\n\tFollowUp: 4, // Push follow-up message to existing stream\n\tMaxRequestId: 5, // Update flow control\n\tIgnore: 6, // Connection-level, no routing\n\tGoAway: 7, // Terminal\n} as const;\ntype Route = (typeof Route)[keyof typeof Route];\n\ninterface StreamEntry {\n\tcontroller: ReadableStreamDefaultController<Uint8Array>;\n}\n\n/**\n * Converts v14-v16 control stream multiplexing into virtual bidi streams.\n *\n * Reads control messages, classifies them, and routes to virtual Stream objects.\n * Each request/response pair gets its own virtual Stream, making all versions\n * look like v17's stream-per-request model.\n */\nexport class ControlStreamAdapter implements Session {\n\t// WebTransport session (for opening real bidi streams in v16)\n\t#quic: WebTransport;\n\n\t// Control stream\n\t#reader: Reader;\n\t#writer: Writer;\n\t#writeMutex = new Mutex();\n\treadonly version: IetfVersion;\n\n\t// Virtual streams keyed by requestId\n\t#streams = new Map<bigint, StreamEntry>();\n\n\t// Namespace → requestId reverse lookup (v14/v15 namespace-keyed messages)\n\t#namespaces = new Map<string, bigint>();\n\n\t// requestId → namespace reverse lookup (for cleanup in #closeStream)\n\t#namespacesByRequestId = new Map<bigint, string>();\n\n\t// SubscribeNamespace requestIds — for routing 0x08/0x0E entries that lack requestId (v14/v15)\n\t#subscribeNamespaces = new Set<bigint>();\n\n\t// Incoming stream queue (for acceptBi)\n\t#incomingQueue: Stream[] = [];\n\t#incomingWaiters: ((stream: Stream | undefined) => void)[] = [];\n\n\t// Request ID flow control. moq-transport reserves even request IDs for the\n\t// client and odd for the server, so the two peers' ID spaces never overlap.\n\t// This matters here because a single `#streams` map routes every request by\n\t// ID: overlapping spaces would let an inbound request clobber the routing\n\t// entry of an outbound one with the same number (e.g. an inbound\n\t// PUBLISH_NAMESPACE stealing a pending SUBSCRIBE's slot, so SUBSCRIBE_OK is\n\t// delivered to the wrong virtual stream).\n\t#requestId: bigint;\n\t#maxRequestId: bigint;\n\t#maxRequestIdResolves: (() => void)[] = [];\n\n\t#closed = false;\n\n\tconstructor(\n\t\tquic: WebTransport,\n\t\tcontrolStream: Stream,\n\t\tversion: IetfVersion,\n\t\tmaxRequestId: bigint,\n\t\tclient: boolean,\n\t) {\n\t\tthis.#quic = quic;\n\t\tthis.#reader = controlStream.reader;\n\t\tthis.#reader.version = version;\n\t\tthis.#writer = controlStream.writer;\n\t\tthis.#writer.version = version;\n\t\tthis.version = version;\n\t\tthis.#maxRequestId = maxRequestId;\n\t\tthis.#requestId = client ? 0n : 1n;\n\t}\n\n\t/**\n\t * Accept the next incoming virtual bidi stream.\n\t * Blocks until a new request arrives on the control stream.\n\t */\n\tasync acceptBi(): Promise<Stream | undefined> {\n\t\tif (this.#closed) return undefined;\n\n\t\tconst queued = this.#incomingQueue.shift();\n\t\tif (queued) return queued;\n\n\t\treturn new Promise<Stream | undefined>((resolve) => {\n\t\t\tthis.#incomingWaiters.push(resolve);\n\t\t});\n\t}\n\n\t/**\n\t * Open an outgoing virtual bidi stream.\n\t * Buffers writes until the first full message is available, parses the\n\t * requestId (and namespace for PublishNamespace), self-registers, then\n\t * flushes. Subsequent writes go directly to the control stream.\n\t */\n\topenBi(): Stream {\n\t\tlet controller!: ReadableStreamDefaultController<Uint8Array>;\n\t\tlet registeredRequestId: bigint | undefined;\n\n\t\tconst readable = new ReadableStream<Uint8Array>({\n\t\t\tstart(c) {\n\t\t\t\tcontroller = c;\n\t\t\t},\n\t\t\tcancel: () => {\n\t\t\t\tif (registeredRequestId !== undefined) {\n\t\t\t\t\tthis.#streams.delete(registeredRequestId);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\tlet buffer = new Uint8Array(0);\n\t\tlet registered = false;\n\n\t\tconst sendWritable = new WritableStream<Uint8Array>({\n\t\t\twrite: async (chunk) => {\n\t\t\t\t// Always accumulate bytes and flush only complete messages\n\t\t\t\t// to prevent interleaving of partial messages from concurrent virtual streams.\n\t\t\t\tconst newBuf = new Uint8Array(buffer.length + chunk.length);\n\t\t\t\tnewBuf.set(buffer);\n\t\t\t\tnewBuf.set(chunk, buffer.length);\n\t\t\t\tbuffer = newBuf;\n\n\t\t\t\t// Try to flush complete messages from the buffer\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst boundary = this.#messageSize(buffer);\n\t\t\t\t\tif (boundary === undefined) break;\n\n\t\t\t\t\tconst toFlush = buffer.subarray(0, boundary);\n\t\t\t\t\tbuffer = buffer.subarray(boundary);\n\n\t\t\t\t\tif (!registered) {\n\t\t\t\t\t\t// First message: extract requestId and register before flushing\n\t\t\t\t\t\tconst parsed = this.#tryParseOutgoing(toFlush);\n\t\t\t\t\t\tif (parsed) {\n\t\t\t\t\t\t\tregisteredRequestId = parsed.requestId;\n\t\t\t\t\t\t\tthis.#streams.set(parsed.requestId, { controller });\n\t\t\t\t\t\t\tregistered = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tawait this.#writeMutex.runExclusive(() => this.#writer.write(toFlush));\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\tconst stream = new Stream({ readable, writable: sendWritable });\n\t\tstream.reader.version = this.version;\n\t\tstream.writer.version = this.version;\n\t\treturn stream;\n\t}\n\n\t/**\n\t * Open a real WebTransport bidi stream (for v16 SubscribeNamespace).\n\t */\n\tasync openNativeBi(): Promise<Stream> {\n\t\treturn Stream.open(this.#quic, { version: this.version });\n\t}\n\n\t/**\n\t * Allocate the next request ID, blocking if flow control limit reached.\n\t */\n\tasync nextRequestId(): Promise<bigint | undefined> {\n\t\tfor (;;) {\n\t\t\tif (this.#closed) return undefined;\n\t\t\tconst id = this.#requestId;\n\t\t\tif (id < this.#maxRequestId) {\n\t\t\t\tthis.#requestId += 2n;\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tthis.#maxRequestIdResolves.push(resolve);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Main run loop — reads control stream messages and routes to virtual streams.\n\t * Must be called after construction. Runs until the control stream closes.\n\t */\n\tasync run(): Promise<void> {\n\t\ttry {\n\t\t\t// v16: also accept real bidi streams (for SubscribeNamespace)\n\t\t\tif (this.version === Version.DRAFT_16) {\n\t\t\t\tvoid this.#acceptNativeBidis();\n\t\t\t}\n\n\t\t\tfor (;;) {\n\t\t\t\tconst done = await this.#reader.done();\n\t\t\t\tif (done) break;\n\n\t\t\t\tconst typeId = await this.#reader.u53();\n\t\t\t\tconst size = await this.#reader.u16();\n\t\t\t\tconst body = await this.#reader.read(size);\n\n\t\t\t\tconst classified = await this.#classify(typeId, body);\n\n\t\t\t\tif (classified.route === Route.GoAway) {\n\t\t\t\t\tconsole.warn(\"received GOAWAY on control stream\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { route, requestId } = classified;\n\n\t\t\t\tswitch (route) {\n\t\t\t\t\tcase Route.NewRequest:\n\t\t\t\t\t\tthis.#newRequest(typeId, size, body, requestId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.Response:\n\t\t\t\t\t\tthis.#pushMessage(requestId, typeId, size, body);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.ErrorResponse:\n\t\t\t\t\t\tthis.#pushMessage(requestId, typeId, size, body);\n\t\t\t\t\t\tthis.#closeStream(requestId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.CloseStream:\n\t\t\t\t\t\tthis.#closeStream(requestId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.FollowUp:\n\t\t\t\t\t\tthis.#pushMessage(requestId, typeId, size, body);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.MaxRequestId:\n\t\t\t\t\t\tthis.#maxRequestId = requestId;\n\t\t\t\t\t\tfor (const resolve of this.#maxRequestIdResolves) resolve();\n\t\t\t\t\t\tthis.#maxRequestIdResolves = [];\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/** Accept real WebTransport bidi streams and queue them for acceptBi (v16). */\n\tasync #acceptNativeBidis(): Promise<void> {\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst stream = await Stream.accept(this.#quic, this.version);\n\t\t\t\tif (!stream) break;\n\n\t\t\t\tconst waiter = this.#incomingWaiters.shift();\n\t\t\t\tif (waiter) {\n\t\t\t\t\twaiter(stream);\n\t\t\t\t} else {\n\t\t\t\t\tthis.#incomingQueue.push(stream);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Session closed\n\t\t}\n\t}\n\n\t#newRequest(typeId: number, size: number, body: Uint8Array, requestId: bigint) {\n\t\tlet controller!: ReadableStreamDefaultController<Uint8Array>;\n\t\tconst readable = new ReadableStream<Uint8Array>({\n\t\t\tstart(c) {\n\t\t\t\tcontroller = c;\n\t\t\t},\n\t\t\tcancel: () => {\n\t\t\t\tthis.#streams.delete(requestId);\n\t\t\t},\n\t\t});\n\n\t\tconst sendWritable = this.#createSendWritable();\n\n\t\tconst stream = new Stream({ readable, writable: sendWritable });\n\t\tstream.reader.version = this.version;\n\t\tstream.writer.version = this.version;\n\n\t\tthis.#streams.set(requestId, { controller });\n\n\t\t// Push initial message bytes so the dispatcher can read typeId + decode\n\t\tcontroller.enqueue(this.#encodeRaw(typeId, size, body));\n\n\t\t// Queue for acceptBi\n\t\tconst waiter = this.#incomingWaiters.shift();\n\t\tif (waiter) {\n\t\t\twaiter(stream);\n\t\t} else {\n\t\t\tthis.#incomingQueue.push(stream);\n\t\t}\n\t}\n\n\t#pushMessage(requestId: bigint, typeId: number, size: number, body: Uint8Array) {\n\t\tconst entry = this.#streams.get(requestId);\n\t\tif (!entry) {\n\t\t\tconsole.warn(`adapter: no stream for requestId=${requestId} typeId=0x${typeId.toString(16)}`);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tentry.controller.enqueue(this.#encodeRaw(typeId, size, body));\n\t\t} catch {\n\t\t\t// Stream already closed\n\t\t}\n\t}\n\n\t#closeStream(requestId: bigint) {\n\t\tconst entry = this.#streams.get(requestId);\n\t\tif (!entry) return;\n\t\tconsole.debug(`adapter: closing stream requestId=${requestId}`);\n\t\tthis.#streams.delete(requestId);\n\t\tthis.#subscribeNamespaces.delete(requestId);\n\t\tconst namespace = this.#namespacesByRequestId.get(requestId);\n\t\tif (namespace !== undefined) {\n\t\t\tthis.#namespaces.delete(namespace);\n\t\t\tthis.#namespacesByRequestId.delete(requestId);\n\t\t}\n\t\ttry {\n\t\t\tentry.controller.close();\n\t\t} catch {\n\t\t\t// Already closed\n\t\t}\n\t}\n\n\t/**\n\t * Returns the total byte size of the first complete message in buffer,\n\t * or undefined if the buffer doesn't contain a complete message yet.\n\t * Message format: [typeId varint][size u16 BE][body of `size` bytes]\n\t */\n\t#messageSize(buffer: Uint8Array): number | undefined {\n\t\tif (buffer.length === 0) return undefined;\n\n\t\tconst typeSize = 1 << ((buffer[0] & 0xc0) >> 6);\n\t\tif (buffer.length < typeSize) return undefined;\n\n\t\tconst [, afterType] = Varint.decode(buffer);\n\t\tif (afterType.length < 2) return undefined;\n\n\t\tconst size = (afterType[0] << 8) | afterType[1];\n\t\tconst totalSize = buffer.length - afterType.length + 2 + size;\n\t\tif (buffer.length < totalSize) return undefined;\n\n\t\treturn totalSize;\n\t}\n\n\t/**\n\t * Try to parse the first outgoing message from accumulated bytes.\n\t * Returns the requestId if enough data is available, undefined otherwise.\n\t */\n\t#tryParseOutgoing(buffer: Uint8Array): { requestId: bigint } | undefined {\n\t\tif (buffer.length === 0) return undefined;\n\n\t\t// Check typeId varint size before decoding\n\t\tconst typeSize = 1 << ((buffer[0] & 0xc0) >> 6);\n\t\tif (buffer.length < typeSize) return undefined;\n\n\t\tconst [typeId, afterType] = Varint.decode(buffer);\n\n\t\t// Need 2 bytes for u16 size\n\t\tif (afterType.length < 2) return undefined;\n\n\t\tconst size = (afterType[0] << 8) | afterType[1];\n\t\tconst bodyStart = afterType.subarray(2);\n\n\t\t// Need full body\n\t\tif (bodyStart.length < size) return undefined;\n\n\t\tconst body = bodyStart.subarray(0, size);\n\n\t\t// Decode requestId from body (QUIC varint)\n\t\tconst [reqId] = Varint.decode(body);\n\t\tconst requestId = BigInt(reqId);\n\n\t\t// PublishNamespace (0x06): also parse namespace for v14/v15 reverse lookup\n\t\tif (typeId === 0x06) {\n\t\t\ttry {\n\t\t\t\tconst [, afterReqId] = Varint.decode(body);\n\t\t\t\tthis.#parseAndRegisterNamespace(afterReqId, requestId);\n\t\t\t} catch {\n\t\t\t\t// Non-critical: only needed for v14/v15 PublishNamespaceDone/Cancel\n\t\t\t}\n\t\t}\n\n\t\t// SubscribeNamespace (0x11): register for follow-up routing\n\t\tif (typeId === 0x11) {\n\t\t\tthis.#subscribeNamespaces.add(requestId);\n\t\t}\n\n\t\treturn { requestId };\n\t}\n\n\t/**\n\t * Parse a namespace from raw bytes and register it for reverse lookup.\n\t */\n\t#parseAndRegisterNamespace(buf: Uint8Array, requestId: bigint) {\n\t\tconst decoder = new TextDecoder();\n\t\tconst [partCount, afterCount] = Varint.decode(buf);\n\t\tlet cursor = afterCount;\n\t\tconst parts: string[] = [];\n\t\tfor (let i = 0; i < partCount; i++) {\n\t\t\tconst [len, afterLen] = Varint.decode(cursor);\n\t\t\tparts.push(decoder.decode(afterLen.subarray(0, len)));\n\t\t\tcursor = afterLen.subarray(len);\n\t\t}\n\t\tconst namespace = parts.join(\"/\");\n\t\tthis.#namespaces.set(namespace, requestId);\n\t\tthis.#namespacesByRequestId.set(requestId, namespace);\n\t}\n\n\t/** Create a WritableStream that buffers and writes complete messages to the control stream under mutex. */\n\t#createSendWritable(): WritableStream<Uint8Array> {\n\t\tlet buffer = new Uint8Array(0);\n\t\treturn new WritableStream<Uint8Array>({\n\t\t\twrite: async (chunk) => {\n\t\t\t\tconst newBuf = new Uint8Array(buffer.length + chunk.length);\n\t\t\t\tnewBuf.set(buffer);\n\t\t\t\tnewBuf.set(chunk, buffer.length);\n\t\t\t\tbuffer = newBuf;\n\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst boundary = this.#messageSize(buffer);\n\t\t\t\t\tif (boundary === undefined) break;\n\n\t\t\t\t\tconst toFlush = buffer.subarray(0, boundary);\n\t\t\t\t\tbuffer = buffer.subarray(boundary);\n\t\t\t\t\tawait this.#writeMutex.runExclusive(() => this.#writer.write(toFlush));\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\n\t/** Encode raw message bytes: [typeId varint][size u16 BE][body] */\n\t#encodeRaw(typeId: number, size: number, body: Uint8Array): Uint8Array {\n\t\t// v14-v16 always use QUIC varint\n\t\tconst typeIdBytes = Varint.encodeTo(new ArrayBuffer(9), typeId);\n\t\tconst result = new Uint8Array(typeIdBytes.byteLength + 2 + body.byteLength);\n\t\tresult.set(typeIdBytes, 0);\n\t\tconst sizeView = new DataView(result.buffer, typeIdBytes.byteLength, 2);\n\t\tsizeView.setUint16(0, size);\n\t\tresult.set(body, typeIdBytes.byteLength + 2);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Classify a control message and extract its requestId for routing.\n\t */\n\tasync #classify(\n\t\ttypeId: number,\n\t\tbody: Uint8Array,\n\t): Promise<{ route: typeof Route.GoAway } | { route: Exclude<Route, typeof Route.GoAway>; requestId: bigint }> {\n\t\tconst readRequestId = async (): Promise<bigint> => {\n\t\t\tconst r = new Reader(undefined, body, this.version);\n\t\t\treturn await r.u62();\n\t\t};\n\n\t\tconst readNamespaceRequestId = async (): Promise<bigint> => {\n\t\t\tconst r = new Reader(undefined, body, this.version);\n\t\t\tconst namespace = await Namespace.decode(r);\n\t\t\tconst requestId = this.#namespaces.get(namespace);\n\t\t\tif (requestId === undefined) throw new Error(`unknown namespace: ${namespace}`);\n\t\t\tthis.#namespaces.delete(namespace);\n\t\t\treturn requestId;\n\t\t};\n\n\t\tswitch (typeId) {\n\t\t\t// === FollowUp: route to existing stream ===\n\t\t\tcase 0x02: {\n\t\t\t\t// SubscribeUpdate / REQUEST_UPDATE\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.FollowUp, requestId };\n\t\t\t}\n\n\t\t\t// === NewRequest: create virtual stream ===\n\t\t\tcase 0x03: // Subscribe\n\t\t\tcase 0x16: // Fetch\n\t\t\tcase 0x1d: // Publish\n\t\t\tcase 0x0d: {\n\t\t\t\t// TrackStatusRequest\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.NewRequest, requestId };\n\t\t\t}\n\t\t\tcase 0x06: {\n\t\t\t\t// PublishNamespace — also store namespace for v14/v15 reverse lookup\n\t\t\t\tconst r = new Reader(undefined, body, this.version);\n\t\t\t\tconst requestId = await r.u62();\n\t\t\t\tconst namespace = await Namespace.decode(r);\n\t\t\t\tthis.#namespaces.set(namespace, requestId);\n\t\t\t\tthis.#namespacesByRequestId.set(requestId, namespace);\n\t\t\t\treturn { route: Route.NewRequest, requestId };\n\t\t\t}\n\t\t\tcase 0x11: {\n\t\t\t\t// SubscribeNamespace (v14/v15 only on control stream)\n\t\t\t\tif (this.version !== Version.DRAFT_14 && this.version !== Version.DRAFT_15) {\n\t\t\t\t\tthrow new Error(\"unexpected SubscribeNamespace on control stream\");\n\t\t\t\t}\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.NewRequest, requestId };\n\t\t\t}\n\n\t\t\t// === Response: push bytes, keep stream open ===\n\t\t\tcase 0x04: {\n\t\t\t\t// SubscribeOk\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\t\t\tcase 0x18: {\n\t\t\t\t// FetchOk\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\t\t\tcase 0x1e: {\n\t\t\t\t// PublishOk\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\t\t\tcase 0x07: {\n\t\t\t\t// v14: PublishNamespaceOk, v15+: RequestOk\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\t\t\tcase 0x12: {\n\t\t\t\t// SubscribeNamespaceOk (v14 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14) throw new Error(\"unexpected SubscribeNamespaceOk\");\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\n\t\t\t// === ErrorResponse: push bytes + close ===\n\t\t\tcase 0x05: {\n\t\t\t\t// SubscribeError (v14) / RequestError (v15+)\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t}\n\t\t\tcase 0x19: {\n\t\t\t\t// FetchError (v14 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14) throw new Error(\"unexpected FetchError\");\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t}\n\t\t\tcase 0x1f: {\n\t\t\t\t// PublishError (v14 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14) throw new Error(\"unexpected PublishError\");\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t}\n\t\t\tcase 0x08: {\n\t\t\t\tif (this.version === Version.DRAFT_14) {\n\t\t\t\t\t// PublishNamespaceError\n\t\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t\t}\n\t\t\t\t// v15: Namespace entry (no requestId) — route to SubscribeNamespace stream\n\t\t\t\tconst subNs08 = this.#subscribeNamespaces.values().next().value;\n\t\t\t\tif (subNs08 === undefined) throw new Error(\"unexpected message 0x08: no SubscribeNamespace stream\");\n\t\t\t\treturn { route: Route.FollowUp, requestId: subNs08 };\n\t\t\t}\n\t\t\tcase 0x0e: {\n\t\t\t\t// v15: NamespaceDone entry (no requestId) — route to SubscribeNamespace stream\n\t\t\t\tconst subNs0e = this.#subscribeNamespaces.values().next().value;\n\t\t\t\tif (subNs0e === undefined) throw new Error(\"unexpected message 0x0e: no SubscribeNamespace stream\");\n\t\t\t\treturn { route: Route.FollowUp, requestId: subNs0e };\n\t\t\t}\n\t\t\tcase 0x13: {\n\t\t\t\t// SubscribeNamespaceError (v14 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14) throw new Error(\"unexpected SubscribeNamespaceError\");\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t}\n\n\t\t\t// === CloseStream: close recv (no bytes pushed) ===\n\t\t\tcase 0x0a: {\n\t\t\t\t// Unsubscribe\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x0b: {\n\t\t\t\t// PublishDone\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x17: {\n\t\t\t\t// FetchCancel\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x09: {\n\t\t\t\t// PublishNamespaceDone: v16 uses requestId, v14/v15 uses namespace\n\t\t\t\tif (this.version === Version.DRAFT_16) {\n\t\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t\t}\n\t\t\t\tconst requestId = await readNamespaceRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x0c: {\n\t\t\t\t// PublishNamespaceCancel: v16 uses requestId, v14/v15 uses namespace\n\t\t\t\tif (this.version === Version.DRAFT_16) {\n\t\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t\t}\n\t\t\t\tconst requestId = await readNamespaceRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x14: {\n\t\t\t\t// UnsubscribeNamespace (v14/v15 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14 && this.version !== Version.DRAFT_15) {\n\t\t\t\t\tthrow new Error(\"unexpected UnsubscribeNamespace\");\n\t\t\t\t}\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\n\t\t\t// === Utility ===\n\t\t\tcase 0x15: {\n\t\t\t\t// MaxRequestId\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.MaxRequestId, requestId };\n\t\t\t}\n\t\t\tcase 0x1a: {\n\t\t\t\t// RequestsBlocked — connection-level, consume and ignore\n\t\t\t\tawait readRequestId();\n\t\t\t\treturn { route: Route.Ignore, requestId: 0n };\n\t\t\t}\n\n\t\t\t// === Terminal ===\n\t\t\tcase 0x10: // GoAway\n\t\t\t\treturn { route: Route.GoAway };\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`unknown control message type: 0x${typeId.toString(16)}`);\n\t\t}\n\t}\n\n\tclose() {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tconsole.debug(\"adapter: close() called\");\n\n\t\t// Close all virtual streams\n\t\tfor (const entry of this.#streams.values()) {\n\t\t\ttry {\n\t\t\t\tentry.controller.close();\n\t\t\t} catch {\n\t\t\t\t// Already closed\n\t\t\t}\n\t\t}\n\t\tthis.#streams.clear();\n\n\t\t// Resolve any waiting acceptBi callers\n\t\tfor (const waiter of this.#incomingWaiters) {\n\t\t\twaiter(undefined);\n\t\t}\n\t\tthis.#incomingWaiters = [];\n\n\t\t// Clear namespace mappings\n\t\tthis.#namespaces.clear();\n\t\tthis.#namespacesByRequestId.clear();\n\t\tthis.#subscribeNamespaces.clear();\n\n\t\t// Unblock maxRequestId waiters\n\t\tfor (const resolve of this.#maxRequestIdResolves) resolve();\n\t\tthis.#maxRequestIdResolves = [];\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/ietf/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAoB,OAAO,EAAE,MAAM,cAAc,CAAC;AAezD;;;GAGG;AACH,MAAM,OAAO,aAAa;IACzB,KAAK,CAAe;I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,mCAAmC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5E,CAAC;IACF,CAAC;IAED,KAAK;QACJ,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAEzC,4BAA4B;QAC5B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC5C,IAAI,CAAC;gBACJ,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACR,iBAAiB;YAClB,CAAC;QACF,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAEtB,uCAAuC;QACvC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC5C,MAAM,CAAC,SAAS,CAAC,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAE3B,2BAA2B;QAC3B,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAAC;QACpC,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;QAElC,+BAA+B;QAC/B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,qBAAqB;YAAE,OAAO,EAAE,CAAC;QAC5D,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;IACjC,CAAC;CACD","sourcesContent":["import { Mutex } from \"async-mutex\";\nimport { Reader, Stream, type Writer } from \"../stream.ts\";\nimport * as Varint from \"../varint.ts\";\nimport * as Namespace from \"./namespace.ts\";\nimport { type IetfVersion, Version } from \"./version.ts\";\n\n/**\n * Interface for opening outgoing bidi streams and allocating request IDs.\n * Implemented by both ControlStreamAdapter (v14-v16) and NativeSession (v17).\n */\nexport interface Session {\n\topenBi(): Stream | Promise<Stream>;\n\topenNativeBi?(): Promise<Stream>;\n\tacceptBi(): Promise<Stream | undefined>;\n\tnextRequestId(): Promise<bigint | undefined>;\n\tclose(): void;\n\treadonly version: IetfVersion;\n}\n\n/**\n * v17 native session — thin wrapper around WebTransport.\n * Each request gets its own real bidi stream; no control stream multiplexing.\n */\nexport class NativeSession implements Session {\n\t#quic: WebTransport;\n\t// moq-transport reserves even request IDs for the client and odd for the server,\n\t// so the two peers' ID spaces never overlap.\n\t#requestId: bigint;\n\treadonly version: IetfVersion;\n\n\tconstructor(quic: WebTransport, version: IetfVersion, client: boolean) {\n\t\tthis.#quic = quic;\n\t\tthis.version = version;\n\t\tthis.#requestId = client ? 0n : 1n;\n\t}\n\n\tasync openBi(): Promise<Stream> {\n\t\treturn Stream.open(this.#quic, { version: this.version });\n\t}\n\n\tasync acceptBi(): Promise<Stream | undefined> {\n\t\treturn Stream.accept(this.#quic, this.version);\n\t}\n\n\tasync nextRequestId(): Promise<bigint | undefined> {\n\t\tconst id = this.#requestId;\n\t\tthis.#requestId += 2n;\n\t\treturn id;\n\t}\n\n\t/** Closes the underlying WebTransport session. */\n\tclose() {\n\t\tthis.#quic.close();\n\t}\n}\n\n// Route classification for control stream messages.\nconst Route = {\n\tNewRequest: 0, // Create virtual bidi stream, push initial message\n\tResponse: 1, // Push message to existing stream (keep open)\n\tErrorResponse: 2, // Push message to existing stream, then close\n\tCloseStream: 3, // Close stream recv (no bytes pushed)\n\tFollowUp: 4, // Push follow-up message to existing stream\n\tMaxRequestId: 5, // Update flow control\n\tIgnore: 6, // Connection-level, no routing\n\tGoAway: 7, // Terminal\n} as const;\ntype Route = (typeof Route)[keyof typeof Route];\n\ninterface StreamEntry {\n\tcontroller: ReadableStreamDefaultController<Uint8Array>;\n}\n\ntype NamespaceDirection = \"incoming\" | \"outgoing\";\n\n/**\n * Converts v14-v16 control stream multiplexing into virtual bidi streams.\n *\n * Reads control messages, classifies them, and routes to virtual Stream objects.\n * Each request/response pair gets its own virtual Stream, making all versions\n * look like v17's stream-per-request model.\n */\nexport class ControlStreamAdapter implements Session {\n\t// WebTransport session (for opening real bidi streams in v16)\n\t#quic: WebTransport;\n\n\t// Control stream\n\t#reader: Reader;\n\t#writer: Writer;\n\t#writeMutex = new Mutex();\n\treadonly version: IetfVersion;\n\n\t// Virtual streams keyed by requestId\n\t#streams = new Map<bigint, StreamEntry>();\n\n\t// Namespace → requestId reverse lookups for v14/v15 namespace-keyed messages.\n\t// DONE names an incoming announcement and CANCEL names an outgoing one, so a relay\n\t// may legitimately hold the same namespace in both maps at once.\n\t#incomingNamespaces = new Map<string, bigint>();\n\t#outgoingNamespaces = new Map<string, bigint>();\n\n\t// requestId → namespace reverse lookup, one entry per request including a refused\n\t// duplicate, so #forget can clean up whichever request goes away.\n\t#namespacesByRequestId = new Map<bigint, { namespace: string; direction: NamespaceDirection }>();\n\n\t// SubscribeNamespace requestIds — for routing 0x08/0x0E entries that lack requestId (v14/v15)\n\t#subscribeNamespaces = new Set<bigint>();\n\n\t// Incoming stream queue (for acceptBi)\n\t#incomingQueue: Stream[] = [];\n\t#incomingWaiters: ((stream: Stream | undefined) => void)[] = [];\n\n\t// Request ID flow control. moq-transport reserves even request IDs for the\n\t// client and odd for the server, so the two peers' ID spaces never overlap.\n\t// This matters here because a single `#streams` map routes every request by\n\t// ID: overlapping spaces would let an inbound request clobber the routing\n\t// entry of an outbound one with the same number (e.g. an inbound\n\t// PUBLISH_NAMESPACE stealing a pending SUBSCRIBE's slot, so SUBSCRIBE_OK is\n\t// delivered to the wrong virtual stream).\n\t#requestId: bigint;\n\t#maxRequestId: bigint;\n\t#maxRequestIdResolves: (() => void)[] = [];\n\n\t#closed = false;\n\n\tconstructor(\n\t\tquic: WebTransport,\n\t\tcontrolStream: Stream,\n\t\tversion: IetfVersion,\n\t\tmaxRequestId: bigint,\n\t\tclient: boolean,\n\t) {\n\t\tthis.#quic = quic;\n\t\tthis.#reader = controlStream.reader;\n\t\tthis.#reader.version = version;\n\t\tthis.#writer = controlStream.writer;\n\t\tthis.#writer.version = version;\n\t\tthis.version = version;\n\t\tthis.#maxRequestId = maxRequestId;\n\t\tthis.#requestId = client ? 0n : 1n;\n\t}\n\n\t/**\n\t * Accept the next incoming virtual bidi stream.\n\t * Blocks until a new request arrives on the control stream.\n\t */\n\tasync acceptBi(): Promise<Stream | undefined> {\n\t\tif (this.#closed) return undefined;\n\n\t\tconst queued = this.#incomingQueue.shift();\n\t\tif (queued) return queued;\n\n\t\treturn new Promise<Stream | undefined>((resolve) => {\n\t\t\tthis.#incomingWaiters.push(resolve);\n\t\t});\n\t}\n\n\t/**\n\t * Open an outgoing virtual bidi stream.\n\t * Buffers writes until the first full message is available, parses the\n\t * requestId (and namespace for PublishNamespace), self-registers, then\n\t * flushes. Subsequent writes go directly to the control stream.\n\t */\n\topenBi(): Stream {\n\t\tlet controller!: ReadableStreamDefaultController<Uint8Array>;\n\t\tlet registeredRequestId: bigint | undefined;\n\n\t\tconst readable = new ReadableStream<Uint8Array>({\n\t\t\tstart(c) {\n\t\t\t\tcontroller = c;\n\t\t\t},\n\t\t\tcancel: () => {\n\t\t\t\tif (registeredRequestId !== undefined) {\n\t\t\t\t\tthis.#forget(registeredRequestId);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\tlet buffer = new Uint8Array(0);\n\t\tlet registered = false;\n\n\t\tconst sendWritable = new WritableStream<Uint8Array>({\n\t\t\twrite: async (chunk) => {\n\t\t\t\t// Always accumulate bytes and flush only complete messages\n\t\t\t\t// to prevent interleaving of partial messages from concurrent virtual streams.\n\t\t\t\tconst newBuf = new Uint8Array(buffer.length + chunk.length);\n\t\t\t\tnewBuf.set(buffer);\n\t\t\t\tnewBuf.set(chunk, buffer.length);\n\t\t\t\tbuffer = newBuf;\n\n\t\t\t\t// Try to flush complete messages from the buffer\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst boundary = this.#messageSize(buffer);\n\t\t\t\t\tif (boundary === undefined) break;\n\n\t\t\t\t\tconst toFlush = buffer.subarray(0, boundary);\n\t\t\t\t\tbuffer = buffer.subarray(boundary);\n\n\t\t\t\t\tif (!registered) {\n\t\t\t\t\t\t// First message: extract requestId and register before flushing\n\t\t\t\t\t\tconst parsed = await this.#tryParseOutgoing(toFlush);\n\t\t\t\t\t\tif (parsed) {\n\t\t\t\t\t\t\tregisteredRequestId = parsed.requestId;\n\t\t\t\t\t\t\tthis.#streams.set(parsed.requestId, { controller });\n\t\t\t\t\t\t\tregistered = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tawait this.#writeMutex.runExclusive(() => this.#writer.write(toFlush));\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\tconst stream = new Stream({ readable, writable: sendWritable });\n\t\tstream.reader.version = this.version;\n\t\tstream.writer.version = this.version;\n\t\treturn stream;\n\t}\n\n\t/**\n\t * Open a real WebTransport bidi stream (for v16 SubscribeNamespace).\n\t */\n\tasync openNativeBi(): Promise<Stream> {\n\t\treturn Stream.open(this.#quic, { version: this.version });\n\t}\n\n\t/**\n\t * Allocate the next request ID, blocking if flow control limit reached.\n\t */\n\tasync nextRequestId(): Promise<bigint | undefined> {\n\t\tfor (;;) {\n\t\t\tif (this.#closed) return undefined;\n\t\t\tconst id = this.#requestId;\n\t\t\tif (id < this.#maxRequestId) {\n\t\t\t\tthis.#requestId += 2n;\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tthis.#maxRequestIdResolves.push(resolve);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Main run loop — reads control stream messages and routes to virtual streams.\n\t * Must be called after construction. Runs until the control stream closes.\n\t */\n\tasync run(): Promise<void> {\n\t\ttry {\n\t\t\t// v16: also accept real bidi streams (for SubscribeNamespace)\n\t\t\tif (this.version === Version.DRAFT_16) {\n\t\t\t\tvoid this.#acceptNativeBidis();\n\t\t\t}\n\n\t\t\tfor (;;) {\n\t\t\t\tconst done = await this.#reader.done();\n\t\t\t\tif (done) break;\n\n\t\t\t\tconst typeId = await this.#reader.u53();\n\t\t\t\tconst size = await this.#reader.u16();\n\t\t\t\tconst body = await this.#reader.read(size);\n\n\t\t\t\tconst classified = await this.#classify(typeId, body);\n\n\t\t\t\tif (classified.route === Route.GoAway) {\n\t\t\t\t\tconsole.warn(\"received GOAWAY on control stream\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { route, requestId } = classified;\n\n\t\t\t\tswitch (route) {\n\t\t\t\t\tcase Route.NewRequest:\n\t\t\t\t\t\tthis.#newRequest(typeId, size, body, requestId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.Response:\n\t\t\t\t\t\tthis.#pushMessage(requestId, typeId, size, body);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.ErrorResponse:\n\t\t\t\t\t\tthis.#pushMessage(requestId, typeId, size, body);\n\t\t\t\t\t\tthis.#closeStream(requestId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.CloseStream:\n\t\t\t\t\t\tthis.#closeStream(requestId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.FollowUp:\n\t\t\t\t\t\tthis.#pushMessage(requestId, typeId, size, body);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Route.MaxRequestId:\n\t\t\t\t\t\tthis.#maxRequestId = requestId;\n\t\t\t\t\t\tfor (const resolve of this.#maxRequestIdResolves) resolve();\n\t\t\t\t\t\tthis.#maxRequestIdResolves = [];\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/** Accept real WebTransport bidi streams and queue them for acceptBi (v16). */\n\tasync #acceptNativeBidis(): Promise<void> {\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst stream = await Stream.accept(this.#quic, this.version);\n\t\t\t\tif (!stream) break;\n\n\t\t\t\tconst waiter = this.#incomingWaiters.shift();\n\t\t\t\tif (waiter) {\n\t\t\t\t\twaiter(stream);\n\t\t\t\t} else {\n\t\t\t\t\tthis.#incomingQueue.push(stream);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Session closed\n\t\t}\n\t}\n\n\t#newRequest(typeId: number, size: number, body: Uint8Array, requestId: bigint) {\n\t\tlet controller!: ReadableStreamDefaultController<Uint8Array>;\n\t\tconst readable = new ReadableStream<Uint8Array>({\n\t\t\tstart(c) {\n\t\t\t\tcontroller = c;\n\t\t\t},\n\t\t\tcancel: () => {\n\t\t\t\tthis.#forget(requestId);\n\t\t\t},\n\t\t});\n\n\t\tconst sendWritable = this.#createSendWritable();\n\n\t\tconst stream = new Stream({ readable, writable: sendWritable });\n\t\tstream.reader.version = this.version;\n\t\tstream.writer.version = this.version;\n\n\t\tthis.#streams.set(requestId, { controller });\n\n\t\t// Push initial message bytes so the dispatcher can read typeId + decode\n\t\tcontroller.enqueue(this.#encodeRaw(typeId, size, body));\n\n\t\t// Queue for acceptBi\n\t\tconst waiter = this.#incomingWaiters.shift();\n\t\tif (waiter) {\n\t\t\twaiter(stream);\n\t\t} else {\n\t\t\tthis.#incomingQueue.push(stream);\n\t\t}\n\t}\n\n\t#pushMessage(requestId: bigint, typeId: number, size: number, body: Uint8Array) {\n\t\tconst entry = this.#streams.get(requestId);\n\t\tif (!entry) {\n\t\t\tconsole.warn(`adapter: no stream for requestId=${requestId} typeId=0x${typeId.toString(16)}`);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tentry.controller.enqueue(this.#encodeRaw(typeId, size, body));\n\t\t} catch {\n\t\t\t// Stream already closed\n\t\t}\n\t}\n\n\t#closeStream(requestId: bigint) {\n\t\tconst entry = this.#streams.get(requestId);\n\t\tthis.#forget(requestId);\n\t\tif (!entry) return;\n\t\tconsole.debug(`adapter: closing stream requestId=${requestId}`);\n\t\ttry {\n\t\t\tentry.controller.close();\n\t\t} catch {\n\t\t\t// Already closed\n\t\t}\n\t}\n\n\t/**\n\t * Drop every routing entry a request owns, keeping the two namespace maps in step.\n\t *\n\t * Runs even when the virtual stream is already gone, so a request that was torn down\n\t * locally still gives its namespace back.\n\t */\n\t#forget(requestId: bigint) {\n\t\tthis.#streams.delete(requestId);\n\t\tthis.#subscribeNamespaces.delete(requestId);\n\n\t\tconst registered = this.#namespacesByRequestId.get(requestId);\n\t\tif (registered === undefined) return;\n\t\tthis.#namespacesByRequestId.delete(requestId);\n\t\tconst namespaces = this.#namespaceRequests(registered.direction);\n\n\t\t// Only the request holding the live announcement may retract it. A refused duplicate\n\t\t// carries the same name, and letting its close withdraw the name would strand the\n\t\t// original: its own DONE would then resolve to nothing.\n\t\tif (namespaces.get(registered.namespace) === requestId) namespaces.delete(registered.namespace);\n\t}\n\n\t/**\n\t * Returns the total byte size of the first complete message in buffer,\n\t * or undefined if the buffer doesn't contain a complete message yet.\n\t * Message format: [typeId varint][size u16 BE][body of `size` bytes]\n\t */\n\t#messageSize(buffer: Uint8Array): number | undefined {\n\t\tif (buffer.length === 0) return undefined;\n\n\t\tconst typeSize = 1 << ((buffer[0] & 0xc0) >> 6);\n\t\tif (buffer.length < typeSize) return undefined;\n\n\t\tconst [, afterType] = Varint.decode(buffer);\n\t\tif (afterType.length < 2) return undefined;\n\n\t\tconst size = (afterType[0] << 8) | afterType[1];\n\t\tconst totalSize = buffer.length - afterType.length + 2 + size;\n\t\tif (buffer.length < totalSize) return undefined;\n\n\t\treturn totalSize;\n\t}\n\n\t/**\n\t * Try to parse the first outgoing message from accumulated bytes.\n\t * Returns the requestId if enough data is available, undefined otherwise.\n\t */\n\tasync #tryParseOutgoing(buffer: Uint8Array): Promise<{ requestId: bigint } | undefined> {\n\t\tif (buffer.length === 0) return undefined;\n\n\t\t// Check typeId varint size before decoding\n\t\tconst typeSize = 1 << ((buffer[0] & 0xc0) >> 6);\n\t\tif (buffer.length < typeSize) return undefined;\n\n\t\tconst [typeId, afterType] = Varint.decode(buffer);\n\n\t\t// Need 2 bytes for u16 size\n\t\tif (afterType.length < 2) return undefined;\n\n\t\tconst size = (afterType[0] << 8) | afterType[1];\n\t\tconst bodyStart = afterType.subarray(2);\n\n\t\t// Need full body\n\t\tif (bodyStart.length < size) return undefined;\n\n\t\tconst body = bodyStart.subarray(0, size);\n\n\t\t// Decode requestId from body (QUIC varint)\n\t\tconst [reqId] = Varint.decode(body);\n\t\tconst requestId = BigInt(reqId);\n\n\t\t// PublishNamespace (0x06): also parse namespace for v14/v15 reverse lookup\n\t\tif (typeId === 0x06) {\n\t\t\ttry {\n\t\t\t\tawait this.#registerNamespace(body, \"outgoing\");\n\t\t\t} catch {\n\t\t\t\t// Non-critical: only needed for v14/v15 PublishNamespaceDone/Cancel\n\t\t\t}\n\t\t}\n\n\t\t// SubscribeNamespace (0x11): register for follow-up routing\n\t\tif (typeId === 0x11) {\n\t\t\tthis.#subscribeNamespaces.add(requestId);\n\t\t}\n\n\t\treturn { requestId };\n\t}\n\n\t/**\n\t * Decode a PublishNamespace body and register its namespace for the v14/v15\n\t * namespace-keyed withdrawals. Returns the request ID it carried.\n\t *\n\t * The one decode site for both directions: outgoing announcements go through\n\t * #tryParseOutgoing and incoming ones through #classify. The direction selects the\n\t * map that the peer's DONE or CANCEL will later consult.\n\t */\n\tasync #registerNamespace(body: Uint8Array, direction: NamespaceDirection): Promise<bigint> {\n\t\tconst r = new Reader(undefined, body, this.version);\n\t\tconst requestId = await r.u62();\n\t\tconst namespace = await Namespace.decode(r);\n\t\tconst namespaces = this.#namespaceRequests(direction);\n\n\t\tthis.#namespacesByRequestId.set(requestId, { namespace, direction });\n\n\t\t// First announcement in this direction wins. A duplicate is refused with 409, and\n\t\t// overwriting here would point the first request's withdrawal at the refused one,\n\t\t// which has no stream left, leaving the namespace announced forever.\n\t\tif (!namespaces.has(namespace)) namespaces.set(namespace, requestId);\n\n\t\treturn requestId;\n\t}\n\n\t#namespaceRequests(direction: NamespaceDirection): Map<string, bigint> {\n\t\treturn direction === \"incoming\" ? this.#incomingNamespaces : this.#outgoingNamespaces;\n\t}\n\n\t/** Create a WritableStream that buffers and writes complete messages to the control stream under mutex. */\n\t#createSendWritable(): WritableStream<Uint8Array> {\n\t\tlet buffer = new Uint8Array(0);\n\t\treturn new WritableStream<Uint8Array>({\n\t\t\twrite: async (chunk) => {\n\t\t\t\tconst newBuf = new Uint8Array(buffer.length + chunk.length);\n\t\t\t\tnewBuf.set(buffer);\n\t\t\t\tnewBuf.set(chunk, buffer.length);\n\t\t\t\tbuffer = newBuf;\n\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst boundary = this.#messageSize(buffer);\n\t\t\t\t\tif (boundary === undefined) break;\n\n\t\t\t\t\tconst toFlush = buffer.subarray(0, boundary);\n\t\t\t\t\tbuffer = buffer.subarray(boundary);\n\t\t\t\t\tawait this.#writeMutex.runExclusive(() => this.#writer.write(toFlush));\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\n\t/** Encode raw message bytes: [typeId varint][size u16 BE][body] */\n\t#encodeRaw(typeId: number, size: number, body: Uint8Array): Uint8Array {\n\t\t// v14-v16 always use QUIC varint\n\t\tconst typeIdBytes = Varint.encodeTo(new ArrayBuffer(9), typeId);\n\t\tconst result = new Uint8Array(typeIdBytes.byteLength + 2 + body.byteLength);\n\t\tresult.set(typeIdBytes, 0);\n\t\tconst sizeView = new DataView(result.buffer, typeIdBytes.byteLength, 2);\n\t\tsizeView.setUint16(0, size);\n\t\tresult.set(body, typeIdBytes.byteLength + 2);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Classify a control message and extract its requestId for routing.\n\t */\n\tasync #classify(\n\t\ttypeId: number,\n\t\tbody: Uint8Array,\n\t): Promise<{ route: typeof Route.GoAway } | { route: Exclude<Route, typeof Route.GoAway>; requestId: bigint }> {\n\t\tconst readRequestId = async (): Promise<bigint> => {\n\t\t\tconst r = new Reader(undefined, body, this.version);\n\t\t\treturn await r.u62();\n\t\t};\n\n\t\t// v14/v15 name their withdrawals instead of numbering them. A name we have no\n\t\t// announcement for is dropped, not fatal: it belongs to a duplicate we already\n\t\t// refused, or to a request that is already gone, so there is nothing left to close.\n\t\t// The mapping itself is released by #forget when the stream goes.\n\t\tconst readNamespaceRequestId = async (direction: NamespaceDirection): Promise<bigint | undefined> => {\n\t\t\tconst r = new Reader(undefined, body, this.version);\n\t\t\tconst namespace = await Namespace.decode(r);\n\t\t\tconst namespaces = this.#namespaceRequests(direction);\n\t\t\tconst requestId = namespaces.get(namespace);\n\t\t\tif (requestId === undefined) console.warn(`adapter: no announcement for namespace: ${namespace}`);\n\t\t\treturn requestId;\n\t\t};\n\n\t\tswitch (typeId) {\n\t\t\t// === FollowUp: route to existing stream ===\n\t\t\tcase 0x02: {\n\t\t\t\t// SubscribeUpdate / REQUEST_UPDATE\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.FollowUp, requestId };\n\t\t\t}\n\n\t\t\t// === NewRequest: create virtual stream ===\n\t\t\tcase 0x03: // Subscribe\n\t\t\tcase 0x16: // Fetch\n\t\t\tcase 0x1d: // Publish\n\t\t\tcase 0x0d: {\n\t\t\t\t// TrackStatusRequest\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.NewRequest, requestId };\n\t\t\t}\n\t\t\tcase 0x06: {\n\t\t\t\t// PublishNamespace: also store the namespace for v14/v15 reverse lookup\n\t\t\t\tconst requestId = await this.#registerNamespace(body, \"incoming\");\n\t\t\t\treturn { route: Route.NewRequest, requestId };\n\t\t\t}\n\t\t\tcase 0x11: {\n\t\t\t\t// SubscribeNamespace (v14/v15 only on control stream)\n\t\t\t\tif (this.version !== Version.DRAFT_14 && this.version !== Version.DRAFT_15) {\n\t\t\t\t\tthrow new Error(\"unexpected SubscribeNamespace on control stream\");\n\t\t\t\t}\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.NewRequest, requestId };\n\t\t\t}\n\n\t\t\t// === Response: push bytes, keep stream open ===\n\t\t\tcase 0x04: {\n\t\t\t\t// SubscribeOk\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\t\t\tcase 0x18: {\n\t\t\t\t// FetchOk\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\t\t\tcase 0x1e: {\n\t\t\t\t// PublishOk\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\t\t\tcase 0x07: {\n\t\t\t\t// v14: PublishNamespaceOk, v15+: RequestOk\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\t\t\tcase 0x12: {\n\t\t\t\t// SubscribeNamespaceOk (v14 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14) throw new Error(\"unexpected SubscribeNamespaceOk\");\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.Response, requestId };\n\t\t\t}\n\n\t\t\t// === ErrorResponse: push bytes + close ===\n\t\t\tcase 0x05: {\n\t\t\t\t// SubscribeError (v14) / RequestError (v15+)\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t}\n\t\t\tcase 0x19: {\n\t\t\t\t// FetchError (v14 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14) throw new Error(\"unexpected FetchError\");\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t}\n\t\t\tcase 0x1f: {\n\t\t\t\t// PublishError (v14 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14) throw new Error(\"unexpected PublishError\");\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t}\n\t\t\tcase 0x08: {\n\t\t\t\tif (this.version === Version.DRAFT_14) {\n\t\t\t\t\t// PublishNamespaceError\n\t\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t\t}\n\t\t\t\t// v15: Namespace entry (no requestId) — route to SubscribeNamespace stream\n\t\t\t\tconst subNs08 = this.#subscribeNamespaces.values().next().value;\n\t\t\t\tif (subNs08 === undefined) throw new Error(\"unexpected message 0x08: no SubscribeNamespace stream\");\n\t\t\t\treturn { route: Route.FollowUp, requestId: subNs08 };\n\t\t\t}\n\t\t\tcase 0x0e: {\n\t\t\t\t// v15: NamespaceDone entry (no requestId) — route to SubscribeNamespace stream\n\t\t\t\tconst subNs0e = this.#subscribeNamespaces.values().next().value;\n\t\t\t\tif (subNs0e === undefined) throw new Error(\"unexpected message 0x0e: no SubscribeNamespace stream\");\n\t\t\t\treturn { route: Route.FollowUp, requestId: subNs0e };\n\t\t\t}\n\t\t\tcase 0x13: {\n\t\t\t\t// SubscribeNamespaceError (v14 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14) throw new Error(\"unexpected SubscribeNamespaceError\");\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.ErrorResponse, requestId };\n\t\t\t}\n\n\t\t\t// === CloseStream: close recv (no bytes pushed) ===\n\t\t\tcase 0x0a: {\n\t\t\t\t// Unsubscribe\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x0b: {\n\t\t\t\t// PublishDone\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x17: {\n\t\t\t\t// FetchCancel\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x09: {\n\t\t\t\t// PublishNamespaceDone: v16 uses requestId, v14/v15 names the incoming\n\t\t\t\t// announcement its sender is withdrawing.\n\t\t\t\tif (this.version === Version.DRAFT_16) {\n\t\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t\t}\n\t\t\t\tconst requestId = await readNamespaceRequestId(\"incoming\");\n\t\t\t\tif (requestId === undefined) return { route: Route.Ignore, requestId: 0n };\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x0c: {\n\t\t\t\t// PublishNamespaceCancel: v16 uses requestId, v14/v15 names the outgoing\n\t\t\t\t// announcement its sender is rejecting.\n\t\t\t\tif (this.version === Version.DRAFT_16) {\n\t\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t\t}\n\t\t\t\tconst requestId = await readNamespaceRequestId(\"outgoing\");\n\t\t\t\tif (requestId === undefined) return { route: Route.Ignore, requestId: 0n };\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\t\t\tcase 0x14: {\n\t\t\t\t// UnsubscribeNamespace (v14/v15 only)\n\t\t\t\tif (this.version !== Version.DRAFT_14 && this.version !== Version.DRAFT_15) {\n\t\t\t\t\tthrow new Error(\"unexpected UnsubscribeNamespace\");\n\t\t\t\t}\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.CloseStream, requestId };\n\t\t\t}\n\n\t\t\t// === Utility ===\n\t\t\tcase 0x15: {\n\t\t\t\t// MaxRequestId\n\t\t\t\tconst requestId = await readRequestId();\n\t\t\t\treturn { route: Route.MaxRequestId, requestId };\n\t\t\t}\n\t\t\tcase 0x1a: {\n\t\t\t\t// RequestsBlocked — connection-level, consume and ignore\n\t\t\t\tawait readRequestId();\n\t\t\t\treturn { route: Route.Ignore, requestId: 0n };\n\t\t\t}\n\n\t\t\t// === Terminal ===\n\t\t\tcase 0x10: // GoAway\n\t\t\t\treturn { route: Route.GoAway };\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`unknown control message type: 0x${typeId.toString(16)}`);\n\t\t}\n\t}\n\n\tclose() {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tconsole.debug(\"adapter: close() called\");\n\n\t\t// Close all virtual streams\n\t\tfor (const entry of this.#streams.values()) {\n\t\t\ttry {\n\t\t\t\tentry.controller.close();\n\t\t\t} catch {\n\t\t\t\t// Already closed\n\t\t\t}\n\t\t}\n\t\tthis.#streams.clear();\n\n\t\t// Resolve any waiting acceptBi callers\n\t\tfor (const waiter of this.#incomingWaiters) {\n\t\t\twaiter(undefined);\n\t\t}\n\t\tthis.#incomingWaiters = [];\n\n\t\t// Clear namespace mappings\n\t\tthis.#incomingNamespaces.clear();\n\t\tthis.#outgoingNamespaces.clear();\n\t\tthis.#namespacesByRequestId.clear();\n\t\tthis.#subscribeNamespaces.clear();\n\n\t\t// Unblock maxRequestId waiters\n\t\tfor (const resolve of this.#maxRequestIdResolves) resolve();\n\t\tthis.#maxRequestIdResolves = [];\n\t}\n}\n"]}
|
package/ietf/aliases.d.ts
CHANGED
|
@@ -1,11 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The full track name an alias is bound to.
|
|
3
|
+
*
|
|
4
|
+
* Kept as two components rather than one joined string: a track name may contain the same
|
|
5
|
+
* separator a broadcast path uses, so `a` + `b/c` and `a/b` + `c` would otherwise compare
|
|
6
|
+
* equal and turn a genuine collision into apparent sharing.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export type TrackIdentity = {
|
|
10
|
+
broadcast: string;
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Thrown when a group arrives for a subscription we already cancelled.
|
|
15
|
+
*
|
|
16
|
+
* The publisher only stops once our cancellation reaches it, so objects keep arriving for
|
|
17
|
+
* at least a round trip afterwards. Draft-19 section 11.1 asks us to keep enough state to
|
|
18
|
+
* discard them quickly "rather than treating them as belonging to an unknown Track Alias".
|
|
19
|
+
*
|
|
20
|
+
* This makes the window quiet, not safe. Once a publisher reassigns the alias the tombstone
|
|
21
|
+
* is reclaimed, and nothing on a group stream distinguishes the old subscription's objects
|
|
22
|
+
* from the new one's. Cancelling promptly is what bounds the exposure to a round trip.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare class RetiredTrackAlias extends Error {
|
|
26
|
+
constructor(alias: bigint);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Thrown when a publisher gives one alias to two subscriptions of the same track.
|
|
30
|
+
*
|
|
31
|
+
* Draft-19 section 5.1 permits this and expects the subscriber to demux by re-applying
|
|
32
|
+
* each subscription's filter. Ours are all LargestObject, so they are indistinguishable and
|
|
33
|
+
* we cannot, which costs the one subscription. It is not a protocol error, so it must not
|
|
34
|
+
* take the session down with it.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare class SharedTrackAlias extends Error {
|
|
38
|
+
constructor(alias: bigint);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Thrown when a publisher points one alias at two different tracks at once, which
|
|
42
|
+
* draft-19 section 11.1 makes fatal to the session.
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare class DuplicateTrackAlias extends Error {
|
|
46
|
+
constructor(alias: bigint);
|
|
47
|
+
}
|
|
1
48
|
/** Resolves publisher-chosen track aliases after control/data stream reordering. @internal */
|
|
2
49
|
export declare class TrackAliases<T> {
|
|
3
50
|
#private;
|
|
4
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Waits briefly for an alias to be established by SUBSCRIBE_OK or PUBLISH.
|
|
53
|
+
*
|
|
54
|
+
* Throws {@link RetiredTrackAlias} at once for an alias we cancelled, rather than
|
|
55
|
+
* waiting out the timeout for a binding that is never coming.
|
|
56
|
+
*/
|
|
5
57
|
get(alias: bigint): Promise<T>;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Establishes an alias and releases any data streams waiting for it.
|
|
60
|
+
*
|
|
61
|
+
* `track` is the full track name the alias was bound to, which is what decides whether a
|
|
62
|
+
* repeat is the legal sharing of an alias across subscriptions to one track
|
|
63
|
+
* ({@link SharedTrackAlias}) or the collision that must fail the session
|
|
64
|
+
* ({@link DuplicateTrackAlias}).
|
|
65
|
+
*/
|
|
66
|
+
set(alias: bigint, value: T, track: TrackIdentity): void;
|
|
67
|
+
/**
|
|
68
|
+
* Retires an alias whose subscription was cancelled, so groups still in flight for it
|
|
69
|
+
* are discarded promptly instead of reported as unknown.
|
|
70
|
+
*
|
|
71
|
+
* Only retires an alias that still belongs to the supplied value: a later subscription
|
|
72
|
+
* may already have reclaimed it, and that binding outranks a departing owner.
|
|
73
|
+
*
|
|
74
|
+
* Returns whether this caller still owned the binding, so metadata keyed by the alias is
|
|
75
|
+
* only torn down by the owner and never out from under whoever reclaimed it.
|
|
76
|
+
*/
|
|
77
|
+
retire(alias: bigint, value: T): boolean;
|
|
10
78
|
}
|
|
11
79
|
//# sourceMappingURL=aliases.d.ts.map
|
package/ietf/aliases.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../src/ietf/aliases.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../src/ietf/aliases.ts"],"names":[],"mappings":"AAiBA;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAMhE;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC3C,YAAY,KAAK,EAAE,MAAM,EAGxB;CACD;AAED;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,YAAY,KAAK,EAAE,MAAM,EAGxB;CACD;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC7C,YAAY,KAAK,EAAE,MAAM,EAGxB;CACD;AAED,8FAA8F;AAC9F,qBAAa,YAAY,CAAC,CAAC;;IAQ1B;;;;;OAKG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAyBnC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,QAehD;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAcvC;CAOD"}
|
package/ietf/aliases.js
CHANGED
|
@@ -1,13 +1,83 @@
|
|
|
1
1
|
/* @ts-self-types="./aliases.d.ts" */
|
|
2
2
|
const TRACK_ALIAS_TIMEOUT_MS = 1000;
|
|
3
|
+
/**
|
|
4
|
+
* How many cancelled aliases to remember. Objects keep arriving for about a round trip
|
|
5
|
+
* after we cancel, so a handful covers the window, while the cap keeps a long session with
|
|
6
|
+
* heavy subscription churn from accumulating tombstones for its whole lifetime.
|
|
7
|
+
*
|
|
8
|
+
* The bound is a count rather than a deadline, so eviction stays synchronous with
|
|
9
|
+
* retirement instead of needing a timer. The trade is that a session cancelling more than
|
|
10
|
+
* this many distinct aliases inside one round trip evicts a tombstone whose objects are
|
|
11
|
+
* still arriving; those fall back to the unknown-alias wait, which is the old behavior
|
|
12
|
+
* rather than a new failure.
|
|
13
|
+
*/
|
|
14
|
+
const RETIRED_ALIAS_CAPACITY = 64;
|
|
15
|
+
function sameTrack(a, b) {
|
|
16
|
+
return a.broadcast === b.broadcast && a.name === b.name;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thrown when a group arrives for a subscription we already cancelled.
|
|
20
|
+
*
|
|
21
|
+
* The publisher only stops once our cancellation reaches it, so objects keep arriving for
|
|
22
|
+
* at least a round trip afterwards. Draft-19 section 11.1 asks us to keep enough state to
|
|
23
|
+
* discard them quickly "rather than treating them as belonging to an unknown Track Alias".
|
|
24
|
+
*
|
|
25
|
+
* This makes the window quiet, not safe. Once a publisher reassigns the alias the tombstone
|
|
26
|
+
* is reclaimed, and nothing on a group stream distinguishes the old subscription's objects
|
|
27
|
+
* from the new one's. Cancelling promptly is what bounds the exposure to a round trip.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export class RetiredTrackAlias extends Error {
|
|
31
|
+
constructor(alias) {
|
|
32
|
+
super(`track alias retired: ${alias}`);
|
|
33
|
+
this.name = "RetiredTrackAlias";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when a publisher gives one alias to two subscriptions of the same track.
|
|
38
|
+
*
|
|
39
|
+
* Draft-19 section 5.1 permits this and expects the subscriber to demux by re-applying
|
|
40
|
+
* each subscription's filter. Ours are all LargestObject, so they are indistinguishable and
|
|
41
|
+
* we cannot, which costs the one subscription. It is not a protocol error, so it must not
|
|
42
|
+
* take the session down with it.
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export class SharedTrackAlias extends Error {
|
|
46
|
+
constructor(alias) {
|
|
47
|
+
super(`track alias shared by another subscription: ${alias}`);
|
|
48
|
+
this.name = "SharedTrackAlias";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Thrown when a publisher points one alias at two different tracks at once, which
|
|
53
|
+
* draft-19 section 11.1 makes fatal to the session.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export class DuplicateTrackAlias extends Error {
|
|
57
|
+
constructor(alias) {
|
|
58
|
+
super(`duplicate track alias: ${alias}`);
|
|
59
|
+
this.name = "DuplicateTrackAlias";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
3
62
|
/** Resolves publisher-chosen track aliases after control/data stream reordering. @internal */
|
|
4
63
|
export class TrackAliases {
|
|
5
64
|
#active = new Map();
|
|
6
65
|
#pending = new Map();
|
|
7
|
-
/**
|
|
66
|
+
/** Aliases whose subscription we cancelled, in retirement order so the oldest is forgotten first. */
|
|
67
|
+
#retired = [];
|
|
68
|
+
#retiredSet = new Set();
|
|
69
|
+
/**
|
|
70
|
+
* Waits briefly for an alias to be established by SUBSCRIBE_OK or PUBLISH.
|
|
71
|
+
*
|
|
72
|
+
* Throws {@link RetiredTrackAlias} at once for an alias we cancelled, rather than
|
|
73
|
+
* waiting out the timeout for a binding that is never coming.
|
|
74
|
+
*/
|
|
8
75
|
async get(alias) {
|
|
9
|
-
|
|
10
|
-
|
|
76
|
+
const bound = this.#active.get(alias);
|
|
77
|
+
if (bound !== undefined)
|
|
78
|
+
return bound.value;
|
|
79
|
+
if (this.#retiredSet.has(alias))
|
|
80
|
+
throw new RetiredTrackAlias(alias);
|
|
11
81
|
const { promise, resolve } = Promise.withResolvers();
|
|
12
82
|
let resolvers = this.#pending.get(alias);
|
|
13
83
|
if (!resolvers) {
|
|
@@ -29,24 +99,61 @@ export class TrackAliases {
|
|
|
29
99
|
this.#pending.delete(alias);
|
|
30
100
|
}
|
|
31
101
|
}
|
|
32
|
-
/**
|
|
33
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Establishes an alias and releases any data streams waiting for it.
|
|
104
|
+
*
|
|
105
|
+
* `track` is the full track name the alias was bound to, which is what decides whether a
|
|
106
|
+
* repeat is the legal sharing of an alias across subscriptions to one track
|
|
107
|
+
* ({@link SharedTrackAlias}) or the collision that must fail the session
|
|
108
|
+
* ({@link DuplicateTrackAlias}).
|
|
109
|
+
*/
|
|
110
|
+
set(alias, value, track) {
|
|
34
111
|
const active = this.#active.get(alias);
|
|
35
|
-
if (
|
|
36
|
-
if (active
|
|
37
|
-
|
|
38
|
-
|
|
112
|
+
if (active !== undefined) {
|
|
113
|
+
if (active.value === value)
|
|
114
|
+
return;
|
|
115
|
+
throw sameTrack(active.track, track) ? new SharedTrackAlias(alias) : new DuplicateTrackAlias(alias);
|
|
39
116
|
}
|
|
40
|
-
|
|
117
|
+
// Our subscription is gone, so the publisher is free to point the alias somewhere
|
|
118
|
+
// new. Reclaiming it also drops the tombstone early.
|
|
119
|
+
this.#forget(alias);
|
|
120
|
+
this.#active.set(alias, { value, track });
|
|
41
121
|
const resolvers = this.#pending.get(alias);
|
|
42
122
|
this.#pending.delete(alias);
|
|
43
123
|
for (const resolve of resolvers ?? [])
|
|
44
124
|
resolve(value);
|
|
45
125
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Retires an alias whose subscription was cancelled, so groups still in flight for it
|
|
128
|
+
* are discarded promptly instead of reported as unknown.
|
|
129
|
+
*
|
|
130
|
+
* Only retires an alias that still belongs to the supplied value: a later subscription
|
|
131
|
+
* may already have reclaimed it, and that binding outranks a departing owner.
|
|
132
|
+
*
|
|
133
|
+
* Returns whether this caller still owned the binding, so metadata keyed by the alias is
|
|
134
|
+
* only torn down by the owner and never out from under whoever reclaimed it.
|
|
135
|
+
*/
|
|
136
|
+
retire(alias, value) {
|
|
137
|
+
if (this.#active.get(alias)?.value !== value)
|
|
138
|
+
return false;
|
|
139
|
+
this.#active.delete(alias);
|
|
140
|
+
if (this.#retiredSet.has(alias))
|
|
141
|
+
return true;
|
|
142
|
+
this.#retiredSet.add(alias);
|
|
143
|
+
this.#retired.push(alias);
|
|
144
|
+
while (this.#retired.length > RETIRED_ALIAS_CAPACITY) {
|
|
145
|
+
const oldest = this.#retired.shift();
|
|
146
|
+
if (oldest !== undefined)
|
|
147
|
+
this.#retiredSet.delete(oldest);
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
#forget(alias) {
|
|
152
|
+
if (!this.#retiredSet.delete(alias))
|
|
153
|
+
return;
|
|
154
|
+
const at = this.#retired.indexOf(alias);
|
|
155
|
+
if (at !== -1)
|
|
156
|
+
this.#retired.splice(at, 1);
|
|
50
157
|
}
|
|
51
158
|
}
|
|
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\n\n/** Resolves publisher-chosen track aliases after control/data stream reordering. @internal */\nexport class TrackAliases<T> {\n\t#active = new Map<bigint, T>();\n\t#pending = new Map<bigint, Set<Resolver<T>>>();\n\n\t/** Waits briefly for an alias to be established by SUBSCRIBE_OK or PUBLISH. */\n\tasync get(alias: bigint): Promise<T> {\n\t\tif (this.#active.has(alias)) return this.#active.get(alias) as T;\n\n\t\tconst { promise, resolve } = Promise.withResolvers<T>();\n\t\tlet resolvers = this.#pending.get(alias);\n\t\tif (!resolvers) {\n\t\t\tresolvers = new Set();\n\t\t\tthis.#pending.set(alias, resolvers);\n\t\t}\n\t\tresolvers.add(resolve);\n\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tconst timeout = new Promise<never>((_, reject) => {\n\t\t\ttimer = setTimeout(() => reject(new Error(`unknown track alias: ${alias}`)), TRACK_ALIAS_TIMEOUT_MS);\n\t\t});\n\n\t\ttry {\n\t\t\treturn await Promise.race([promise, timeout]);\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t\tresolvers.delete(resolve);\n\t\t\tif (this.#pending.get(alias) === resolvers && resolvers.size === 0) this.#pending.delete(alias);\n\t\t}\n\t}\n\n\t/** Establishes an alias and releases any data streams waiting for it. */\n\tset(alias: bigint, value: T) {\n\t\tconst active = this.#active.get(alias);\n\t\tif (this.#active.has(alias)) {\n\t\t\tif (active !== value) throw new Error(`duplicate track alias: ${alias}`);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#active.set(alias, value);\n\t\tconst resolvers = this.#pending.get(alias);\n\t\tthis.#pending.delete(alias);\n\t\tfor (const resolve of resolvers ?? []) resolve(value);\n\t}\n\n\t/** Removes an alias only if it still belongs to the supplied value. */\n\tdelete(alias: bigint, value: T) {\n\t\tif (this.#active.get(alias) === value) this.#active.delete(alias);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"aliases.js","sourceRoot":"","sources":["../../src/ietf/aliases.ts"],"names":[],"mappings":"AAAA,MAAM,sBAA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AAM,GAAG,sBAAsB,EAAE,CAAC;YACtD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YACrC,IAAI,MAAM,KAAK,SAAS;gBAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,CAAC,KAAa;QACpB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,OAAO;QAC5C,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,EAAE,KAAK,CAAC,CAAC;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;CACD","sourcesContent":["const TRACK_ALIAS_TIMEOUT_MS = 1000;\n\n/**\n * How many cancelled aliases to remember. Objects keep arriving for about a round trip\n * after we cancel, so a handful covers the window, while the cap keeps a long session with\n * heavy subscription churn from accumulating tombstones for its whole lifetime.\n *\n * The bound is a count rather than a deadline, so eviction stays synchronous with\n * retirement instead of needing a timer. The trade is that a session cancelling more than\n * this many distinct aliases inside one round trip evicts a tombstone whose objects are\n * still arriving; those fall back to the unknown-alias wait, which is the old behavior\n * rather than a new failure.\n */\nconst RETIRED_ALIAS_CAPACITY = 64;\n\ntype Resolver<T> = PromiseWithResolvers<T>[\"resolve\"];\n\n/**\n * The full track name an alias is bound to.\n *\n * Kept as two components rather than one joined string: a track name may contain the same\n * separator a broadcast path uses, so `a` + `b/c` and `a/b` + `c` would otherwise compare\n * equal and turn a genuine collision into apparent sharing.\n * @internal\n */\nexport type TrackIdentity = { broadcast: string; name: string };\n\nfunction sameTrack(a: TrackIdentity, b: TrackIdentity): boolean {\n\treturn a.broadcast === b.broadcast && a.name === b.name;\n}\n\n/**\n * Thrown when a group arrives for a subscription we already cancelled.\n *\n * The publisher only stops once our cancellation reaches it, so objects keep arriving for\n * at least a round trip afterwards. Draft-19 section 11.1 asks us to keep enough state to\n * discard them quickly \"rather than treating them as belonging to an unknown Track Alias\".\n *\n * This makes the window quiet, not safe. Once a publisher reassigns the alias the tombstone\n * is reclaimed, and nothing on a group stream distinguishes the old subscription's objects\n * from the new one's. Cancelling promptly is what bounds the exposure to a round trip.\n * @internal\n */\nexport class RetiredTrackAlias extends Error {\n\tconstructor(alias: bigint) {\n\t\tsuper(`track alias retired: ${alias}`);\n\t\tthis.name = \"RetiredTrackAlias\";\n\t}\n}\n\n/**\n * Thrown when a publisher gives one alias to two subscriptions of the same track.\n *\n * Draft-19 section 5.1 permits this and expects the subscriber to demux by re-applying\n * each subscription's filter. Ours are all LargestObject, so they are indistinguishable and\n * we cannot, which costs the one subscription. It is not a protocol error, so it must not\n * take the session down with it.\n * @internal\n */\nexport class SharedTrackAlias extends Error {\n\tconstructor(alias: bigint) {\n\t\tsuper(`track alias shared by another subscription: ${alias}`);\n\t\tthis.name = \"SharedTrackAlias\";\n\t}\n}\n\n/**\n * Thrown when a publisher points one alias at two different tracks at once, which\n * draft-19 section 11.1 makes fatal to the session.\n * @internal\n */\nexport class DuplicateTrackAlias extends Error {\n\tconstructor(alias: bigint) {\n\t\tsuper(`duplicate track alias: ${alias}`);\n\t\tthis.name = \"DuplicateTrackAlias\";\n\t}\n}\n\n/** Resolves publisher-chosen track aliases after control/data stream reordering. @internal */\nexport class TrackAliases<T> {\n\t#active = new Map<bigint, { value: T; track: TrackIdentity }>();\n\t#pending = new Map<bigint, Set<Resolver<T>>>();\n\n\t/** Aliases whose subscription we cancelled, in retirement order so the oldest is forgotten first. */\n\t#retired: bigint[] = [];\n\t#retiredSet = new Set<bigint>();\n\n\t/**\n\t * Waits briefly for an alias to be established by SUBSCRIBE_OK or PUBLISH.\n\t *\n\t * Throws {@link RetiredTrackAlias} at once for an alias we cancelled, rather than\n\t * waiting out the timeout for a binding that is never coming.\n\t */\n\tasync get(alias: bigint): Promise<T> {\n\t\tconst bound = this.#active.get(alias);\n\t\tif (bound !== undefined) return bound.value;\n\t\tif (this.#retiredSet.has(alias)) throw new RetiredTrackAlias(alias);\n\n\t\tconst { promise, resolve } = Promise.withResolvers<T>();\n\t\tlet resolvers = this.#pending.get(alias);\n\t\tif (!resolvers) {\n\t\t\tresolvers = new Set();\n\t\t\tthis.#pending.set(alias, resolvers);\n\t\t}\n\t\tresolvers.add(resolve);\n\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tconst timeout = new Promise<never>((_, reject) => {\n\t\t\ttimer = setTimeout(() => reject(new Error(`unknown track alias: ${alias}`)), TRACK_ALIAS_TIMEOUT_MS);\n\t\t});\n\n\t\ttry {\n\t\t\treturn await Promise.race([promise, timeout]);\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t\tresolvers.delete(resolve);\n\t\t\tif (this.#pending.get(alias) === resolvers && resolvers.size === 0) this.#pending.delete(alias);\n\t\t}\n\t}\n\n\t/**\n\t * Establishes an alias and releases any data streams waiting for it.\n\t *\n\t * `track` is the full track name the alias was bound to, which is what decides whether a\n\t * repeat is the legal sharing of an alias across subscriptions to one track\n\t * ({@link SharedTrackAlias}) or the collision that must fail the session\n\t * ({@link DuplicateTrackAlias}).\n\t */\n\tset(alias: bigint, value: T, track: TrackIdentity) {\n\t\tconst active = this.#active.get(alias);\n\t\tif (active !== undefined) {\n\t\t\tif (active.value === value) return;\n\t\t\tthrow sameTrack(active.track, track) ? new SharedTrackAlias(alias) : new DuplicateTrackAlias(alias);\n\t\t}\n\n\t\t// Our subscription is gone, so the publisher is free to point the alias somewhere\n\t\t// new. Reclaiming it also drops the tombstone early.\n\t\tthis.#forget(alias);\n\n\t\tthis.#active.set(alias, { value, track });\n\t\tconst resolvers = this.#pending.get(alias);\n\t\tthis.#pending.delete(alias);\n\t\tfor (const resolve of resolvers ?? []) resolve(value);\n\t}\n\n\t/**\n\t * Retires an alias whose subscription was cancelled, so groups still in flight for it\n\t * are discarded promptly instead of reported as unknown.\n\t *\n\t * Only retires an alias that still belongs to the supplied value: a later subscription\n\t * may already have reclaimed it, and that binding outranks a departing owner.\n\t *\n\t * Returns whether this caller still owned the binding, so metadata keyed by the alias is\n\t * only torn down by the owner and never out from under whoever reclaimed it.\n\t */\n\tretire(alias: bigint, value: T): boolean {\n\t\tif (this.#active.get(alias)?.value !== value) return false;\n\t\tthis.#active.delete(alias);\n\n\t\tif (this.#retiredSet.has(alias)) return true;\n\t\tthis.#retiredSet.add(alias);\n\t\tthis.#retired.push(alias);\n\n\t\twhile (this.#retired.length > RETIRED_ALIAS_CAPACITY) {\n\t\t\tconst oldest = this.#retired.shift();\n\t\t\tif (oldest !== undefined) this.#retiredSet.delete(oldest);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t#forget(alias: bigint) {\n\t\tif (!this.#retiredSet.delete(alias)) return;\n\t\tconst at = this.#retired.indexOf(alias);\n\t\tif (at !== -1) this.#retired.splice(at, 1);\n\t}\n}\n"]}
|
package/ietf/fetch.d.ts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import type * as Path from "../path";
|
|
2
2
|
import type { Reader, Writer } from "../stream";
|
|
3
3
|
import type { IetfVersion } from "./version";
|
|
4
|
+
/**
|
|
5
|
+
* The header that begins a fetch stream (draft-20 section 11.4.4), naming the request it
|
|
6
|
+
* answers. Written by the publisher when serving a subscription's fill.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FetchHeader {
|
|
9
|
+
/** The uni stream type, not a control message id. */
|
|
10
|
+
static type: number;
|
|
11
|
+
/** The SUBSCRIBE (or FETCH) request this stream carries objects for. */
|
|
12
|
+
requestId: bigint;
|
|
13
|
+
constructor({ requestId }: {
|
|
14
|
+
requestId: bigint;
|
|
15
|
+
});
|
|
16
|
+
/** Write the header, which the stream type must already precede. */
|
|
17
|
+
encode(w: Writer, _version: IetfVersion): Promise<void>;
|
|
18
|
+
/** Read the header, with the stream type already consumed. */
|
|
19
|
+
static decode(r: Reader, _version: IetfVersion): Promise<FetchHeader>;
|
|
20
|
+
}
|
|
4
21
|
export declare class Fetch {
|
|
5
22
|
#private;
|
|
6
23
|
static id: number;
|
package/ietf/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/ietf/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,qBAAa,KAAK;;IACjB,MAAM,CAAC,EAAE,SAAQ;IAEjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAElB,YAAY,EACX,SAAS,EACT,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,SAAS,GACT,EAAE;QACF,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC;QAC3B,SAAS,EAAE,MAAM,CAAC;QAClB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KAClB,EAUA;IAMK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE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,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,EAIhE;IAMK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5D;IAED,OAAa,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAEzE;CAKD;AAGD,qBAAa,WAAW;;IACvB,MAAM,CAAC,EAAE,SAAQ;IAEjB,SAAS,EAAE,MAAM,CAAC;IAElB,YAAY,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,EAE/C;IAMK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5D;IAED,OAAa,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAE1E;CAKD"}
|
package/ietf/fetch.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
/* @ts-self-types="./fetch.d.ts" */
|
|
2
2
|
import * as Message from "./message.js";
|
|
3
|
+
/**
|
|
4
|
+
* The header that begins a fetch stream (draft-20 section 11.4.4), naming the request it
|
|
5
|
+
* answers. Written by the publisher when serving a subscription's fill.
|
|
6
|
+
*/
|
|
7
|
+
export class FetchHeader {
|
|
8
|
+
/** The uni stream type, not a control message id. */
|
|
9
|
+
static type = 0x5;
|
|
10
|
+
/** The SUBSCRIBE (or FETCH) request this stream carries objects for. */
|
|
11
|
+
requestId;
|
|
12
|
+
constructor({ requestId }) {
|
|
13
|
+
this.requestId = requestId;
|
|
14
|
+
}
|
|
15
|
+
/** Write the header, which the stream type must already precede. */
|
|
16
|
+
async encode(w, _version) {
|
|
17
|
+
await w.u62(this.requestId);
|
|
18
|
+
}
|
|
19
|
+
/** Read the header, with the stream type already consumed. */
|
|
20
|
+
static async decode(r, _version) {
|
|
21
|
+
return new FetchHeader({ requestId: await r.u62() });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
3
24
|
export class Fetch {
|
|
4
25
|
static id = 0x16;
|
|
5
26
|
requestId;
|
package/ietf/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/ietf/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,MAAM,OAAO,KAAK;IACjB,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC;IAEjB,SAAS,CAAS;IAClB,cAAc,CAAa;IAC3B,SAAS,CAAS;IAClB,kBAAkB,CAAS;IAC3B,UAAU,CAAS;IACnB,UAAU,CAAS;IACnB,WAAW,CAAS;IACpB,QAAQ,CAAS;IACjB,SAAS,CAAS;IAElB,YAAY,EACX,SAAS,EACT,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,SAAS,GAWT;QACA,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACvB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAA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M,CAAC,CAAS,EAAE,QAAqB;QACnD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAU;QAC9B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import type * as Path from \"../path.ts\";\nimport type { Reader, Writer } from \"../stream.ts\";\nimport * as Message from \"./message.ts\";\nimport type { IetfVersion } from \"./version.ts\";\n\nexport class Fetch {\n\tstatic id = 0x16;\n\n\trequestId: bigint;\n\ttrackNamespace: Path.Valid;\n\ttrackName: string;\n\tsubscriberPriority: number;\n\tgroupOrder: number;\n\tstartGroup: bigint;\n\tstartObject: bigint;\n\tendGroup: bigint;\n\tendObject: bigint;\n\n\tconstructor({\n\t\trequestId,\n\t\ttrackNamespace,\n\t\ttrackName,\n\t\tsubscriberPriority,\n\t\tgroupOrder,\n\t\tstartGroup,\n\t\tstartObject,\n\t\tendGroup,\n\t\tendObject,\n\t}: {\n\t\trequestId: bigint;\n\t\ttrackNamespace: Path.Valid;\n\t\ttrackName: string;\n\t\tsubscriberPriority: number;\n\t\tgroupOrder: number;\n\t\tstartGroup: bigint;\n\t\tstartObject: bigint;\n\t\tendGroup: bigint;\n\t\tendObject: bigint;\n\t}) {\n\t\tthis.requestId = requestId;\n\t\tthis.trackNamespace = trackNamespace;\n\t\tthis.trackName = trackName;\n\t\tthis.subscriberPriority = subscriberPriority;\n\t\tthis.groupOrder = groupOrder;\n\t\tthis.startGroup = startGroup;\n\t\tthis.startObject = startObject;\n\t\tthis.endGroup = endGroup;\n\t\tthis.endObject = endObject;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<Fetch> {\n\t\treturn Message.decode(r, Fetch.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<Fetch> {\n\t\tthrow new Error(\"FETCH messages are not supported\");\n\t}\n}\n\nexport class FetchOk {\n\tstatic id = 0x18;\n\n\trequestId: bigint | undefined;\n\n\tconstructor({ requestId }: { requestId?: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_OK messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchOk> {\n\t\treturn Message.decode(r, FetchOk.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchOk> {\n\t\tthrow new Error(\"FETCH_OK messages are not supported\");\n\t}\n}\n\nexport class FetchError {\n\tstatic id = 0x19;\n\n\trequestId: bigint;\n\terrorCode: number;\n\treasonPhrase: string;\n\n\tconstructor({\n\t\trequestId,\n\t\terrorCode,\n\t\treasonPhrase,\n\t}: { requestId: bigint; errorCode: number; reasonPhrase: string }) {\n\t\tthis.requestId = requestId;\n\t\tthis.errorCode = errorCode;\n\t\tthis.reasonPhrase = reasonPhrase;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_ERROR messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchError> {\n\t\treturn Message.decode(r, FetchError.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchError> {\n\t\tthrow new Error(\"FETCH_ERROR messages are not supported\");\n\t}\n}\n\n// Removed in d17\nexport class FetchCancel {\n\tstatic id = 0x17;\n\n\trequestId: bigint;\n\n\tconstructor({ requestId }: { requestId: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_CANCEL messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchCancel> {\n\t\treturn Message.decode(r, FetchCancel.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchCancel> {\n\t\tthrow new Error(\"FETCH_CANCEL messages are not supported\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/ietf/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC;;;GAGG;AACH,MAAM,OAAO,WAAW;IACvB,qDAAqD;IACrD,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC;IAElB,wEAAwE;IACxE,SAAS,CAAS;IAElB,YAAY,EAAE,SAAS,EAAyB;QAC/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,oEAAoE;IACpE,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,QAAqB;QAC5C,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED,8DAA8D;IAC9D,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,QAAqB;QACnD,OAAO,IAAI,WAAW,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;CACD;AAED,MAAM,OAAO,KAAK;IACjB,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC;IAEjB,SAAS,CAAS;IAClB,cAAc,CAAa;IAC3B,SAAS,CAAS;IAClB,kBAAkB,CAAS;IAC3B,UAAU,CAAS;IACnB,UAAU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AqB;QACnD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAU;QAC9B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC3D,CAAC;CACD;AAED,iBAAiB;AACjB,MAAM,OAAO,WAAW;IACvB,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC;IAEjB,SAAS,CAAS;IAElB,YAAY,EAAE,SAAS,EAAyB;QAC/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACvB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,QAAqB;QAC5C,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,QAAqB;QACnD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAU;QAC9B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import type * as Path from \"../path.ts\";\nimport type { Reader, Writer } from \"../stream.ts\";\nimport * as Message from \"./message.ts\";\nimport type { IetfVersion } from \"./version.ts\";\n\n/**\n * The header that begins a fetch stream (draft-20 section 11.4.4), naming the request it\n * answers. Written by the publisher when serving a subscription's fill.\n */\nexport class FetchHeader {\n\t/** The uni stream type, not a control message id. */\n\tstatic type = 0x5;\n\n\t/** The SUBSCRIBE (or FETCH) request this stream carries objects for. */\n\trequestId: bigint;\n\n\tconstructor({ requestId }: { requestId: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\t/** Write the header, which the stream type must already precede. */\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\tawait w.u62(this.requestId);\n\t}\n\n\t/** Read the header, with the stream type already consumed. */\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchHeader> {\n\t\treturn new FetchHeader({ requestId: await r.u62() });\n\t}\n}\n\nexport class Fetch {\n\tstatic id = 0x16;\n\n\trequestId: bigint;\n\ttrackNamespace: Path.Valid;\n\ttrackName: string;\n\tsubscriberPriority: number;\n\tgroupOrder: number;\n\tstartGroup: bigint;\n\tstartObject: bigint;\n\tendGroup: bigint;\n\tendObject: bigint;\n\n\tconstructor({\n\t\trequestId,\n\t\ttrackNamespace,\n\t\ttrackName,\n\t\tsubscriberPriority,\n\t\tgroupOrder,\n\t\tstartGroup,\n\t\tstartObject,\n\t\tendGroup,\n\t\tendObject,\n\t}: {\n\t\trequestId: bigint;\n\t\ttrackNamespace: Path.Valid;\n\t\ttrackName: string;\n\t\tsubscriberPriority: number;\n\t\tgroupOrder: number;\n\t\tstartGroup: bigint;\n\t\tstartObject: bigint;\n\t\tendGroup: bigint;\n\t\tendObject: bigint;\n\t}) {\n\t\tthis.requestId = requestId;\n\t\tthis.trackNamespace = trackNamespace;\n\t\tthis.trackName = trackName;\n\t\tthis.subscriberPriority = subscriberPriority;\n\t\tthis.groupOrder = groupOrder;\n\t\tthis.startGroup = startGroup;\n\t\tthis.startObject = startObject;\n\t\tthis.endGroup = endGroup;\n\t\tthis.endObject = endObject;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<Fetch> {\n\t\treturn Message.decode(r, Fetch.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<Fetch> {\n\t\tthrow new Error(\"FETCH messages are not supported\");\n\t}\n}\n\nexport class FetchOk {\n\tstatic id = 0x18;\n\n\trequestId: bigint | undefined;\n\n\tconstructor({ requestId }: { requestId?: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_OK messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchOk> {\n\t\treturn Message.decode(r, FetchOk.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchOk> {\n\t\tthrow new Error(\"FETCH_OK messages are not supported\");\n\t}\n}\n\nexport class FetchError {\n\tstatic id = 0x19;\n\n\trequestId: bigint;\n\terrorCode: number;\n\treasonPhrase: string;\n\n\tconstructor({\n\t\trequestId,\n\t\terrorCode,\n\t\treasonPhrase,\n\t}: { requestId: bigint; errorCode: number; reasonPhrase: string }) {\n\t\tthis.requestId = requestId;\n\t\tthis.errorCode = errorCode;\n\t\tthis.reasonPhrase = reasonPhrase;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_ERROR messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchError> {\n\t\treturn Message.decode(r, FetchError.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchError> {\n\t\tthrow new Error(\"FETCH_ERROR messages are not supported\");\n\t}\n}\n\n// Removed in d17\nexport class FetchCancel {\n\tstatic id = 0x17;\n\n\trequestId: bigint;\n\n\tconstructor({ requestId }: { requestId: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_CANCEL messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchCancel> {\n\t\treturn Message.decode(r, FetchCancel.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchCancel> {\n\t\tthrow new Error(\"FETCH_CANCEL messages are not supported\");\n\t}\n}\n"]}
|