Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions doc/lib/js/watch.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,30 +218,6 @@ leave the connection's estimate unclaimed. Without a claim, video selects the be
`video.target` allows. To stop the relay probing while still adapting, keep the claim and call
`connection.viewers.setTarget(0)`.

To chart when each audio frame arrived against when it plays, open an
`arrivals()` handle on the audio decoder. It yields every frame received while it is open, stamped
when the frame came off the transport, and a gap wherever media after an earlier
frame will never arrive (a latency skip, a hole):

```ts
const arrivals = player.audio.arrivals();
for await (const entry of arrivals) {
if (entry.kind === "gap") {
// Break the plotted line; nothing arrived from `timestamp` for `duration`.
continue;
}
const { timestamp, arrival, late } = entry;
// `late`: arrived after its playback deadline.
}
```

A gap's span is an upper bound: without per-frame durations it starts at the
last frame's timestamp, and it covers any pause the publisher declared.

Unread frames queue on the handle, so keep reading and keep your own window.
Leaving the loop or calling `arrivals.close()` stops observing and releases
them; nothing is retained without an open handle.

## Buffered playback

By default the player minimizes latency: it time-stretches received audio
Expand Down
5 changes: 0 additions & 5 deletions js/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ qmux-bench:
bunx tsc --noEmit --project net/bench/tsconfig.json
bun net/bench/qmux.ts

# Sweep open arrival handles against their unread backlog.
arrivals-bench:
uv run --no-project python ../sh/js/install.py frozen
bun watch/bench/arrivals.ts

# Reduce and compare the worst known peer grant shapes, swept over AUTH_OK size.
pattern-bench:
uv run --no-project python ../sh/js/install.py frozen
Expand Down
28 changes: 0 additions & 28 deletions js/net/src/ietf/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,34 +312,6 @@ function decodeTag(data: Uint8Array): Filter {
}
}

/**
* Read the tagged filter draft-14 carries inline in a SUBSCRIBE body, where the fields
* following the tag have no length to delimit them.
*
* Every tag is read, including the absolute forms we do not serve. Rejecting one would tear
* the session down over a filter the draft lets a subscriber send; what we do with it is
* decided when the range is resolved.
*/
export async function decodeInline(r: Reader): Promise<Filter> {
const tag = await r.u62();
switch (tag) {
case TAG_NEXT_GROUP:
return { kind: "relative", groups: 0n };
case TAG_LARGEST_OBJECT:
return { kind: "nextObject" };
case TAG_ABSOLUTE_START:
return { kind: "absolute", startGroup: await r.u62(), startObject: await r.u62() };
case TAG_ABSOLUTE_RANGE: {
const startGroup = await r.u62();
const startObject = await r.u62();
const delta = await r.u62();
return { kind: "absolute", startGroup, startObject, endGroup: startGroup + delta };
}
default:
throw new Error(`unsupported filter type: ${tag}`);
}
}

function expectEmpty(rest: Uint8Array): void {
if (rest.length !== 0) {
throw new Error("trailing bytes in LOCATION_FILTER");
Expand Down
16 changes: 1 addition & 15 deletions js/qmux/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @moq/qmux

A [WebTransport](https://developer.mozilla.org/en-US/docs/Web/API/WebTransport_API) implementation using WebSockets as the underlying transport with [QMux](https://www.ietf.org/archive/id/draft-ietf-quic-qmux-02.html) (draft-ietf-quic-qmux-02, negotiating down to draft-01 and draft-00) framing: a polyfill in browsers, and a server on any runtime that can accept a WebSocket.
A [WebTransport](https://developer.mozilla.org/en-US/docs/Web/API/WebTransport_API) implementation using WebSockets as the underlying transport with [QMux](https://www.ietf.org/archive/id/draft-ietf-quic-qmux-02.html) (draft-ietf-quic-qmux-02, negotiating down to draft-01 and draft-00) framing: a WebTransport-compatible client in browsers, and a server on any runtime that can accept a WebSocket.

QMux brings QUIC's multiplexed streams and flow control to reliable, ordered byte-stream transports like WebSockets. This allows WebTransport applications to seamlessly fall back when QUIC/UDP is blocked by network middleboxes.

Expand Down Expand Up @@ -124,20 +124,6 @@ The outgoing code comes off the reason passed to `abort()` / `cancel()`, so any
(native or the exported `StreamError`) sends its `streamErrorCode` and anything else sends 0.
`STOP_SENDING` works the same way, erroring the sender's writable with the code the peer chose.

### Polyfill

Install as a global `WebTransport` polyfill:

```ts
import { install } from "@moq/qmux"

// Only installs if native WebTransport is unavailable
install()

// Now use the standard WebTransport API
const transport = new WebTransport("https://example.com/endpoint")
```

## License

Licensed under either of [Apache License, Version 2.0](../../LICENSE-APACHE) or [MIT license](../../LICENSE-MIT) at your option.
7 changes: 0 additions & 7 deletions js/qmux/api/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ export interface Config {
streamReceiveWindow?: bigint;
}

export interface InstallOptions {
requireProtocol?: boolean;
versions?: Record<string, Version | Version[] | null>;
}

export interface SendStream extends WritableStream<Uint8Array> {
getStats(): Promise<SendStreamStats>;
sendOrder: number;
Expand Down Expand Up @@ -136,7 +131,5 @@ export interface WebSocketStreamOpenEvent {
writable: WritableStream<WebSocketStreamData>;
}

export function install(options?: InstallOptions): boolean;

export function selectSubprotocol(offered: string | readonly string[] | null | undefined, options?: Pick<SessionOptions, "protocols" | "versions" | "requireProtocol">): string | undefined;
```
1 change: 0 additions & 1 deletion js/qmux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"qmux",
"webtransport",
"websocket",
"polyfill",
"quic",
"streams"
]
Expand Down
33 changes: 1 addition & 32 deletions js/qmux/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** WebTransport over WebSockets with QMux framing: a browser polyfill and a server for an accepted socket. @module */
import { Session, type Version } from "./session.ts";
/** WebTransport over WebSockets with QMux framing: a browser client and a server for an accepted socket. @module */

export { SessionError, StreamError } from "./error.ts";
export type {
Expand All @@ -21,33 +20,3 @@ export type {
WebSocketStreamLike,
WebSocketStreamOpenEvent,
} from "./web-socket-stream.ts";

/** Options forwarded to every `Session` constructed by {@link install}. */
export interface InstallOptions {
/** Wire-format version(s) by ALPN. See {@link SessionOptions.versions}. */
versions?: Record<string, Version | Version[] | null>;
/** Require the peer to negotiate an app protocol. See {@link SessionOptions.requireProtocol}. */
requireProtocol?: boolean;
}

/** Install `Session` as the global `WebTransport` if the platform doesn't ship one.
*
* The `versions` map and `requireProtocol` flag are forwarded to every
* `Session` constructed via the polyfill. Callers that pass only explicit
* `{qmux-VV}.{alpn}` pairs in their `protocols` list can omit the map.
*
* Returns `true` if the polyfill was installed, `false` if `globalThis.WebTransport`
* already existed.
*/
export function install(options?: InstallOptions): boolean {
if ("WebTransport" in globalThis) return false;
const versions = options?.versions;
const requireProtocol = options?.requireProtocol;
// biome-ignore lint/suspicious/noExplicitAny: polyfill - extending Session to match the WebTransport constructor signature
(globalThis as any).WebTransport = class extends Session {
constructor(url: string | URL, options?: WebTransportOptions) {
super(url, { ...options, versions, requireProtocol });
}
};
return true;
}
18 changes: 0 additions & 18 deletions js/watch/api/index.api.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
# `@moq/watch`

```ts
export type Arrival = {
arrival: Clock.Instant;
kind: "frame";
late: boolean;
timestamp: Clock.Duration;
} | {
duration: Clock.Duration;
kind: "gap";
timestamp: Clock.Duration;
};

export interface Arrivals {
[Symbol.asyncIterator](): AsyncIterator<Arrival>;
close(): void;
next(): Promise<Arrival | undefined>;
}

export namespace Audio {
export class Decoder {
constructor(props: Audio.DecoderProps);
arrivals(): Arrivals;
close(): void;
readonly in: Signals.Readonlys<Audio.DecoderInput>;
readonly out: Signals.Readonlys<Audio.DecoderOutput>;
Expand Down
29 changes: 0 additions & 29 deletions js/watch/bench/arrivals.ts

This file was deleted.

2 changes: 1 addition & 1 deletion js/watch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"./src/support/element.ts"
],
"scripts": {
"build": "rm -rf dist && vite build && tsc -p tsconfig.build.json && bun ../common/package.ts && tsc --project test-dts/tsconfig.json",
"build": "rm -rf dist && vite build && tsc -p tsconfig.build.json && bun ../common/package.ts",
"check": "tsc --noEmit",
"test": "bun test --only-failures",
"release": "bun ../common/release.ts"
Expand Down
70 changes: 0 additions & 70 deletions js/watch/src/arrivals.test.ts

This file was deleted.

Loading