@moq/net 0.1.9 → 0.2.1
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/announced.d.ts +40 -24
- package/announced.d.ts.map +1 -1
- package/announced.js +74 -40
- package/announced.js.map +1 -1
- package/announced.test.d.ts +2 -0
- package/announced.test.d.ts.map +1 -0
- package/announced.test.js +37 -0
- package/announced.test.js.map +1 -0
- package/broadcast.d.ts +80 -25
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +266 -49
- package/broadcast.js.map +1 -1
- package/broadcast.test.d.ts +2 -0
- package/broadcast.test.d.ts.map +1 -0
- package/broadcast.test.js +219 -0
- package/broadcast.test.js.map +1 -0
- package/connection/accept.d.ts +6 -0
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +30 -10
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts +5 -0
- package/connection/browser.d.ts.map +1 -0
- package/connection/browser.js +25 -0
- package/connection/browser.js.map +1 -0
- package/connection/browser.test.d.ts +2 -0
- package/connection/browser.test.d.ts.map +1 -0
- package/connection/browser.test.js +29 -0
- package/connection/browser.test.js.map +1 -0
- package/connection/connect.d.ts +43 -1
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +96 -107
- package/connection/connect.js.map +1 -1
- package/connection/connect.test.d.ts +2 -0
- package/connection/connect.test.d.ts.map +1 -0
- package/connection/connect.test.js +118 -0
- package/connection/connect.test.js.map +1 -0
- package/connection/established.d.ts +29 -15
- package/connection/established.d.ts.map +1 -1
- package/connection/established.js.map +1 -1
- package/connection/index.d.ts +8 -0
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +6 -0
- package/connection/index.js.map +1 -1
- package/connection/reload.d.ts +43 -7
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +159 -62
- package/connection/reload.js.map +1 -1
- package/connection/reload.test.js +65 -0
- package/connection/reload.test.js.map +1 -1
- package/connection/stats.d.ts +92 -0
- package/connection/stats.d.ts.map +1 -0
- package/connection/stats.js +35 -0
- package/connection/stats.js.map +1 -0
- package/connection/stats.test.d.ts +2 -0
- package/connection/stats.test.d.ts.map +1 -0
- package/connection/stats.test.js +120 -0
- package/connection/stats.test.js.map +1 -0
- package/connection/transport.d.ts +10 -0
- package/connection/transport.d.ts.map +1 -0
- package/connection/transport.js +12 -0
- package/connection/transport.js.map +1 -0
- package/consume.d.ts +26 -0
- package/consume.d.ts.map +1 -0
- package/consume.js +40 -0
- package/consume.js.map +1 -0
- package/datagram.d.ts +23 -0
- package/datagram.d.ts.map +1 -0
- package/datagram.js +3 -0
- package/datagram.js.map +1 -0
- package/error.d.ts +62 -0
- package/error.d.ts.map +1 -0
- package/error.js +92 -0
- package/error.js.map +1 -0
- package/error.test.d.ts +2 -0
- package/error.test.d.ts.map +1 -0
- package/error.test.js +89 -0
- package/error.test.js.map +1 -0
- package/group.d.ts +125 -36
- package/group.d.ts.map +1 -1
- package/group.js +244 -67
- package/group.js.map +1 -1
- package/group.test.js +121 -35
- package/group.test.js.map +1 -1
- package/ietf/adapter.d.ts +2 -2
- package/ietf/adapter.d.ts.map +1 -1
- package/ietf/adapter.js +15 -5
- package/ietf/adapter.js.map +1 -1
- package/ietf/connection.d.ts +19 -6
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +23 -8
- package/ietf/connection.js.map +1 -1
- package/ietf/ietf.test.js +58 -1
- package/ietf/ietf.test.js.map +1 -1
- package/ietf/object.d.ts +12 -4
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +92 -9
- package/ietf/object.js.map +1 -1
- package/ietf/publisher.d.ts +2 -2
- package/ietf/publisher.d.ts.map +1 -1
- package/ietf/publisher.js +12 -12
- package/ietf/publisher.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +0 -4
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +0 -5
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.d.ts +8 -4
- package/ietf/subscriber.d.ts.map +1 -1
- package/ietf/subscriber.js +171 -93
- package/ietf/subscriber.js.map +1 -1
- package/index.d.ts +10 -5
- package/index.d.ts.map +1 -1
- package/index.js +10 -5
- package/index.js.map +1 -1
- package/integration.test.js +634 -12
- package/integration.test.js.map +1 -1
- package/internal.d.ts +14 -0
- package/internal.d.ts.map +1 -0
- package/internal.js +8 -0
- package/internal.js.map +1 -0
- package/lite/announce.d.ts +55 -13
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +221 -68
- package/lite/announce.js.map +1 -1
- package/lite/announce.test.d.ts +2 -0
- package/lite/announce.test.d.ts.map +1 -0
- package/lite/announce.test.js +71 -0
- package/lite/announce.test.js.map +1 -0
- package/lite/connection.d.ts +45 -19
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +85 -80
- package/lite/connection.js.map +1 -1
- package/lite/datagram.d.ts +23 -0
- package/lite/datagram.d.ts.map +1 -0
- package/lite/datagram.js +57 -0
- package/lite/datagram.js.map +1 -0
- package/lite/datagram.test.d.ts +2 -0
- package/lite/datagram.test.d.ts.map +1 -0
- package/lite/datagram.test.js +26 -0
- package/lite/datagram.test.js.map +1 -0
- package/lite/datagram_stream.d.ts +8 -0
- package/lite/datagram_stream.d.ts.map +1 -0
- package/lite/datagram_stream.js +44 -0
- package/lite/datagram_stream.js.map +1 -0
- package/lite/datagram_stream.test.d.ts +2 -0
- package/lite/datagram_stream.test.d.ts.map +1 -0
- package/lite/datagram_stream.test.js +15 -0
- package/lite/datagram_stream.test.js.map +1 -0
- package/lite/fetch.d.ts.map +1 -1
- package/lite/fetch.js +2 -2
- package/lite/fetch.js.map +1 -1
- package/lite/fetch.test.d.ts +2 -0
- package/lite/fetch.test.d.ts.map +1 -0
- package/lite/fetch.test.js +41 -0
- package/lite/fetch.test.js.map +1 -0
- package/lite/index.d.ts +3 -0
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +3 -0
- package/lite/index.js.map +1 -1
- package/lite/publisher.d.ts +13 -6
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +274 -64
- package/lite/publisher.js.map +1 -1
- package/lite/publisher.test.d.ts +2 -0
- package/lite/publisher.test.d.ts.map +1 -0
- package/lite/publisher.test.js +65 -0
- package/lite/publisher.test.js.map +1 -0
- package/lite/setup.d.ts +72 -6
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +184 -31
- package/lite/setup.js.map +1 -1
- package/lite/setup.test.d.ts +2 -0
- package/lite/setup.test.d.ts.map +1 -0
- package/lite/setup.test.js +122 -0
- package/lite/setup.test.js.map +1 -0
- package/lite/stream.d.ts +12 -3
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +7 -4
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +37 -23
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +70 -55
- package/lite/subscribe.js.map +1 -1
- package/lite/subscribe.test.d.ts +2 -0
- package/lite/subscribe.test.d.ts.map +1 -0
- package/lite/subscribe.test.js +68 -0
- package/lite/subscribe.test.js.map +1 -0
- package/lite/subscriber.d.ts +24 -17
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +515 -90
- package/lite/subscriber.js.map +1 -1
- package/lite/subscriber.test.js +2 -2
- package/lite/subscriber.test.js.map +1 -1
- package/lite/track.d.ts +25 -13
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +60 -35
- package/lite/track.js.map +1 -1
- package/lite/track.test.js +12 -10
- package/lite/track.test.js.map +1 -1
- package/lite/version.d.ts +17 -4
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +88 -17
- package/lite/version.js.map +1 -1
- package/mock.d.ts +42 -3
- package/mock.d.ts.map +1 -1
- package/mock.js +88 -17
- package/mock.js.map +1 -1
- package/package.json +3 -3
- package/path.d.ts +30 -0
- package/path.d.ts.map +1 -1
- package/path.js +49 -0
- package/path.js.map +1 -1
- package/path.test.js +41 -0
- package/path.test.js.map +1 -1
- package/stream.d.ts.map +1 -1
- package/stream.js +25 -4
- package/stream.js.map +1 -1
- package/stream.test.js +42 -0
- package/stream.test.js.map +1 -1
- package/time.d.ts +109 -86
- package/time.d.ts.map +1 -1
- package/time.js +80 -30
- package/time.js.map +1 -1
- package/time.test.d.ts +2 -0
- package/time.test.d.ts.map +1 -0
- package/time.test.js +12 -0
- package/time.test.js.map +1 -0
- package/track.d.ts +225 -45
- package/track.d.ts.map +1 -1
- package/track.js +505 -93
- package/track.js.map +1 -1
- package/track.test.js +138 -29
- package/track.test.js.map +1 -1
- package/util/timeout.d.ts +5 -0
- package/util/timeout.d.ts.map +1 -0
- package/util/timeout.js +18 -0
- package/util/timeout.js.map +1 -0
- package/util/timeout.test.d.ts +2 -0
- package/util/timeout.test.d.ts.map +1 -0
- package/util/timeout.test.js +18 -0
- package/util/timeout.test.js.map +1 -0
- package/varint.d.ts +6 -0
- package/varint.d.ts.map +1 -1
- package/varint.js +6 -2
- package/varint.js.map +1 -1
- package/zod.d.ts +4 -4
- package/zod.d.ts.map +1 -1
- package/zod.js.map +1 -1
- package/bandwidth.d.ts +0 -11
- package/bandwidth.d.ts.map +0 -1
- package/bandwidth.js +0 -7
- package/bandwidth.js.map +0 -1
- package/util/error.d.ts +0 -3
- package/util/error.d.ts.map +0 -1
- package/util/error.js +0 -9
- package/util/error.js.map +0 -1
- package/util/index.d.ts +0 -2
- package/util/index.d.ts.map +0 -1
- package/util/index.js +0 -3
- package/util/index.js.map +0 -1
package/lite/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/lite/setup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,cAAc,EAAgB,MAAM,cAAc,CAAC;AAE5D,kFAAkF;AAClF,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,OAAO,KAAK;IACjB,4EAA4E;IAC5E,IAAI,C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AAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,OAAgB;QACvC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC7E,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,OAAgB;QAC9C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC7E,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;CACD","sourcesContent":["import type { Reader, Writer } from \"../stream.ts\";\nimport * as Message from \"./message.ts\";\nimport { hasSetupStream, type Version } from \"./version.ts\";\n\n/// Setup parameter ID for the request Path (client-only, on URI-less transports).\nconst PARAM_PATH = 0x2;\n\n/**\n * The moq-lite-05 SETUP message, sent once per endpoint on a unidirectional Setup stream.\n *\n * The browser conveys its path via the WebTransport URL, so it never sends a Path\n * parameter; this class still parses one for completeness when reading a peer's SETUP.\n */\nexport class Setup {\n\t/// The request path, only sent on transport bindings without a request URI.\n\tpath?: string;\n\n\tconstructor(props: { path?: string } = {}) {\n\t\tthis.path = props.path;\n\t}\n\n\tasync #encode(w: Writer) {\n\t\tif (this.path !== undefined) {\n\t\t\tawait w.u53(1); // parameter count\n\t\t\tconst value = new TextEncoder().encode(this.path);\n\t\t\tawait w.u53(PARAM_PATH);\n\t\t\tawait w.u53(value.byteLength);\n\t\t\tawait w.write(value);\n\t\t} else {\n\t\t\tawait w.u53(0); // no parameters\n\t\t}\n\t}\n\n\tstatic async #decode(r: Reader): Promise<Setup> {\n\t\tconst count = await r.u53();\n\t\tlet path: string | undefined;\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tconst id = await r.u53();\n\t\t\tconst len = await r.u53();\n\t\t\tconst value = await r.read(len);\n\t\t\t// Unknown parameters are ignored so new ones stay backward compatible.\n\t\t\tif (id === PARAM_PATH) {\n\t\t\t\tpath = new TextDecoder().decode(value);\n\t\t\t}\n\t\t}\n\t\treturn new Setup({ path });\n\t}\n\n\tasync encode(w: Writer, version: Version): Promise<void> {\n\t\tif (!hasSetupStream(version)) throw new Error(\"SETUP requires moq-lite-05+\");\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, version: Version): Promise<Setup> {\n\t\tif (!hasSetupStream(version)) throw new Error(\"SETUP requires moq-lite-05+\");\n\t\treturn Message.decode(r, Setup.#decode);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/lite/setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,cAAc,EAAgB,MAAM,cAAc,CAAC;AAE5D,yDAAyD;AACzD,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,kFAAkF;AAClF,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,+EAA+E;AAC/E,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,2EAA2E;AAC3E,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,wDAAwD;IACxD,IAAI,EAAE,CAAC;IACP,+EAA+E;IAC/E,MAAM,EAAE,CAAC;IACT,kFAAkF;IAClF,QAAQ,EAAE,CAAC;CACF,CAAC;AAKX,6FAA6F;AAC7F,SAAS,aAAa,CAAC,IAAY;IAClC,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,EAAE;Y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AAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,OAAgB;QACvC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,mFAAmF;IACnF,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,OAAgB;QAC9C,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;CACD","sourcesContent":["/**\n * The lite-05 SETUP message: each endpoint advertises its capabilities once, as the\n * sole message on a unidirectional Setup Stream ({@link DataType.Setup}), then closes it.\n *\n * @module\n */\n\nimport type { Reader, Writer } from \"../stream.ts\";\nimport * as Varint from \"../varint.ts\";\nimport * as Message from \"./message.ts\";\nimport { hasSetupStream, type Version } from \"./version.ts\";\n\n/** Setup Parameter id for the Probe capability level. */\nconst PARAM_PROBE = 0x1n;\n/** Setup Parameter id for the request Path (client-only, URI-less transports). */\nconst PARAM_PATH = 0x2n;\n/** Setup Parameter id for the client's intended {@link Role} (client-only). */\nconst PARAM_ROLE = 0x3n;\n\n/** Cap on the number of parameters in a bag, matching the Rust decoder. */\nconst MAX_PARAMS = 64;\n\n/**\n * The probe capability an endpoint advertises in SETUP.\n *\n * Monotonic: a higher level implies every lower one. An unknown (future) value\n * decodes as the highest level we understand, so a peer that gains a new level is\n * treated as at least {@link ProbeLevel.Increase}.\n */\nexport const ProbeLevel = {\n\t/** No probing. Equivalent to omitting the parameter. */\n\tNone: 0,\n\t/** The publisher can measure and periodically report its estimated bitrate. */\n\tReport: 1,\n\t/** The publisher can additionally pad the connection (or send redundant data). */\n\tIncrease: 2,\n} as const;\n\n/** A probe capability level. See {@link ProbeLevel}. */\nexport type ProbeLevel = (typeof ProbeLevel)[keyof typeof ProbeLevel];\n\n/** Map a wire value to a level, saturating unknown values to {@link ProbeLevel.Increase}. */\nfunction probeFromCode(code: bigint): ProbeLevel {\n\tswitch (code) {\n\t\tcase 0n:\n\t\t\treturn ProbeLevel.None;\n\t\tcase 1n:\n\t\t\treturn ProbeLevel.Report;\n\t\tdefault:\n\t\t\treturn ProbeLevel.Increase;\n\t}\n}\n\n/**\n * The direction a client intends to use the session for.\n *\n * A client advertises this in its SETUP so the server can reject a token that lacks the\n * matching scope during the handshake, instead of accepting a session that then silently\n * carries no media (a subscribe-only token used to publish, or vice versa). It only ever\n * narrows what the server grants, so it is not a security boundary: the server still\n * enforces the token's scope regardless.\n */\nexport const Role = {\n\t/** The client may do either, or declined to say. Equivalent to omitting the parameter. */\n\tBoth: 0,\n\t/** The client will publish tracks (ingest); the server must consume. */\n\tPublisher: 1,\n\t/** The client will subscribe to tracks (egress); the server must publish. */\n\tSubscriber: 2,\n} as const;\n\n/** A session role. See {@link Role}. */\nexport type Role = (typeof Role)[keyof typeof Role];\n\n/**\n * Map a wire value to a role, falling back to {@link Role.Both}.\n *\n * The draft requires a receiver that does not recognize the value to treat it as `Both`,\n * so a newer client can't break an older server: it just loses the early reject and defers\n * to the token's scope.\n */\nfunction roleFromCode(code: bigint): Role {\n\tswitch (code) {\n\t\tcase 1n:\n\t\t\treturn Role.Publisher;\n\t\tcase 2n:\n\t\t\treturn Role.Subscriber;\n\t\tdefault:\n\t\t\treturn Role.Both;\n\t}\n}\n\n/**\n * A bag of `id -> raw bytes` parameters, the body shared by SETUP. Encoded as a varint\n * count followed by `id, length, value` triples; duplicate ids are rejected on decode.\n */\nclass Parameters {\n\t#entries = new Map<bigint, Uint8Array>();\n\n\t/** Set a parameter to a raw byte value, replacing any existing entry. */\n\tsetBytes(id: bigint, value: Uint8Array) {\n\t\tthis.#entries.set(id, value);\n\t}\n\n\t/** Return a parameter's raw byte value, if present. */\n\tgetBytes(id: bigint): Uint8Array | undefined {\n\t\treturn this.#entries.get(id);\n\t}\n\n\t/** Set a parameter to a varint value, replacing any existing entry. */\n\tsetVarint(id: bigint, value: number | bigint) {\n\t\tthis.#entries.set(id, Varint.encode(Number(value)));\n\t}\n\n\t/** Decode a parameter as a single varint, if present. Throws if trailing bytes remain. */\n\tgetVarint(id: bigint): bigint | undefined {\n\t\tconst bytes = this.#entries.get(id);\n\t\tif (bytes === undefined) return undefined;\n\t\tconst [value, remain] = Varint.decode(bytes);\n\t\tif (remain.byteLength !== 0) {\n\t\t\tthrow new Error(\"trailing bytes after varint parameter\");\n\t\t}\n\t\treturn BigInt(value);\n\t}\n\n\tasync encode(w: Writer) {\n\t\tif (this.#entries.size > MAX_PARAMS) {\n\t\t\tthrow new Error(\"too many parameters\");\n\t\t}\n\n\t\tawait w.u53(this.#entries.size);\n\t\tfor (const [id, value] of this.#entries) {\n\t\t\tawait w.u62(id);\n\t\t\tawait w.u53(value.byteLength);\n\t\t\tawait w.write(value);\n\t\t}\n\t}\n\n\tstatic async decode(r: Reader): Promise<Parameters> {\n\t\tconst params = new Parameters();\n\n\t\tconst count = await r.u53();\n\t\tif (count > MAX_PARAMS) {\n\t\t\tthrow new Error(\"too many parameters\");\n\t\t}\n\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tconst id = await r.u62();\n\t\t\tif (params.#entries.has(id)) {\n\t\t\t\tthrow new Error(`duplicate parameter id: ${id.toString()}`);\n\t\t\t}\n\t\t\tconst size = await r.u53();\n\t\t\tconst value = await r.read(size);\n\t\t\tparams.#entries.set(id, value);\n\t\t}\n\n\t\treturn params;\n\t}\n}\n\n/** The capabilities a {@link Setup} advertises. Each defaults to the wire default, which is the absence of the parameter. */\nexport interface SetupProps {\n\t/** See {@link Setup.probe}. Defaults to {@link ProbeLevel.None}. */\n\tprobe?: ProbeLevel;\n\t/** See {@link Setup.path}. Omitted by default. */\n\tpath?: string;\n\t/** See {@link Setup.role}. Defaults to {@link Role.Both}. */\n\trole?: Role;\n}\n\n/**\n * The SETUP message, sent once per endpoint on the unidirectional Setup Stream.\n *\n * lite-05+ only. The two endpoints' SETUP messages are independent: neither side\n * blocks on the peer's before opening other streams, but a stream whose encoding\n * depends on a negotiated capability (e.g. PROBE) must wait for it.\n */\nexport class Setup {\n\t/** The probe capability this endpoint supports. {@link ProbeLevel.None} when absent. */\n\tprobe: ProbeLevel;\n\n\t/**\n\t * The request path, for transports that carry no request URI (native QUIC, qmux over\n\t * TCP/TLS, unix sockets). Sent only by the client; a server never sends one and a relay\n\t * never forwards it. `undefined` on URI-carrying bindings such as WebTransport, where\n\t * sending one is a protocol violation. An empty string means the same as `undefined`.\n\t */\n\tpath?: string;\n\n\t/**\n\t * The client's intended {@link Role}. `Both` is sent as the absence of the parameter, so\n\t * a client that never sets it decodes back to `Both`. Sent only by the client; a server\n\t * never sends one and a relay never forwards it.\n\t */\n\trole: Role;\n\n\tconstructor({ probe, path, role }: SetupProps = {}) {\n\t\tthis.probe = probe ?? ProbeLevel.None;\n\t\tthis.path = path;\n\t\tthis.role = role ?? Role.Both;\n\t}\n\n\tstatic #guard(version: Version) {\n\t\tif (!hasSetupStream(version)) {\n\t\t\tthrow new Error(\"setup stream not supported for this version\");\n\t\t}\n\t}\n\n\tasync #encode(w: Writer) {\n\t\tconst params = new Parameters();\n\t\t// None is the wire default, so omit it to keep the message empty when nothing is set.\n\t\tif (this.probe !== ProbeLevel.None) {\n\t\t\tparams.setVarint(PARAM_PROBE, this.probe);\n\t\t}\n\t\tif (this.path !== undefined) {\n\t\t\tparams.setBytes(PARAM_PATH, new TextEncoder().encode(this.path));\n\t\t}\n\t\t// Both is the wire default, sent as the absence of the parameter.\n\t\tif (this.role !== Role.Both) {\n\t\t\tparams.setVarint(PARAM_ROLE, this.role);\n\t\t}\n\t\tawait params.encode(w);\n\t}\n\n\tstatic async #decode(r: Reader): Promise<Setup> {\n\t\tconst params = await Parameters.decode(r);\n\n\t\tconst probeCode = params.getVarint(PARAM_PROBE);\n\t\tconst probe = probeCode === undefined ? ProbeLevel.None : probeFromCode(probeCode);\n\n\t\t// An empty path is valid and means the same as omitting the parameter, so a\n\t\t// client that wants the root doesn't have to special-case it.\n\t\tconst pathBytes = params.getBytes(PARAM_PATH);\n\t\tconst path = pathBytes === undefined ? undefined : new TextDecoder().decode(pathBytes);\n\n\t\tconst roleCode = params.getVarint(PARAM_ROLE);\n\t\tconst role = roleCode === undefined ? Role.Both : roleFromCode(roleCode);\n\n\t\treturn new Setup({ probe, path, role });\n\t}\n\n\t/** Encode the SETUP message with its size prefix. Throws on pre-lite-05 versions. */\n\tasync encode(w: Writer, version: Version): Promise<void> {\n\t\tSetup.#guard(version);\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\t/** Decode a SETUP message with its size prefix. Throws on pre-lite-05 versions. */\n\tstatic async decode(r: Reader, version: Version): Promise<Setup> {\n\t\tSetup.#guard(version);\n\t\treturn Message.decode(r, Setup.#decode);\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.test.d.ts","sourceRoot":"","sources":["../../src/lite/setup.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* @ts-self-types="./setup.test.d.ts" */
|
|
2
|
+
import { expect, test } from "bun:test";
|
|
3
|
+
import { Reader, Writer } from "../stream.js";
|
|
4
|
+
import * as Varint from "../varint.js";
|
|
5
|
+
import { ProbeLevel, Role, Setup } from "./setup.js";
|
|
6
|
+
import { Version } from "./version.js";
|
|
7
|
+
// Parameter ids, duplicated from setup.ts so a typo there fails a test rather than
|
|
8
|
+
// silently agreeing with itself.
|
|
9
|
+
const PARAM_PROBE = 0x1n;
|
|
10
|
+
const PARAM_PATH = 0x2n;
|
|
11
|
+
const PARAM_ROLE = 0x3n;
|
|
12
|
+
function concat(chunks) {
|
|
13
|
+
const total = chunks.reduce((sum, c) => sum + c.byteLength, 0);
|
|
14
|
+
const out = new Uint8Array(total);
|
|
15
|
+
let offset = 0;
|
|
16
|
+
for (const c of chunks) {
|
|
17
|
+
out.set(c, offset);
|
|
18
|
+
offset += c.byteLength;
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
async function bytes(f) {
|
|
23
|
+
const written = [];
|
|
24
|
+
const writer = new Writer(new WritableStream({ write: (chunk) => void written.push(new Uint8Array(chunk)) }));
|
|
25
|
+
await f(writer);
|
|
26
|
+
writer.close();
|
|
27
|
+
await writer.closed;
|
|
28
|
+
return concat(written);
|
|
29
|
+
}
|
|
30
|
+
async function roundTrip(msg) {
|
|
31
|
+
const reader = new Reader(undefined, await bytes((w) => msg.encode(w, Version.DRAFT_05)));
|
|
32
|
+
const got = await Setup.decode(reader, Version.DRAFT_05);
|
|
33
|
+
expect(await reader.done()).toBe(true);
|
|
34
|
+
return got;
|
|
35
|
+
}
|
|
36
|
+
// Hand-frame a SETUP carrying a single raw parameter, so we can feed the decoder values
|
|
37
|
+
// our own encoder would never produce (unknown levels, empty paths).
|
|
38
|
+
async function decodeParam(id, value) {
|
|
39
|
+
const body = await bytes(async (w) => {
|
|
40
|
+
await w.u53(1); // parameter count
|
|
41
|
+
await w.u62(id);
|
|
42
|
+
await w.u53(value.byteLength);
|
|
43
|
+
if (value.byteLength > 0)
|
|
44
|
+
await w.write(value);
|
|
45
|
+
});
|
|
46
|
+
const framed = await bytes(async (w) => {
|
|
47
|
+
await w.u53(body.byteLength); // Message size prefix
|
|
48
|
+
await w.write(body);
|
|
49
|
+
});
|
|
50
|
+
return await Setup.decode(new Reader(undefined, framed), Version.DRAFT_05);
|
|
51
|
+
}
|
|
52
|
+
test("empty SETUP round-trips on draft-05", async () => {
|
|
53
|
+
const got = await roundTrip(new Setup());
|
|
54
|
+
expect(got.probe).toBe(ProbeLevel.None);
|
|
55
|
+
expect(got.path).toBeUndefined();
|
|
56
|
+
expect(got.role).toBe(Role.Both);
|
|
57
|
+
});
|
|
58
|
+
test("each probe level round-trips on draft-05", async () => {
|
|
59
|
+
for (const probe of [ProbeLevel.None, ProbeLevel.Report, ProbeLevel.Increase]) {
|
|
60
|
+
const got = await roundTrip(new Setup({ probe }));
|
|
61
|
+
expect(got.probe).toBe(probe);
|
|
62
|
+
expect(got.path).toBeUndefined();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
test("SETUP with path round-trips on draft-05", async () => {
|
|
66
|
+
const got = await roundTrip(new Setup({ probe: ProbeLevel.Report, path: "/room/123" }));
|
|
67
|
+
expect(got.probe).toBe(ProbeLevel.Report);
|
|
68
|
+
expect(got.path).toBe("/room/123");
|
|
69
|
+
});
|
|
70
|
+
test("each role round-trips on draft-05", async () => {
|
|
71
|
+
for (const role of [Role.Both, Role.Publisher, Role.Subscriber]) {
|
|
72
|
+
const got = await roundTrip(new Setup({ role }));
|
|
73
|
+
expect(got.role).toBe(role);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
test("SETUP carries role alongside probe and path", async () => {
|
|
77
|
+
const got = await roundTrip(new Setup({ probe: ProbeLevel.Increase, path: "/room/123", role: Role.Publisher }));
|
|
78
|
+
expect(got.probe).toBe(ProbeLevel.Increase);
|
|
79
|
+
expect(got.path).toBe("/room/123");
|
|
80
|
+
expect(got.role).toBe(Role.Publisher);
|
|
81
|
+
});
|
|
82
|
+
test("Both is the wire default, so it is omitted rather than encoded", async () => {
|
|
83
|
+
// Both must be the absence of the parameter, so a server that predates it decodes a
|
|
84
|
+
// Both client back to Both. Assert the empty bag directly: comparing against another
|
|
85
|
+
// default-constructed Setup would agree with itself even if we encoded Both.
|
|
86
|
+
const both = await bytes((w) => new Setup({ role: Role.Both }).encode(w, Version.DRAFT_05));
|
|
87
|
+
const emptyBag = await bytes(async (w) => {
|
|
88
|
+
await w.u53(1); // Message size prefix: one byte of body follows
|
|
89
|
+
await w.u53(0); // parameter count
|
|
90
|
+
});
|
|
91
|
+
expect(both).toEqual(emptyBag);
|
|
92
|
+
// A directional role is still encoded, so the check above can actually fail.
|
|
93
|
+
const publisher = await bytes((w) => new Setup({ role: Role.Publisher }).encode(w, Version.DRAFT_05));
|
|
94
|
+
expect(publisher.byteLength).toBeGreaterThan(both.byteLength);
|
|
95
|
+
});
|
|
96
|
+
test("unknown role falls back to Both", async () => {
|
|
97
|
+
// Hand-frame a SETUP carrying an unrecognized role (99). The draft requires a receiver
|
|
98
|
+
// that doesn't know the value to treat it as Both, so a newer client can't break us.
|
|
99
|
+
const got = await decodeParam(PARAM_ROLE, Varint.encode(99));
|
|
100
|
+
expect(got.role).toBe(Role.Both);
|
|
101
|
+
});
|
|
102
|
+
test("role 0 decodes as Both", async () => {
|
|
103
|
+
const got = await decodeParam(PARAM_ROLE, Varint.encode(0));
|
|
104
|
+
expect(got.role).toBe(Role.Both);
|
|
105
|
+
});
|
|
106
|
+
test("unknown probe level saturates to Increase", async () => {
|
|
107
|
+
const got = await decodeParam(PARAM_PROBE, Varint.encode(99));
|
|
108
|
+
expect(got.probe).toBe(ProbeLevel.Increase);
|
|
109
|
+
});
|
|
110
|
+
test("SETUP is rejected before draft-05", async () => {
|
|
111
|
+
await expect(bytes((w) => new Setup().encode(w, Version.DRAFT_04))).rejects.toThrow();
|
|
112
|
+
});
|
|
113
|
+
test("SETUP decode is rejected before draft-05", async () => {
|
|
114
|
+
const framed = await bytes((w) => new Setup().encode(w, Version.DRAFT_05));
|
|
115
|
+
await expect(Setup.decode(new Reader(undefined, framed), Version.DRAFT_04)).rejects.toThrow();
|
|
116
|
+
});
|
|
117
|
+
test("empty path decodes as the root", async () => {
|
|
118
|
+
// Valid on the wire and equivalent to omitting the parameter.
|
|
119
|
+
const got = await decodeParam(PARAM_PATH, new Uint8Array());
|
|
120
|
+
expect(got.path).toBe("");
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=setup.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.test.js","sourceRoot":"","sources":["../../src/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CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"bun:test\";\nimport { Reader, Writer } from \"../stream.ts\";\nimport * as Varint from \"../varint.ts\";\nimport { ProbeLevel, Role, Setup } from \"./setup.ts\";\nimport { Version } from \"./version.ts\";\n\n// Parameter ids, duplicated from setup.ts so a typo there fails a test rather than\n// silently agreeing with itself.\nconst PARAM_PROBE = 0x1n;\nconst PARAM_PATH = 0x2n;\nconst PARAM_ROLE = 0x3n;\n\nfunction concat(chunks: Uint8Array[]): Uint8Array {\n\tconst total = chunks.reduce((sum, c) => sum + c.byteLength, 0);\n\tconst out = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const c of chunks) {\n\t\tout.set(c, offset);\n\t\toffset += c.byteLength;\n\t}\n\treturn out;\n}\n\nasync function bytes(f: (w: Writer) => Promise<void>): Promise<Uint8Array> {\n\tconst written: Uint8Array[] = [];\n\tconst writer = new Writer(\n\t\tnew WritableStream<Uint8Array>({ write: (chunk) => void written.push(new Uint8Array(chunk)) }),\n\t);\n\tawait f(writer);\n\twriter.close();\n\tawait writer.closed;\n\treturn concat(written);\n}\n\nasync function roundTrip(msg: Setup): Promise<Setup> {\n\tconst reader = new Reader(undefined, await bytes((w) => msg.encode(w, Version.DRAFT_05)));\n\tconst got = await Setup.decode(reader, Version.DRAFT_05);\n\texpect(await reader.done()).toBe(true);\n\treturn got;\n}\n\n// Hand-frame a SETUP carrying a single raw parameter, so we can feed the decoder values\n// our own encoder would never produce (unknown levels, empty paths).\nasync function decodeParam(id: bigint, value: Uint8Array): Promise<Setup> {\n\tconst body = await bytes(async (w) => {\n\t\tawait w.u53(1); // parameter count\n\t\tawait w.u62(id);\n\t\tawait w.u53(value.byteLength);\n\t\tif (value.byteLength > 0) await w.write(value);\n\t});\n\n\tconst framed = await bytes(async (w) => {\n\t\tawait w.u53(body.byteLength); // Message size prefix\n\t\tawait w.write(body);\n\t});\n\n\treturn await Setup.decode(new Reader(undefined, framed), Version.DRAFT_05);\n}\n\ntest(\"empty SETUP round-trips on draft-05\", async () => {\n\tconst got = await roundTrip(new Setup());\n\texpect(got.probe).toBe(ProbeLevel.None);\n\texpect(got.path).toBeUndefined();\n\texpect(got.role).toBe(Role.Both);\n});\n\ntest(\"each probe level round-trips on draft-05\", async () => {\n\tfor (const probe of [ProbeLevel.None, ProbeLevel.Report, ProbeLevel.Increase]) {\n\t\tconst got = await roundTrip(new Setup({ probe }));\n\t\texpect(got.probe).toBe(probe);\n\t\texpect(got.path).toBeUndefined();\n\t}\n});\n\ntest(\"SETUP with path round-trips on draft-05\", async () => {\n\tconst got = await roundTrip(new Setup({ probe: ProbeLevel.Report, path: \"/room/123\" }));\n\texpect(got.probe).toBe(ProbeLevel.Report);\n\texpect(got.path).toBe(\"/room/123\");\n});\n\ntest(\"each role round-trips on draft-05\", async () => {\n\tfor (const role of [Role.Both, Role.Publisher, Role.Subscriber]) {\n\t\tconst got = await roundTrip(new Setup({ role }));\n\t\texpect(got.role).toBe(role);\n\t}\n});\n\ntest(\"SETUP carries role alongside probe and path\", async () => {\n\tconst got = await roundTrip(new Setup({ probe: ProbeLevel.Increase, path: \"/room/123\", role: Role.Publisher }));\n\texpect(got.probe).toBe(ProbeLevel.Increase);\n\texpect(got.path).toBe(\"/room/123\");\n\texpect(got.role).toBe(Role.Publisher);\n});\n\ntest(\"Both is the wire default, so it is omitted rather than encoded\", async () => {\n\t// Both must be the absence of the parameter, so a server that predates it decodes a\n\t// Both client back to Both. Assert the empty bag directly: comparing against another\n\t// default-constructed Setup would agree with itself even if we encoded Both.\n\tconst both = await bytes((w) => new Setup({ role: Role.Both }).encode(w, Version.DRAFT_05));\n\tconst emptyBag = await bytes(async (w) => {\n\t\tawait w.u53(1); // Message size prefix: one byte of body follows\n\t\tawait w.u53(0); // parameter count\n\t});\n\texpect(both).toEqual(emptyBag);\n\n\t// A directional role is still encoded, so the check above can actually fail.\n\tconst publisher = await bytes((w) => new Setup({ role: Role.Publisher }).encode(w, Version.DRAFT_05));\n\texpect(publisher.byteLength).toBeGreaterThan(both.byteLength);\n});\n\ntest(\"unknown role falls back to Both\", async () => {\n\t// Hand-frame a SETUP carrying an unrecognized role (99). The draft requires a receiver\n\t// that doesn't know the value to treat it as Both, so a newer client can't break us.\n\tconst got = await decodeParam(PARAM_ROLE, Varint.encode(99));\n\texpect(got.role).toBe(Role.Both);\n});\n\ntest(\"role 0 decodes as Both\", async () => {\n\tconst got = await decodeParam(PARAM_ROLE, Varint.encode(0));\n\texpect(got.role).toBe(Role.Both);\n});\n\ntest(\"unknown probe level saturates to Increase\", async () => {\n\tconst got = await decodeParam(PARAM_PROBE, Varint.encode(99));\n\texpect(got.probe).toBe(ProbeLevel.Increase);\n});\n\ntest(\"SETUP is rejected before draft-05\", async () => {\n\tawait expect(bytes((w) => new Setup().encode(w, Version.DRAFT_04))).rejects.toThrow();\n});\n\ntest(\"SETUP decode is rejected before draft-05\", async () => {\n\tconst framed = await bytes((w) => new Setup().encode(w, Version.DRAFT_05));\n\tawait expect(Setup.decode(new Reader(undefined, framed), Version.DRAFT_04)).rejects.toThrow();\n});\n\ntest(\"empty path decodes as the root\", async () => {\n\t// Valid on the wire and equivalent to omitting the parameter.\n\tconst got = await decodeParam(PARAM_PATH, new Uint8Array());\n\texpect(got.path).toBe(\"\");\n});\n"]}
|
package/lite/stream.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnounceRequest } from "./announce";
|
|
2
2
|
import type { Goaway } from "./goaway";
|
|
3
3
|
import type { Group } from "./group";
|
|
4
4
|
import type { SessionClient } from "./session";
|
|
5
5
|
import type { Subscribe } from "./subscribe";
|
|
6
|
-
|
|
6
|
+
import type { Track } from "./track";
|
|
7
|
+
export type StreamBi = SessionClient | AnnounceRequest | Subscribe | Track | Goaway;
|
|
7
8
|
export type StreamUni = Group;
|
|
8
9
|
export declare const StreamId: {
|
|
9
10
|
readonly Session: 0;
|
|
@@ -16,8 +17,16 @@ export declare const StreamId: {
|
|
|
16
17
|
readonly ClientCompat: 32;
|
|
17
18
|
readonly ServerCompat: 33;
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The varint type prefix on a unidirectional data stream.
|
|
22
|
+
*
|
|
23
|
+
* `Group` is the per-group frame stream. `Setup` (lite-05+) carries the single SETUP
|
|
24
|
+
* message advertising this endpoint's capabilities.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DataType: {
|
|
20
27
|
readonly Group: 0;
|
|
21
28
|
readonly Setup: 1;
|
|
22
29
|
};
|
|
30
|
+
/** A unidirectional data-stream type. See {@link DataType}. */
|
|
31
|
+
export type DataType = (typeof DataType)[keyof typeof DataType];
|
|
23
32
|
//# sourceMappingURL=stream.d.ts.map
|
package/lite/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/lite/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/lite/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,eAAe,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AACpF,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC;AAE9B,eAAO,MAAM,QAAQ;aACpB,OAAO,EAAE,CAAC;aACV,QAAQ,EAAE,CAAC;aACX,SAAS,EAAE,CAAC;aACZ,KAAK,EAAE,CAAC;aACR,KAAK,EAAE,CAAC;aACR,MAAM,EAAE,CAAC;aACT,KAAK,EAAE,CAAC;aACR,YAAY,EAAE,EAAI;aAClB,YAAY,EAAE,EAAI;CACT,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;aACpB,KAAK,EAAE,CAAC;aACR,KAAK,EAAE,CAAC;CACC,CAAC;AAEX,+DAA+D;AAC/D,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC"}
|
package/lite/stream.js
CHANGED
|
@@ -6,15 +6,18 @@ export const StreamId = {
|
|
|
6
6
|
Fetch: 3,
|
|
7
7
|
Probe: 4,
|
|
8
8
|
Goaway: 5,
|
|
9
|
-
/// Queries a track's immutable publisher properties via TRACK/TRACK_INFO (moq-lite-05+).
|
|
10
9
|
Track: 6,
|
|
11
10
|
ClientCompat: 0x20,
|
|
12
11
|
ServerCompat: 0x21,
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The varint type prefix on a unidirectional data stream.
|
|
15
|
+
*
|
|
16
|
+
* `Group` is the per-group frame stream. `Setup` (lite-05+) carries the single SETUP
|
|
17
|
+
* message advertising this endpoint's capabilities.
|
|
18
|
+
*/
|
|
19
|
+
export const DataType = {
|
|
16
20
|
Group: 0,
|
|
17
|
-
/// Carries a single SETUP message (moq-lite-05+).
|
|
18
21
|
Setup: 1,
|
|
19
22
|
};
|
|
20
23
|
//# sourceMappingURL=stream.js.map
|
package/lite/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/lite/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/lite/stream.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,CAAC;IACZ,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;IACR,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,IAAI;CACT,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;CACC,CAAC","sourcesContent":["import type { AnnounceRequest } from \"./announce.ts\";\nimport type { Goaway } from \"./goaway.ts\";\nimport type { Group } from \"./group.ts\";\nimport type { SessionClient } from \"./session.ts\";\nimport type { Subscribe } from \"./subscribe.ts\";\nimport type { Track } from \"./track.ts\";\n\nexport type StreamBi = SessionClient | AnnounceRequest | Subscribe | Track | Goaway;\nexport type StreamUni = Group;\n\nexport const StreamId = {\n\tSession: 0,\n\tAnnounce: 1,\n\tSubscribe: 2,\n\tFetch: 3,\n\tProbe: 4,\n\tGoaway: 5,\n\tTrack: 6,\n\tClientCompat: 0x20,\n\tServerCompat: 0x21,\n} as const;\n\n/**\n * The varint type prefix on a unidirectional data stream.\n *\n * `Group` is the per-group frame stream. `Setup` (lite-05+) carries the single SETUP\n * message advertising this endpoint's capabilities.\n */\nexport const DataType = {\n\tGroup: 0,\n\tSetup: 1,\n} as const;\n\n/** A unidirectional data-stream type. See {@link DataType}. */\nexport type DataType = (typeof DataType)[keyof typeof DataType];\n"]}
|
package/lite/subscribe.d.ts
CHANGED
|
@@ -42,6 +42,12 @@ export declare class Subscribe {
|
|
|
42
42
|
encode(w: Writer, version: Version): Promise<void>;
|
|
43
43
|
static decode(r: Reader, version: Version): Promise<Subscribe>;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Publisher's acknowledgement on the Subscribe Stream for drafts 01-04.
|
|
47
|
+
*
|
|
48
|
+
* Draft-05+ replaced this with implicit acceptance plus {@link SubscribeStart} /
|
|
49
|
+
* {@link SubscribeEnd}; the immutable codec/timescale/cache moved to TRACK_INFO.
|
|
50
|
+
*/
|
|
45
51
|
export declare class SubscribeOk {
|
|
46
52
|
#private;
|
|
47
53
|
priority: number;
|
|
@@ -59,6 +65,28 @@ export declare class SubscribeOk {
|
|
|
59
65
|
encode(w: Writer, version: Version): Promise<void>;
|
|
60
66
|
static decode(r: Reader, version: Version): Promise<SubscribeOk>;
|
|
61
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolves the absolute start group of a Draft-05+ subscription. The first message
|
|
70
|
+
* the publisher sends, once the start group is known. A value greater than the
|
|
71
|
+
* requested start implicitly drops the leading range.
|
|
72
|
+
*/
|
|
73
|
+
export declare class SubscribeStart {
|
|
74
|
+
group: number;
|
|
75
|
+
constructor(group: number);
|
|
76
|
+
encode(w: Writer): Promise<void>;
|
|
77
|
+
static decode(r: Reader): Promise<SubscribeStart>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Signals that no group at or after `group` (exclusive upper bound) will be produced
|
|
81
|
+
* on a Draft-05+ subscription. `0` means the track ended before producing any groups.
|
|
82
|
+
*/
|
|
83
|
+
export declare class SubscribeEnd {
|
|
84
|
+
/** The exclusive final group sequence: the first sequence that will never be produced. */
|
|
85
|
+
group: number;
|
|
86
|
+
constructor(group: number);
|
|
87
|
+
encode(w: Writer): Promise<void>;
|
|
88
|
+
static decode(r: Reader): Promise<SubscribeEnd>;
|
|
89
|
+
}
|
|
62
90
|
export declare class SubscribeDrop {
|
|
63
91
|
#private;
|
|
64
92
|
start: number;
|
|
@@ -73,39 +101,25 @@ export declare class SubscribeDrop {
|
|
|
73
101
|
static decode(r: Reader): Promise<SubscribeDrop>;
|
|
74
102
|
}
|
|
75
103
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* moq-lite-05+ only.
|
|
79
|
-
*/
|
|
80
|
-
export declare class SubscribeEnd {
|
|
81
|
-
#private;
|
|
82
|
-
group: number;
|
|
83
|
-
constructor(props: {
|
|
84
|
-
group: number;
|
|
85
|
-
});
|
|
86
|
-
encode(w: Writer): Promise<void>;
|
|
87
|
-
static decode(r: Reader): Promise<SubscribeEnd>;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* A response message on the subscribe stream.
|
|
91
|
-
*
|
|
92
|
-
* In Draft03/04 each response is prefixed with a type discriminator: 0x0 SUBSCRIBE_OK,
|
|
93
|
-
* 0x1 SUBSCRIBE_DROP. In Draft05 end-of-subscription splits out, so the discriminators
|
|
94
|
-
* become 0x0 SUBSCRIBE_OK, 0x1 SUBSCRIBE_END, 0x2 SUBSCRIBE_DROP.
|
|
104
|
+
* A response message on the subscribe stream, prefixed with a type discriminator
|
|
105
|
+
* on Draft-03+.
|
|
95
106
|
*
|
|
96
|
-
*
|
|
107
|
+
* The discriminator is version-dependent:
|
|
108
|
+
* - Draft-03/04: `0x0` SUBSCRIBE_OK, `0x1` SUBSCRIBE_DROP.
|
|
109
|
+
* - Draft-05+: `0x0` SUBSCRIBE_START, `0x1` SUBSCRIBE_END, `0x2` SUBSCRIBE_DROP
|
|
110
|
+
* (SUBSCRIBE_OK was removed; acceptance is implicit).
|
|
97
111
|
*/
|
|
98
112
|
export type SubscribeResponse = {
|
|
99
113
|
ok: SubscribeOk;
|
|
114
|
+
} | {
|
|
115
|
+
start: SubscribeStart;
|
|
100
116
|
} | {
|
|
101
117
|
end: SubscribeEnd;
|
|
102
118
|
} | {
|
|
103
119
|
drop: SubscribeDrop;
|
|
104
120
|
};
|
|
105
|
-
/** Encode a subscribe-stream response (OK / END / DROP) for the negotiated moq-lite version. */
|
|
106
121
|
export declare function encodeSubscribeResponse(w: Writer, resp: SubscribeResponse, version: Version): Promise<void>;
|
|
107
|
-
/** Decode the next subscribe-stream response for the negotiated moq-lite version. */
|
|
108
122
|
export declare function decodeSubscribeResponse(r: Reader, version: Version): Promise<SubscribeResponse>;
|
|
109
|
-
/** Like {@link decodeSubscribeResponse} but
|
|
123
|
+
/** Like {@link decodeSubscribeResponse} but resolves `undefined` on a clean FIN. */
|
|
110
124
|
export declare function decodeSubscribeResponseMaybe(r: Reader, version: Version): Promise<SubscribeResponse | undefined>;
|
|
111
125
|
//# sourceMappingURL=subscribe.d.ts.map
|
package/lite/subscribe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/lite/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,qBAAa,eAAe;;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,YAAY,KAAK,EAAE;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;KAClB,EAMA;IAwCK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvD;IAED,OAAa,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAEzE;IAED,OAAa,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAE1F;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,OAAO,GACd,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAGxC"}
|
package/lite/subscribe.js
CHANGED
|
@@ -10,7 +10,7 @@ export class SubscribeUpdate {
|
|
|
10
10
|
endGroup;
|
|
11
11
|
constructor(props) {
|
|
12
12
|
this.priority = props.priority;
|
|
13
|
-
this.ordered = props.ordered ??
|
|
13
|
+
this.ordered = props.ordered ?? false;
|
|
14
14
|
this.maxLatency = props.maxLatency ?? 0;
|
|
15
15
|
this.startGroup = props.startGroup;
|
|
16
16
|
this.endGroup = props.endGroup;
|
|
@@ -131,13 +131,19 @@ export class Subscribe {
|
|
|
131
131
|
return Message.decode(r, (r) => Subscribe.#decode(r, version));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Publisher's acknowledgement on the Subscribe Stream for drafts 01-04.
|
|
136
|
+
*
|
|
137
|
+
* Draft-05+ replaced this with implicit acceptance plus {@link SubscribeStart} /
|
|
138
|
+
* {@link SubscribeEnd}; the immutable codec/timescale/cache moved to TRACK_INFO.
|
|
139
|
+
*/
|
|
134
140
|
export class SubscribeOk {
|
|
135
141
|
priority;
|
|
136
142
|
ordered;
|
|
137
143
|
maxLatency;
|
|
138
144
|
startGroup;
|
|
139
145
|
endGroup;
|
|
140
|
-
constructor({ priority = 0, ordered =
|
|
146
|
+
constructor({ priority = 0, ordered = false, maxLatency = 0, startGroup = undefined, endGroup = undefined, }) {
|
|
141
147
|
this.priority = priority;
|
|
142
148
|
this.ordered = ordered;
|
|
143
149
|
this.maxLatency = maxLatency;
|
|
@@ -152,10 +158,8 @@ export class SubscribeOk {
|
|
|
152
158
|
case Version.DRAFT_01:
|
|
153
159
|
await w.u8(this.priority ?? 0);
|
|
154
160
|
break;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
await w.u53(this.startGroup ?? 0);
|
|
158
|
-
break;
|
|
161
|
+
// Draft-05+ never sends SUBSCRIBE_OK, but keep the field layout matching
|
|
162
|
+
// Draft-03/04 so a stray future use stays well-formed.
|
|
159
163
|
default:
|
|
160
164
|
await w.u8(this.priority);
|
|
161
165
|
await w.bool(this.ordered);
|
|
@@ -178,9 +182,6 @@ export class SubscribeOk {
|
|
|
178
182
|
case Version.DRAFT_01:
|
|
179
183
|
priority = await r.u8();
|
|
180
184
|
break;
|
|
181
|
-
case Version.DRAFT_05_WIP:
|
|
182
|
-
// moq-lite-05+: just the resolved absolute start group (raw).
|
|
183
|
-
return new SubscribeOk({ startGroup: await r.u53() });
|
|
184
185
|
default:
|
|
185
186
|
priority = await r.u8();
|
|
186
187
|
ordered = await r.bool();
|
|
@@ -204,6 +205,44 @@ export class SubscribeOk {
|
|
|
204
205
|
return Message.decode(r, SubscribeOk.#decode.bind(SubscribeOk, version));
|
|
205
206
|
}
|
|
206
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Resolves the absolute start group of a Draft-05+ subscription. The first message
|
|
210
|
+
* the publisher sends, once the start group is known. A value greater than the
|
|
211
|
+
* requested start implicitly drops the leading range.
|
|
212
|
+
*/
|
|
213
|
+
export class SubscribeStart {
|
|
214
|
+
group;
|
|
215
|
+
constructor(group) {
|
|
216
|
+
this.group = group;
|
|
217
|
+
}
|
|
218
|
+
async encode(w) {
|
|
219
|
+
return Message.encode(w, async (w) => {
|
|
220
|
+
await w.u53(this.group);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
static async decode(r) {
|
|
224
|
+
return Message.decode(r, async (r) => new SubscribeStart(await r.u53()));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Signals that no group at or after `group` (exclusive upper bound) will be produced
|
|
229
|
+
* on a Draft-05+ subscription. `0` means the track ended before producing any groups.
|
|
230
|
+
*/
|
|
231
|
+
export class SubscribeEnd {
|
|
232
|
+
/** The exclusive final group sequence: the first sequence that will never be produced. */
|
|
233
|
+
group;
|
|
234
|
+
constructor(group) {
|
|
235
|
+
this.group = group;
|
|
236
|
+
}
|
|
237
|
+
async encode(w) {
|
|
238
|
+
return Message.encode(w, async (w) => {
|
|
239
|
+
await w.u53(this.group);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
static async decode(r) {
|
|
243
|
+
return Message.decode(r, async (r) => new SubscribeEnd(await r.u53()));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
207
246
|
/// Indicates that one or more groups have been dropped.
|
|
208
247
|
///
|
|
209
248
|
/// Draft03+ only.
|
|
@@ -231,30 +270,6 @@ export class SubscribeDrop {
|
|
|
231
270
|
return Message.decode(r, SubscribeDrop.#decode);
|
|
232
271
|
}
|
|
233
272
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Signals that no group after a given sequence will be produced.
|
|
236
|
-
*
|
|
237
|
-
* moq-lite-05+ only.
|
|
238
|
-
*/
|
|
239
|
-
export class SubscribeEnd {
|
|
240
|
-
group;
|
|
241
|
-
constructor(props) {
|
|
242
|
-
this.group = props.group;
|
|
243
|
-
}
|
|
244
|
-
async #encode(w) {
|
|
245
|
-
await w.u53(this.group);
|
|
246
|
-
}
|
|
247
|
-
static async #decode(r) {
|
|
248
|
-
return new SubscribeEnd({ group: await r.u53() });
|
|
249
|
-
}
|
|
250
|
-
async encode(w) {
|
|
251
|
-
return Message.encode(w, this.#encode.bind(this));
|
|
252
|
-
}
|
|
253
|
-
static async decode(r) {
|
|
254
|
-
return Message.decode(r, SubscribeEnd.#decode);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/** Encode a subscribe-stream response (OK / END / DROP) for the negotiated moq-lite version. */
|
|
258
273
|
export async function encodeSubscribeResponse(w, resp, version) {
|
|
259
274
|
switch (version) {
|
|
260
275
|
case Version.DRAFT_01:
|
|
@@ -266,50 +281,52 @@ export async function encodeSubscribeResponse(w, resp, version) {
|
|
|
266
281
|
throw new Error("only SUBSCRIBE_OK is supported for this version");
|
|
267
282
|
}
|
|
268
283
|
break;
|
|
269
|
-
case Version.
|
|
270
|
-
|
|
284
|
+
case Version.DRAFT_03:
|
|
285
|
+
case Version.DRAFT_04:
|
|
271
286
|
if ("ok" in resp) {
|
|
272
287
|
await w.u53(0x0);
|
|
273
288
|
await resp.ok.encode(w, version);
|
|
274
289
|
}
|
|
275
|
-
else if ("
|
|
290
|
+
else if ("drop" in resp) {
|
|
276
291
|
await w.u53(0x1);
|
|
277
|
-
await resp.
|
|
292
|
+
await resp.drop.encode(w);
|
|
278
293
|
}
|
|
279
294
|
else {
|
|
280
|
-
|
|
281
|
-
await resp.drop.encode(w);
|
|
295
|
+
throw new Error("SUBSCRIBE_START/END not supported for this version");
|
|
282
296
|
}
|
|
283
297
|
break;
|
|
284
298
|
default:
|
|
285
|
-
//
|
|
286
|
-
if ("
|
|
299
|
+
// Draft-05+: SUBSCRIBE_OK is gone; START/END/DROP carry the resolved range.
|
|
300
|
+
if ("start" in resp) {
|
|
287
301
|
await w.u53(0x0);
|
|
288
|
-
await resp.
|
|
302
|
+
await resp.start.encode(w);
|
|
289
303
|
}
|
|
290
|
-
else if ("
|
|
304
|
+
else if ("end" in resp) {
|
|
291
305
|
await w.u53(0x1);
|
|
306
|
+
await resp.end.encode(w);
|
|
307
|
+
}
|
|
308
|
+
else if ("drop" in resp) {
|
|
309
|
+
await w.u53(0x2);
|
|
292
310
|
await resp.drop.encode(w);
|
|
293
311
|
}
|
|
294
312
|
else {
|
|
295
|
-
throw new Error("
|
|
313
|
+
throw new Error("SUBSCRIBE_OK not supported for this version");
|
|
296
314
|
}
|
|
297
315
|
break;
|
|
298
316
|
}
|
|
299
317
|
}
|
|
300
|
-
async function
|
|
318
|
+
export async function decodeSubscribeResponse(r, version) {
|
|
301
319
|
switch (version) {
|
|
302
320
|
case Version.DRAFT_01:
|
|
303
321
|
case Version.DRAFT_02:
|
|
304
322
|
return { ok: await SubscribeOk.decode(r, version) };
|
|
305
|
-
case Version.
|
|
323
|
+
case Version.DRAFT_03:
|
|
324
|
+
case Version.DRAFT_04: {
|
|
306
325
|
const typ = await r.u53();
|
|
307
326
|
switch (typ) {
|
|
308
327
|
case 0x0:
|
|
309
328
|
return { ok: await SubscribeOk.decode(r, version) };
|
|
310
329
|
case 0x1:
|
|
311
|
-
return { end: await SubscribeEnd.decode(r) };
|
|
312
|
-
case 0x2:
|
|
313
330
|
return { drop: await SubscribeDrop.decode(r) };
|
|
314
331
|
default:
|
|
315
332
|
throw new Error(`unknown subscribe response type: ${typ}`);
|
|
@@ -319,8 +336,10 @@ async function decodeResponse(r, version) {
|
|
|
319
336
|
const typ = await r.u53();
|
|
320
337
|
switch (typ) {
|
|
321
338
|
case 0x0:
|
|
322
|
-
return {
|
|
339
|
+
return { start: await SubscribeStart.decode(r) };
|
|
323
340
|
case 0x1:
|
|
341
|
+
return { end: await SubscribeEnd.decode(r) };
|
|
342
|
+
case 0x2:
|
|
324
343
|
return { drop: await SubscribeDrop.decode(r) };
|
|
325
344
|
default:
|
|
326
345
|
throw new Error(`unknown subscribe response type: ${typ}`);
|
|
@@ -328,14 +347,10 @@ async function decodeResponse(r, version) {
|
|
|
328
347
|
}
|
|
329
348
|
}
|
|
330
349
|
}
|
|
331
|
-
/**
|
|
332
|
-
export async function decodeSubscribeResponse(r, version) {
|
|
333
|
-
return decodeResponse(r, version);
|
|
334
|
-
}
|
|
335
|
-
/** Like {@link decodeSubscribeResponse} but returns `undefined` at a clean stream end (FIN). */
|
|
350
|
+
/** Like {@link decodeSubscribeResponse} but resolves `undefined` on a clean FIN. */
|
|
336
351
|
export async function decodeSubscribeResponseMaybe(r, version) {
|
|
337
352
|
if (await r.done())
|
|
338
353
|
return undefined;
|
|
339
|
-
return
|
|
354
|
+
return decodeSubscribeResponse(r, version);
|
|
340
355
|
}
|
|
341
356
|
//# sourceMappingURL=subscribe.js.map
|