@caprid/moq-core 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +20 -0
  2. package/NOTICE +5 -0
  3. package/README.md +26 -2
  4. package/UPSTREAM.json +34 -0
  5. package/dist/index.d.ts +18 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +10 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/protocol/bytes.d.ts +58 -0
  10. package/dist/protocol/bytes.d.ts.map +1 -0
  11. package/dist/protocol/bytes.js +210 -0
  12. package/dist/protocol/bytes.js.map +1 -0
  13. package/dist/protocol/control-messages.d.ts +544 -0
  14. package/dist/protocol/control-messages.d.ts.map +1 -0
  15. package/dist/protocol/control-messages.js +1110 -0
  16. package/dist/protocol/control-messages.js.map +1 -0
  17. package/dist/protocol/errors.d.ts +64 -0
  18. package/dist/protocol/errors.d.ts.map +1 -0
  19. package/dist/protocol/errors.js +67 -0
  20. package/dist/protocol/errors.js.map +1 -0
  21. package/dist/protocol/object-stream.d.ts +128 -0
  22. package/dist/protocol/object-stream.d.ts.map +1 -0
  23. package/dist/protocol/object-stream.js +255 -0
  24. package/dist/protocol/object-stream.js.map +1 -0
  25. package/dist/protocol/publish-session.d.ts +175 -0
  26. package/dist/protocol/publish-session.d.ts.map +1 -0
  27. package/dist/protocol/publish-session.js +1026 -0
  28. package/dist/protocol/publish-session.js.map +1 -0
  29. package/dist/protocol/request-stream.d.ts +51 -0
  30. package/dist/protocol/request-stream.d.ts.map +1 -0
  31. package/dist/protocol/request-stream.js +94 -0
  32. package/dist/protocol/request-stream.js.map +1 -0
  33. package/dist/protocol/session.d.ts +334 -0
  34. package/dist/protocol/session.d.ts.map +1 -0
  35. package/dist/protocol/session.js +908 -0
  36. package/dist/protocol/session.js.map +1 -0
  37. package/dist/protocol/stream-reset.d.ts +10 -0
  38. package/dist/protocol/stream-reset.d.ts.map +1 -0
  39. package/dist/protocol/stream-reset.js +24 -0
  40. package/dist/protocol/stream-reset.js.map +1 -0
  41. package/dist/protocol/subgroup-writer.d.ts +67 -0
  42. package/dist/protocol/subgroup-writer.d.ts.map +1 -0
  43. package/dist/protocol/subgroup-writer.js +172 -0
  44. package/dist/protocol/subgroup-writer.js.map +1 -0
  45. package/dist/protocol/transport-error.d.ts +29 -0
  46. package/dist/protocol/transport-error.d.ts.map +1 -0
  47. package/dist/protocol/transport-error.js +39 -0
  48. package/dist/protocol/transport-error.js.map +1 -0
  49. package/dist/protocol/varint.d.ts +20 -0
  50. package/dist/protocol/varint.d.ts.map +1 -0
  51. package/dist/protocol/varint.js +99 -0
  52. package/dist/protocol/varint.js.map +1 -0
  53. package/dist/track-source.d.ts +13 -0
  54. package/dist/track-source.d.ts.map +1 -0
  55. package/dist/track-source.js +2 -0
  56. package/dist/track-source.js.map +1 -0
  57. package/package.json +31 -4
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2025-present Video.js contributors
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+ ------------------------------------------------------------------
16
+
17
+ Trademark Notice:
18
+ “Video.js” is a registered trademark of Brightcove Inc.
19
+ The project is maintained independently by the open-source community,
20
+ governed by the Video.js Technical Steering Committee.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ The protocol implementation and its initial tests are derived from Video.js.
2
+ Copyright 2025-present Video.js contributors.
3
+ Licensed under the Apache License, Version 2.0. See LICENSE.
4
+
5
+ See UPSTREAM.json for the source revision, original file hashes, and adaptations.
package/README.md CHANGED
@@ -1,3 +1,27 @@
1
- # @caprid/moq-core
1
+ # Generic MoQ core
2
2
 
3
- Placeholder so the name can be set up for trusted publishing. Install 0.1.0 or later.
3
+ An independently buildable package for MOQT sessions and arbitrary track objects. It has no runtime
4
+ dependencies and does not import Relay product code or Video.js.
5
+
6
+ `createMoqtSession` owns the supplied established transport. Subscribe, fetch, and track-status
7
+ requests use callback handlers, preserve uninterpreted payloads and object properties, and expose
8
+ protocol lifecycle notifications. `MoqTrackSource` describes borrowed track access without shutdown.
9
+
10
+ The implementation and regression tests originate in Video.js under Apache-2.0. This initial
11
+ extraction preserves the wire implementation; ESM imports, test-runner imports, and the default SETUP implementation identifier are adapted.
12
+ See `NOTICE` and `UPSTREAM.json`. The original Video.js modules remain pending dependency migration.
13
+
14
+ This package follows MOQT draft 22, and draft 20 for a peer that selects it, and receives subscription objects over reliable streams. It does
15
+ not implement application timing, decoding, datagram reception, or automatic session recovery.
16
+
17
+ `createMoqtPublishSession` serves a namespace and its registered tracks over a separate transport.
18
+ The extracted publish driver excludes SPF actors and media dependencies. Track properties are
19
+ explicit, with no default media timescale. `createSubgroupWriter` writes arbitrary object payloads
20
+ and metadata; the SDK supplies the bounded, single-object-group publishing policy above it.
21
+
22
+ For Relay application usage and local installation, start with the [JavaScript quickstart](../../GUIDE.md#first-round-trip).
23
+
24
+ ## Stability
25
+
26
+ Before 1.0, a minor version can break the API. This package releases together with `@caprid/relay`
27
+ at the same version; see the [changelog](../../CHANGELOG.md).
package/UPSTREAM.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "repository": "https://github.com/videojs/v10",
3
+ "revision": "5a486737dad4a5874a4f4d3250c7cc8195f5d704",
4
+ "protocol": "moqt-22",
5
+ "files": {
6
+ "packages/spf/src/network/moqt/bytes.ts": "50cd814e1b601047e26d11954191c1fc91ecc559d1b9cc4cca1a48424af00bba",
7
+ "packages/spf/src/network/moqt/control-messages.ts": "f0832fd5e4974a07e308ab7fcdffa92b73e4fdd9eb6916f17a9481d2d3830935",
8
+ "packages/spf/src/network/moqt/errors.ts": "a3b9498efb1133bbdbe5047c95ac63744c69ea98c805a01941f996e28eff3e3d",
9
+ "packages/spf/src/network/moqt/object-stream.ts": "1e57fd00bc4437c7f983305a00bf3473e1dcec04d65a1bb9d08a68901f9f92e7",
10
+ "packages/spf/src/network/moqt/request-stream.ts": "f89104ecc12e18882905557292e43fd6b4b927564487b49b2a7ca6a01ed2cd68",
11
+ "packages/spf/src/network/moqt/session.ts": "948459b9bc7508d2573a1a428201e5be691e01c9910c17a483aff88b1ab5796a",
12
+ "packages/spf/src/network/moqt/varint.ts": "c4f2b9db079f99d36c18cee22cc223bfbe154453944d48e616094aeb512cd7a5",
13
+ "packages/spf/src/publish/session/publish-session.ts": "5dede482ff4f56362be532ef28376f53935f143ef8465a781fa7ffda4f072190",
14
+ "packages/spf/src/network/moqt/subgroup-writer.ts": "716633da1bf9defe2b8f99dce33f61f9aa9c91cdadf044df71cf55d79a60a012"
15
+ },
16
+ "adaptations": [
17
+ "Relative imports use .js suffixes for native ESM.",
18
+ "Tests use Vitest directly and import protocol modules from their new directory.",
19
+ "The default SETUP implementation identifier names @caprid/moq-core. The existing error identity symbol is retained for interoperability.",
20
+ "Publish session extraction excludes the SPF actor and accepts explicit track properties instead of imposing the LOC microsecond timescale.",
21
+ "Publish protocol tests exclude media-engine integration and actor tests; raw tracks assert no implicit timescale.",
22
+ "SDK relay-hub test helper is derived from Video.js publish tests and adapted to local protocol imports.",
23
+ "The package index additionally re-exports ByteWriter, encodeKeyValuePairs and MAX_OBJECT_PROPERTIES_LENGTH so the SDK can measure encoded properties with the core's own encoder before a write starts; the protocol modules are unchanged.",
24
+ "The subscribe session's close sends no GOAWAY, unlike the upstream driver's best-effort GOAWAY(0): one written as the transport closes gives the peer nothing to act on and the session has no drain to offer, and the publish session already sends none (spec/behavior.md, \"Relay interop deviations\"; issue #128). Receiving GOAWAY is unchanged.",
25
+ "The publish session closes with INVALID_REQUEST_ID rather than PROTOCOL_VIOLATION when the peer reuses a request ID, and also when a peer request ID has the client's (even) parity, as draft-22 Section 6.4.2.1 requires. Tests that stand the subscribe driver in for the relay give it odd request IDs through a transport wrapper.",
26
+ "The subscribe session closes with INVALID_REQUEST_ID too when a server-initiated request reuses a request ID or has the client's (even) parity, checked before the request is answered, so a request the client rejects still consumes its ID (draft-22 Section 6.4.2.1).",
27
+ "The publish session ends each Established subscription it ends with PUBLISH_DONE (a status, and a Stream Count of the data streams opened for it) after closing that subscription's data streams, then FIN, instead of the upstream FIN alone. `openUniStream(trackAlias)` names the subscription a data stream serves, so the session can count it and reset it if still open. This needs moq-relay 0.15.4 or later (spec/behavior.md, \"Relay interop deviations\"; issue #132).",
28
+ "An orderly publish session close, after the bounded write drain, also waits (`CLOSE_END_ACK_TIMEOUT_MS`, 2 s) for the peer to end its side of every request stream it is still serving before closing the transport, instead of the upstream close right after the write drain. moq-relay FINs that side only after it has read PUBLISH_DONE and finished the track; a transport closed sooner aborts the track and viewers see PUBLISH_DONE status 0 (spec/behavior.md, \"Relay interop deviations\"; issue #25).",
29
+ "The subscribe session FINs its side of a subscription's request stream once the publisher's FIN follows PUBLISH_DONE, as draft-22 Section 6.4.2.2 says a requester SHOULD, instead of the upstream driver leaving it open. A publisher closing waits for that FIN before closing the transport, so an SDK publisher closing ahead of an SDK subscriber no longer waits out the 2 s bound. A follow-up message on a request stream whose sending side has ended writes nothing (spec/behavior.md, \"Relay interop deviations\"; issue #142).",
30
+ "The package index also re-exports the types that public signatures reference, and TSDoc comments were added to exported declarations for the generated API reference (issue #179); code is unchanged.",
31
+ "The core speaks moq-transport draft-22 by default and draft-20 as a fallback, where the upstream snapshot speaks draft-20 only. The two differ on the wire only in the LOCATION_FILTER parameter (draft-22 Section 9.20.9: a Location Filter Type selects the fields and there is no length; draft-20 length-prefixes the fields), so the codec takes the negotiated identifier: `MOQT_PROTOCOL_IDS` lists both in preference order, each session reads `transport.protocol` through `resolveMoqtProtocol`, and every encoder and decoder that carries message parameters takes a trailing `protocol` argument that defaults to `moqt-22`. Section citations in the protocol modules follow draft-22's numbering (docs/research/moqt-22-delta.md; issue #274)."
32
+ ],
33
+ "migration": "Initial extraction snapshot. Video.js still contains the original modules; migrating it to this independently versioned package is a separate integration step. Do not maintain divergent protocol implementations."
34
+ }
@@ -0,0 +1,18 @@
1
+ export { ByteWriter } from './protocol/bytes.js';
2
+ export type { FillParameters, GroupOrder, KeyValuePair, Location, LocationFilter, MessageParameters, MoqtProtocolId, Redirect, TrackNamespace, } from './protocol/control-messages.js';
3
+ export { encodeKeyValuePairs, encodeRequestUpdate, MAX_NAMESPACE_FIELDS, MOQT_PROTOCOL_ID, MOQT_PROTOCOL_IDS, PUBLISH_DONE_STATUS, REQUEST_ERROR_CODE, SETUP_OPTION, } from './protocol/control-messages.js';
4
+ export type { SessionErrorCode } from './protocol/errors.js';
5
+ export { isMoqtProtocolError, MoqtProtocolError, SESSION_ERROR } from './protocol/errors.js';
6
+ export type { FetchEndOfRangeStatus, FetchStreamEntry, MoqtObject, ObjectStatus } from './protocol/object-stream.js';
7
+ export { MAX_OBJECT_PAYLOAD_LENGTH, MAX_OBJECT_PROPERTIES_LENGTH } from './protocol/object-stream.js';
8
+ export type { IncomingSubscribe, MoqtPublishSession, MoqtPublishSessionCallbacks, MoqtPublishSessionConfig, RegisteredTrack, RegisterTrackOptions, } from './protocol/publish-session.js';
9
+ export { createMoqtPublishSession, MAX_TRACK_PROPERTIES_LENGTH } from './protocol/publish-session.js';
10
+ export type { BidirectionalStreamLike } from './protocol/request-stream.js';
11
+ export type { FetchHandle, FetchHandlers, FetchOk, Goaway, IncomingPublish, MoqtFetchOptions, MoqtSendStreamOptions, MoqtSession, MoqtSessionCallbacks, MoqtSessionConfig, MoqtSubscribeNamespaceOptions, MoqtSubscribeOptions, MoqtTransport, NamespaceSubscription, NamespaceSubscriptionHandlers, PublishDone, RequestError, SubscribeOk, Subscription, SubscriptionHandlers, TrackStatusHandlers, } from './protocol/session.js';
12
+ export { createMoqtSession, isStreamFailure } from './protocol/session.js';
13
+ export { streamResetReason } from './protocol/stream-reset.js';
14
+ export type { SubgroupObjectInput, SubgroupWriteOptions, SubgroupWriter, SubgroupWriterOptions, } from './protocol/subgroup-writer.js';
15
+ export { createSubgroupWriter } from './protocol/subgroup-writer.js';
16
+ export { isStreamError, MoqtStreamError } from './protocol/transport-error.js';
17
+ export type { MoqTrackSource } from './track-source.js';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,YAAY,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,cAAc,GACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,GACb,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7F,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACrH,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AACtG,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,EAC3B,wBAAwB,EACxB,eAAe,EACf,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACtG,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,YAAY,EACV,WAAW,EACX,aAAa,EACb,OAAO,EACP,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,6BAA6B,EAC7B,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC/E,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export { ByteWriter } from './protocol/bytes.js';
2
+ export { encodeKeyValuePairs, encodeRequestUpdate, MAX_NAMESPACE_FIELDS, MOQT_PROTOCOL_ID, MOQT_PROTOCOL_IDS, PUBLISH_DONE_STATUS, REQUEST_ERROR_CODE, SETUP_OPTION, } from './protocol/control-messages.js';
3
+ export { isMoqtProtocolError, MoqtProtocolError, SESSION_ERROR } from './protocol/errors.js';
4
+ export { MAX_OBJECT_PAYLOAD_LENGTH, MAX_OBJECT_PROPERTIES_LENGTH } from './protocol/object-stream.js';
5
+ export { createMoqtPublishSession, MAX_TRACK_PROPERTIES_LENGTH } from './protocol/publish-session.js';
6
+ export { createMoqtSession, isStreamFailure } from './protocol/session.js';
7
+ export { streamResetReason } from './protocol/stream-reset.js';
8
+ export { createSubgroupWriter } from './protocol/subgroup-writer.js';
9
+ export { isStreamError, MoqtStreamError } from './protocol/transport-error.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAYjD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,GACb,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE7F,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAStG,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAyBtG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAO/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,58 @@
1
+ export declare function utf8Encode(value: string): Uint8Array;
2
+ export declare function utf8Decode(bytes: Uint8Array): string;
3
+ /** Synchronous cursor over a byte buffer. All reads throw `RangeError` past the end. */
4
+ export declare class ByteReader {
5
+ #private;
6
+ constructor(bytes: Uint8Array, offset?: number);
7
+ get offset(): number;
8
+ get remaining(): number;
9
+ readVarint(): number;
10
+ /**
11
+ * Read a count whose "unknown" sentinel is the maximal varint 2^64−1 — PUBLISH_DONE's Stream Count (§9.9). Exactly
12
+ * that sentinel reads as `undefined`; any other value above this codec's 2^53−1 ceiling is still the protocol error
13
+ * `readVarint` raises, since no real count gets there.
14
+ */
15
+ readCountVarint(): number | undefined;
16
+ readUint8(): number;
17
+ readUint16(): number;
18
+ /** Returns a view (not a copy) of the next `length` bytes. */
19
+ readBytes(length: number): Uint8Array;
20
+ }
21
+ /** Growable byte sink for encoding wire structures. */
22
+ export declare class ByteWriter {
23
+ #private;
24
+ constructor(initialCapacity?: number);
25
+ /** Number of bytes written so far. */
26
+ get length(): number;
27
+ /** Appends a MOQT varint (§8.1). Throws `RangeError` unless `value` is a non-negative safe integer. */
28
+ writeVarint(value: number): void;
29
+ /** Appends the low 8 bits of `value`. */
30
+ writeUint8(value: number): void;
31
+ /** Appends the low 16 bits of `value`, big-endian. */
32
+ writeUint16(value: number): void;
33
+ /** Appends `bytes` as-is, with no length prefix. */
34
+ writeBytes(bytes: Uint8Array): void;
35
+ /** Varint length prefix followed by the bytes. */
36
+ writeLengthPrefixed(bytes: Uint8Array): void;
37
+ /** Returns a copy of the written bytes. */
38
+ toBytes(): Uint8Array;
39
+ }
40
+ /**
41
+ * Buffered asynchronous reader over a `ReadableStream<Uint8Array>`.
42
+ *
43
+ * Reads never split a varint or byte run: each method pulls chunks until it can satisfy the request. A clean
44
+ * end-of-stream mid-read throws `RangeError`; use `atEnd()` to probe for a clean boundary first.
45
+ */
46
+ export declare class StreamReader {
47
+ #private;
48
+ constructor(stream: ReadableStream<Uint8Array>);
49
+ /** True when the stream ended cleanly with no bytes left unread. */
50
+ atEnd(): Promise<boolean>;
51
+ readBytes(length: number): Promise<Uint8Array>;
52
+ readUint8(): Promise<number>;
53
+ readVarint(): Promise<number>;
54
+ /** Cancel the underlying stream (e.g. drop an unwanted data stream). */
55
+ cancel(reason?: unknown): Promise<void>;
56
+ releaseLock(): void;
57
+ }
58
+ //# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/protocol/bytes.ts"],"names":[],"mappings":"AAYA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEpD;AA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AAG,OAAO,CAAC,IAAI,CAAC;IAQ7C,WAAW,IAAI,IAAI;CAGpB"}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Byte-level readers/writers shared by the MOQT wire codecs.
3
+ *
4
+ * `ByteReader`/`ByteWriter` are synchronous cursors over in-memory buffers, used for control-message bodies (always
5
+ * fully buffered — the 16-bit message length bounds them). `StreamReader` is the asynchronous counterpart for
6
+ * unidirectional data streams, where headers and objects arrive incrementally over a WebTransport `ReadableStream`.
7
+ */
8
+ import { decodeVarint, encodeVarintInto, varintByteLength, varintLengthFromFirstByte } from './varint.js';
9
+ const textEncoder = new TextEncoder();
10
+ const textDecoder = new TextDecoder();
11
+ export function utf8Encode(value) {
12
+ return textEncoder.encode(value);
13
+ }
14
+ export function utf8Decode(bytes) {
15
+ return textDecoder.decode(bytes);
16
+ }
17
+ /** Synchronous cursor over a byte buffer. All reads throw `RangeError` past the end. */
18
+ export class ByteReader {
19
+ #bytes;
20
+ #offset;
21
+ constructor(bytes, offset = 0) {
22
+ this.#bytes = bytes;
23
+ this.#offset = offset;
24
+ }
25
+ get offset() {
26
+ return this.#offset;
27
+ }
28
+ get remaining() {
29
+ return this.#bytes.length - this.#offset;
30
+ }
31
+ readVarint() {
32
+ const { value, byteLength } = decodeVarint(this.#bytes, this.#offset);
33
+ this.#offset += byteLength;
34
+ return value;
35
+ }
36
+ /**
37
+ * Read a count whose "unknown" sentinel is the maximal varint 2^64−1 — PUBLISH_DONE's Stream Count (§9.9). Exactly
38
+ * that sentinel reads as `undefined`; any other value above this codec's 2^53−1 ceiling is still the protocol error
39
+ * `readVarint` raises, since no real count gets there.
40
+ */
41
+ readCountVarint() {
42
+ const offset = this.#offset;
43
+ // 2^64−1 has one encoding: the 9-byte form with every bit set.
44
+ if (this.remaining >= 9 && this.#bytes.subarray(offset, offset + 9).every((byte) => byte === 0xff)) {
45
+ this.#offset += 9;
46
+ return undefined;
47
+ }
48
+ return this.readVarint();
49
+ }
50
+ readUint8() {
51
+ if (this.remaining < 1)
52
+ throw new RangeError('read past end of buffer');
53
+ return this.#bytes[this.#offset++];
54
+ }
55
+ readUint16() {
56
+ if (this.remaining < 2)
57
+ throw new RangeError('read past end of buffer');
58
+ const value = this.#bytes[this.#offset] * 256 + this.#bytes[this.#offset + 1];
59
+ this.#offset += 2;
60
+ return value;
61
+ }
62
+ /** Returns a view (not a copy) of the next `length` bytes. */
63
+ readBytes(length) {
64
+ if (length < 0 || this.remaining < length)
65
+ throw new RangeError('read past end of buffer');
66
+ const view = this.#bytes.subarray(this.#offset, this.#offset + length);
67
+ this.#offset += length;
68
+ return view;
69
+ }
70
+ }
71
+ /** Growable byte sink for encoding wire structures. */
72
+ export class ByteWriter {
73
+ #buffer;
74
+ #length = 0;
75
+ constructor(initialCapacity = 256) {
76
+ this.#buffer = new Uint8Array(initialCapacity);
77
+ }
78
+ /** Number of bytes written so far. */
79
+ get length() {
80
+ return this.#length;
81
+ }
82
+ #ensure(extra) {
83
+ const needed = this.#length + extra;
84
+ if (needed <= this.#buffer.length)
85
+ return;
86
+ const grown = new Uint8Array(Math.max(needed, this.#buffer.length * 2));
87
+ grown.set(this.#buffer.subarray(0, this.#length));
88
+ this.#buffer = grown;
89
+ }
90
+ /** Appends a MOQT varint (§8.1). Throws `RangeError` unless `value` is a non-negative safe integer. */
91
+ writeVarint(value) {
92
+ this.#ensure(varintByteLength(value));
93
+ this.#length += encodeVarintInto(this.#buffer, this.#length, value);
94
+ }
95
+ /** Appends the low 8 bits of `value`. */
96
+ writeUint8(value) {
97
+ this.#ensure(1);
98
+ this.#buffer[this.#length++] = value & 0xff;
99
+ }
100
+ /** Appends the low 16 bits of `value`, big-endian. */
101
+ writeUint16(value) {
102
+ this.#ensure(2);
103
+ this.#buffer[this.#length++] = (value >> 8) & 0xff;
104
+ this.#buffer[this.#length++] = value & 0xff;
105
+ }
106
+ /** Appends `bytes` as-is, with no length prefix. */
107
+ writeBytes(bytes) {
108
+ this.#ensure(bytes.length);
109
+ this.#buffer.set(bytes, this.#length);
110
+ this.#length += bytes.length;
111
+ }
112
+ /** Varint length prefix followed by the bytes. */
113
+ writeLengthPrefixed(bytes) {
114
+ this.writeVarint(bytes.length);
115
+ this.writeBytes(bytes);
116
+ }
117
+ /** Returns a copy of the written bytes. */
118
+ toBytes() {
119
+ return this.#buffer.slice(0, this.#length);
120
+ }
121
+ }
122
+ /**
123
+ * Buffered asynchronous reader over a `ReadableStream<Uint8Array>`.
124
+ *
125
+ * Reads never split a varint or byte run: each method pulls chunks until it can satisfy the request. A clean
126
+ * end-of-stream mid-read throws `RangeError`; use `atEnd()` to probe for a clean boundary first.
127
+ */
128
+ export class StreamReader {
129
+ #reader;
130
+ #chunks = [];
131
+ #buffered = 0;
132
+ #done = false;
133
+ constructor(stream) {
134
+ this.#reader = stream.getReader();
135
+ }
136
+ async #pull() {
137
+ if (this.#done)
138
+ return false;
139
+ const { done, value } = await this.#reader.read();
140
+ if (done) {
141
+ this.#done = true;
142
+ return false;
143
+ }
144
+ if (value.length > 0) {
145
+ this.#chunks.push(value);
146
+ this.#buffered += value.length;
147
+ }
148
+ return true;
149
+ }
150
+ async #fill(length) {
151
+ while (this.#buffered < length) {
152
+ if (!(await this.#pull()))
153
+ throw new RangeError('unexpected end of stream');
154
+ }
155
+ }
156
+ #take(length) {
157
+ const out = new Uint8Array(length);
158
+ let copied = 0;
159
+ while (copied < length) {
160
+ const head = this.#chunks[0];
161
+ const take = Math.min(head.length, length - copied);
162
+ out.set(head.subarray(0, take), copied);
163
+ if (take === head.length) {
164
+ this.#chunks.shift();
165
+ }
166
+ else {
167
+ this.#chunks[0] = head.subarray(take);
168
+ }
169
+ copied += take;
170
+ }
171
+ this.#buffered -= length;
172
+ return out;
173
+ }
174
+ /** True when the stream ended cleanly with no bytes left unread. */
175
+ async atEnd() {
176
+ while (this.#buffered === 0) {
177
+ if (!(await this.#pull()))
178
+ return true;
179
+ }
180
+ return false;
181
+ }
182
+ async readBytes(length) {
183
+ await this.#fill(length);
184
+ return this.#take(length);
185
+ }
186
+ async readUint8() {
187
+ await this.#fill(1);
188
+ return this.#take(1)[0];
189
+ }
190
+ async readVarint() {
191
+ await this.#fill(1);
192
+ const firstByte = this.#chunks[0][0];
193
+ const byteLength = varintLengthFromFirstByte(firstByte);
194
+ await this.#fill(byteLength);
195
+ return decodeVarint(this.#take(byteLength)).value;
196
+ }
197
+ /** Cancel the underlying stream (e.g. drop an unwanted data stream). */
198
+ async cancel(reason) {
199
+ try {
200
+ await this.#reader.cancel(reason);
201
+ }
202
+ finally {
203
+ this.#reader.releaseLock();
204
+ }
205
+ }
206
+ releaseLock() {
207
+ this.#reader.releaseLock();
208
+ }
209
+ }
210
+ //# sourceMappingURL=bytes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/protocol/bytes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE1G,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,wFAAwF;AACxF,MAAM,OAAO,UAAU;IACrB,MAAM,CAAa;IACnB,OAAO,CAAS;IAEhB,YAAY,KAAiB,EAAE,MAAM,GAAG,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,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