@moq/web-transport-ws
v0.1.2
Published
WebTransport polyfill using WebSockets
Maintainers
Readme
WebTransport Polyfill
A WebTransport polyfill that uses WebSocket as the underlying transport, with implementations in both Rust and TypeScript/JavaScript.
Wire Protocol
Both implementations use the same QUIC-like frame encoding over WebSocket:
- Variable-length integer encoding (VarInt)
- Stream multiplexing with bidirectional and unidirectional streams
- Frame types: STREAM, RESET_STREAM, STOP_SENDING, etc.
This is a simplified version of QMux, which might be used in the future.
JavaScript/TypeScript Usage
Check if WebTransport is available, otherwise install the polyfill:
import { install } from "@moq/web-transport-ws"
// Install the polyfill if needed.
install();
// Now WebTransport is available even in Safari
const transport = new WebTransport("https://example.com/path")URLs are automatically rewritten with the WebSocket protocol:
https://example.com/path→wss://example.com/path
Building
Rust
cargo buildTypeScript/JavaScript
npm install
npm run buildUsage
cargo run --example serverbun examples/client.tsdeno -A --sloppy-imports examples/client.tsBundle TypeScript source to single JavaScript file
bun build --target=node --outfile=examples/client.js examples/client.ts node examples/client.jsLicense
MIT OR Apache-2.0
