@caprid/relay-websocket 0.0.0-stage → 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.
- package/LICENSE +202 -0
- package/README.md +66 -2
- package/dist/errors.d.ts +39 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +41 -0
- package/dist/errors.js.map +1 -0
- package/dist/fallback.d.ts +55 -0
- package/dist/fallback.d.ts.map +1 -0
- package/dist/fallback.js +208 -0
- package/dist/fallback.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/streams.d.ts +23 -0
- package/dist/streams.d.ts.map +1 -0
- package/dist/streams.js +158 -0
- package/dist/streams.js.map +1 -0
- package/dist/transport.d.ts +34 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +215 -0
- package/dist/transport.js.map +1 -0
- package/package.json +33 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@caprid/relay-websocket`: the Relay SDK's transport adapter for QMux over WebSocket. It carries MOQT on QMux
|
|
3
|
+
* (draft-ietf-quic-qmux, wire format `qmux-01`) inside one WebSocket connection over TCP, the relay's fallback for
|
|
4
|
+
* networks that block UDP and browsers without a usable `WebTransport`. It follows the transport adapter contract
|
|
5
|
+
* (`spec/transport-adapter.md`), with the deviations the contract records for it.
|
|
6
|
+
*
|
|
7
|
+
* - {@link createWebSocketTransport}: always WebSocket.
|
|
8
|
+
* - {@link withWebSocketFallback}: WebTransport first, WebSocket when its handshake fails or times out.
|
|
9
|
+
*
|
|
10
|
+
* Pass either factory as the SDK's `createTransport`.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
import type { MoqtTransport } from '@caprid/moq-core';
|
|
15
|
+
import { type FallbackCarrier, FallbackTransport, type WebSocketFallbackOptions } from './fallback.js';
|
|
16
|
+
export type { CloseInfo } from './errors.js';
|
|
17
|
+
export { WebSocketSessionError } from './errors.js';
|
|
18
|
+
export type { FallbackCarrier, FallbackTransport, WebSocketFallbackOptions } from './fallback.js';
|
|
19
|
+
/** The transport a {@link WebSocketConnection} carries: a `MoqtTransport` that reports the selected protocol. */
|
|
20
|
+
export interface WebSocketMoqtTransport extends MoqtTransport {
|
|
21
|
+
/** The MOQT protocol the peer selected, without its QMux prefix; empty until `ready` resolves. */
|
|
22
|
+
readonly protocol: string;
|
|
23
|
+
}
|
|
24
|
+
/** What one call of a {@link WebSocketTransportFactory} returns: the shape the SDK's `createTransport` expects. */
|
|
25
|
+
export interface WebSocketConnection {
|
|
26
|
+
/** The transport the MOQT session runs on. */
|
|
27
|
+
transport: WebSocketMoqtTransport;
|
|
28
|
+
/** Resolves once the WebSocket is open and the peer selected an offered protocol. */
|
|
29
|
+
ready: Promise<void>;
|
|
30
|
+
/** Always `'websocket'`: the upgrade request carries the URL's path and query, as a WebTransport CONNECT does. */
|
|
31
|
+
framing: 'websocket';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Dials `url` as a WebSocket (`https:` becomes `wss:`, path and query unchanged), offering each of `protocols` as the
|
|
35
|
+
* subprotocol `qmux-01.<protocol>`.
|
|
36
|
+
*/
|
|
37
|
+
export type WebSocketTransportFactory = (url: string, protocols: string[]) => WebSocketConnection;
|
|
38
|
+
/**
|
|
39
|
+
* A transport factory for the SDK's `createTransport` option that always connects over QMux over WebSocket, in a
|
|
40
|
+
* browser or in Node:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { connectRelaySubscriber } from '@caprid/relay';
|
|
44
|
+
* import { createWebSocketTransport } from '@caprid/relay-websocket';
|
|
45
|
+
*
|
|
46
|
+
* const subscriber = await connectRelaySubscriber({ url, getToken, createTransport: createWebSocketTransport() });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* The streams share one TCP connection, so a lost packet holds up every stream behind it (head-of-line blocking), and
|
|
50
|
+
* a relay's credentials refusal arrives as a failed WebSocket handshake, which the SDK reports as `TRANSPORT_ERROR`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createWebSocketTransport(): WebSocketTransportFactory;
|
|
53
|
+
/** What one call of a {@link FallbackTransportFactory} returns. */
|
|
54
|
+
export interface FallbackConnection {
|
|
55
|
+
/** The transport the MOQT session runs on, whichever dial won. */
|
|
56
|
+
transport: FallbackTransport;
|
|
57
|
+
/** Resolves once one of the dials is ready and its peer selected a protocol. */
|
|
58
|
+
ready: Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* `'webtransport'` while the WebTransport dial is in progress or once it won, `'websocket'` once the dial fell back.
|
|
61
|
+
* Both carry the path and token in the URL, so the SDK's SETUP is the same either way.
|
|
62
|
+
*/
|
|
63
|
+
readonly framing: FallbackCarrier;
|
|
64
|
+
}
|
|
65
|
+
/** Dials WebTransport, then QMux over WebSocket when that fails; see {@link withWebSocketFallback}. */
|
|
66
|
+
export type FallbackTransportFactory = (url: string, protocols: string[]) => FallbackConnection;
|
|
67
|
+
/**
|
|
68
|
+
* A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first, and falls
|
|
69
|
+
* back to QMux over WebSocket when that handshake fails or takes longer than `handshakeTimeoutMs` (default 4 s). Where
|
|
70
|
+
* the runtime has no usable `WebTransport` (Safari before WebTransport, Node), it dials WebSocket at once. The dials
|
|
71
|
+
* run one after the other, never both at once, and each connection decides afresh.
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { connectRelayPublisher } from '@caprid/relay';
|
|
75
|
+
* import { withWebSocketFallback } from '@caprid/relay-websocket';
|
|
76
|
+
*
|
|
77
|
+
* const publisher = await connectRelayPublisher({ url, getToken, createTransport: withWebSocketFallback() });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function withWebSocketFallback(options?: WebSocketFallbackOptions): FallbackTransportFactory;
|
|
81
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BAAwB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,kBAAkB,CAAC;AAEhG;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,wBAA6B,GAAG,wBAAwB,CAYtG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { assertHandshakeTimeout, FallbackTransport, toWebSocketUrl, } from './fallback.js';
|
|
2
|
+
import { WebSocketTransport } from './transport.js';
|
|
3
|
+
export { WebSocketSessionError } from './errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* A transport factory for the SDK's `createTransport` option that always connects over QMux over WebSocket, in a
|
|
6
|
+
* browser or in Node:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { connectRelaySubscriber } from '@caprid/relay';
|
|
10
|
+
* import { createWebSocketTransport } from '@caprid/relay-websocket';
|
|
11
|
+
*
|
|
12
|
+
* const subscriber = await connectRelaySubscriber({ url, getToken, createTransport: createWebSocketTransport() });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* The streams share one TCP connection, so a lost packet holds up every stream behind it (head-of-line blocking), and
|
|
16
|
+
* a relay's credentials refusal arrives as a failed WebSocket handshake, which the SDK reports as `TRANSPORT_ERROR`.
|
|
17
|
+
*/
|
|
18
|
+
export function createWebSocketTransport() {
|
|
19
|
+
return (url, protocols) => {
|
|
20
|
+
const transport = new WebSocketTransport(toWebSocketUrl(url), protocols);
|
|
21
|
+
return { transport, ready: transport.ready, framing: 'websocket' };
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first, and falls
|
|
26
|
+
* back to QMux over WebSocket when that handshake fails or takes longer than `handshakeTimeoutMs` (default 4 s). Where
|
|
27
|
+
* the runtime has no usable `WebTransport` (Safari before WebTransport, Node), it dials WebSocket at once. The dials
|
|
28
|
+
* run one after the other, never both at once, and each connection decides afresh.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { connectRelayPublisher } from '@caprid/relay';
|
|
32
|
+
* import { withWebSocketFallback } from '@caprid/relay-websocket';
|
|
33
|
+
*
|
|
34
|
+
* const publisher = await connectRelayPublisher({ url, getToken, createTransport: withWebSocketFallback() });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function withWebSocketFallback(options = {}) {
|
|
38
|
+
assertHandshakeTimeout(options.handshakeTimeoutMs);
|
|
39
|
+
return (url, protocols) => {
|
|
40
|
+
const transport = new FallbackTransport(url, protocols, options);
|
|
41
|
+
return {
|
|
42
|
+
transport,
|
|
43
|
+
ready: transport.ready,
|
|
44
|
+
get framing() {
|
|
45
|
+
return transport.carrier ?? 'webtransport';
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,sBAAsB,EAEtB,iBAAiB,EACjB,cAAc,GAEf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAyBpD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;QACxB,MAAM,SAAS,GAAG,IAAI,kBAAkB,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;QACzE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAkBD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAoC,EAAE;IAC1E,sBAAsB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;QACxB,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACjE,OAAO;YACL,SAAS;YACT,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,IAAI,OAAO;gBACT,OAAO,SAAS,CAAC,OAAO,IAAI,cAAc,CAAC;YAC7C,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Turns an error `@moq/qmux` raised on a stream into the one the contract wants (TA-22). */
|
|
2
|
+
export type MapFailure = (error: unknown) => unknown;
|
|
3
|
+
/** Settles, with the error to report, once the session is over (TA-12). */
|
|
4
|
+
export type SessionEnd = Promise<unknown>;
|
|
5
|
+
/** A writable over `inner`, one of `@moq/qmux`'s send streams. */
|
|
6
|
+
export declare function sendWritable(inner: WritableStream<Uint8Array>, mapFailure: MapFailure): WritableStream<Uint8Array>;
|
|
7
|
+
/**
|
|
8
|
+
* A readable over `inner`, one of `@moq/qmux`'s receive streams. It keeps one read of the inner stream outstanding, so a
|
|
9
|
+
* peer reset (TA-19) lands without a read pending: `@moq/qmux` reports one only to a read, after the bytes before it.
|
|
10
|
+
* That holds at most one chunk ahead of the application, which the flow control window already counts as delivered.
|
|
11
|
+
* The session's end errors the readable at once, a chunk held ahead or not (TA-12). Cancelling sends STOP_SENDING with
|
|
12
|
+
* the reason's code and ends the readable (TA-18).
|
|
13
|
+
*/
|
|
14
|
+
export declare function recvReadable(inner: ReadableStream<Uint8Array>, mapFailure: MapFailure, sessionEnd: SessionEnd): ReadableStream<Uint8Array>;
|
|
15
|
+
/** Both halves of one of `@moq/qmux`'s bidirectional streams. */
|
|
16
|
+
export declare function bidirectional(stream: {
|
|
17
|
+
readable: ReadableStream<Uint8Array>;
|
|
18
|
+
writable: WritableStream<Uint8Array>;
|
|
19
|
+
}, mapFailure: MapFailure, sessionEnd: SessionEnd): {
|
|
20
|
+
readable: ReadableStream<Uint8Array>;
|
|
21
|
+
writable: WritableStream<Uint8Array>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=streams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streams.d.ts","sourceRoot":"","sources":["../src/streams.ts"],"names":[],"mappings":"AAcA,6FAA6F;AAC7F,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;AAErD,2EAA2E;AAC3E,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE1C,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAuDlH;AAaD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,EACjC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACrB,cAAc,CAAC,UAAU,CAAC,CAmE5B;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAC3B,MAAM,EAAE;IAAE,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;CAAE,EACtF,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACrB;IAAE,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;CAAE,CAKhF"}
|
package/dist/streams.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHATWG streams over `@moq/qmux`'s stream halves (spec/transport-adapter.md, "Streams").
|
|
3
|
+
*
|
|
4
|
+
* Each half is wrapped rather than handed over as it is, for three rules:
|
|
5
|
+
*
|
|
6
|
+
* - A reset or a stop carries the code TA-17 gives, checked here: `@moq/qmux` wraps any number to 32 bits.
|
|
7
|
+
* - A send stream's pending write or close settles as soon as the stream is aborted or fails (TA-16, TA-20).
|
|
8
|
+
* WHATWG holds a sink's `abort()` until a pending write settles, so a write blocked on flow control would otherwise
|
|
9
|
+
* hold the abort, and the write slot above it, until the peer granted credit.
|
|
10
|
+
* - A failure that is not the stream's own is reported as a session error once the session is over (TA-12, TA-22):
|
|
11
|
+
* `@moq/qmux` fails a stream's pending operations with a plain `Error` when the session ends.
|
|
12
|
+
*/
|
|
13
|
+
import { isStreamError, resetReason } from './errors.js';
|
|
14
|
+
/** A writable over `inner`, one of `@moq/qmux`'s send streams. */
|
|
15
|
+
export function sendWritable(inner, mapFailure) {
|
|
16
|
+
const writer = inner.getWriter();
|
|
17
|
+
let fail;
|
|
18
|
+
// Settles the pending step at once when the stream is aborted or fails; never resolves.
|
|
19
|
+
const failed = new Promise((_, reject) => {
|
|
20
|
+
fail = reject;
|
|
21
|
+
});
|
|
22
|
+
failed.catch(() => { });
|
|
23
|
+
let aborted = false;
|
|
24
|
+
const abortOnce = (reason) => {
|
|
25
|
+
if (aborted)
|
|
26
|
+
return;
|
|
27
|
+
aborted = true;
|
|
28
|
+
// The reset goes out once `@moq/qmux` has finished a write it already started (Known deviations).
|
|
29
|
+
writer.abort(resetReason(reason)).catch(() => { });
|
|
30
|
+
};
|
|
31
|
+
const pending = (step) => Promise.race([
|
|
32
|
+
step.catch(async (error) => {
|
|
33
|
+
// A peer stop fails a write blocked on credit with a plain error just before the stream reports the stop.
|
|
34
|
+
if (!isStreamError(error)) {
|
|
35
|
+
const stored = await errorOf(writer.closed);
|
|
36
|
+
if (isStreamError(stored))
|
|
37
|
+
throw stored;
|
|
38
|
+
}
|
|
39
|
+
throw mapFailure(error);
|
|
40
|
+
}),
|
|
41
|
+
failed,
|
|
42
|
+
]);
|
|
43
|
+
return new WritableStream({
|
|
44
|
+
start(controller) {
|
|
45
|
+
controller.signal.addEventListener('abort', () => {
|
|
46
|
+
fail(controller.signal.reason);
|
|
47
|
+
abortOnce(controller.signal.reason);
|
|
48
|
+
}, { once: true });
|
|
49
|
+
// A peer STOP_SENDING, or the session's end, errors the stream even when nothing is in flight (TA-20, TA-12).
|
|
50
|
+
writer.closed.catch((error) => {
|
|
51
|
+
if (aborted)
|
|
52
|
+
return;
|
|
53
|
+
const mapped = mapFailure(error);
|
|
54
|
+
fail(mapped);
|
|
55
|
+
controller.error(mapped);
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
write(chunk) {
|
|
59
|
+
if (!(chunk instanceof Uint8Array))
|
|
60
|
+
throw new TypeError('a WebSocket transport stream takes Uint8Array chunks');
|
|
61
|
+
return pending(writer.write(chunk));
|
|
62
|
+
},
|
|
63
|
+
close() {
|
|
64
|
+
return pending(writer.close());
|
|
65
|
+
},
|
|
66
|
+
abort: abortOnce,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** The error `promise` rejected with, if it did within a macrotask; `undefined` otherwise. */
|
|
70
|
+
function errorOf(promise) {
|
|
71
|
+
return Promise.race([
|
|
72
|
+
promise.then(() => undefined, (error) => error),
|
|
73
|
+
new Promise((resolve) => setTimeout(resolve, 0)),
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A readable over `inner`, one of `@moq/qmux`'s receive streams. It keeps one read of the inner stream outstanding, so a
|
|
78
|
+
* peer reset (TA-19) lands without a read pending: `@moq/qmux` reports one only to a read, after the bytes before it.
|
|
79
|
+
* That holds at most one chunk ahead of the application, which the flow control window already counts as delivered.
|
|
80
|
+
* The session's end errors the readable at once, a chunk held ahead or not (TA-12). Cancelling sends STOP_SENDING with
|
|
81
|
+
* the reason's code and ends the readable (TA-18).
|
|
82
|
+
*/
|
|
83
|
+
export function recvReadable(inner, mapFailure, sessionEnd) {
|
|
84
|
+
const reader = inner.getReader();
|
|
85
|
+
let ended = false;
|
|
86
|
+
let buffered;
|
|
87
|
+
let demand;
|
|
88
|
+
let controller;
|
|
89
|
+
const settleDemand = () => {
|
|
90
|
+
const waiting = demand;
|
|
91
|
+
demand = undefined;
|
|
92
|
+
waiting?.();
|
|
93
|
+
};
|
|
94
|
+
const fail = (error) => {
|
|
95
|
+
if (ended)
|
|
96
|
+
return;
|
|
97
|
+
ended = true;
|
|
98
|
+
// Bytes not yet delivered may be discarded on a reset (RFC 9000 §3.2).
|
|
99
|
+
buffered = undefined;
|
|
100
|
+
try {
|
|
101
|
+
controller.error(mapFailure(error));
|
|
102
|
+
}
|
|
103
|
+
catch { }
|
|
104
|
+
settleDemand();
|
|
105
|
+
};
|
|
106
|
+
const deliver = () => {
|
|
107
|
+
if (!buffered || !demand)
|
|
108
|
+
return;
|
|
109
|
+
const chunk = buffered;
|
|
110
|
+
buffered = undefined;
|
|
111
|
+
controller.enqueue(chunk);
|
|
112
|
+
settleDemand();
|
|
113
|
+
readAhead();
|
|
114
|
+
};
|
|
115
|
+
const readAhead = () => {
|
|
116
|
+
reader.read().then((result) => {
|
|
117
|
+
if (ended)
|
|
118
|
+
return;
|
|
119
|
+
if (result.done) {
|
|
120
|
+
ended = true;
|
|
121
|
+
controller.close();
|
|
122
|
+
settleDemand();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
buffered = result.value;
|
|
126
|
+
deliver();
|
|
127
|
+
}, fail);
|
|
128
|
+
};
|
|
129
|
+
return new ReadableStream({
|
|
130
|
+
start(started) {
|
|
131
|
+
controller = started;
|
|
132
|
+
readAhead();
|
|
133
|
+
sessionEnd.then(fail);
|
|
134
|
+
},
|
|
135
|
+
pull() {
|
|
136
|
+
if (ended)
|
|
137
|
+
return;
|
|
138
|
+
return new Promise((resolve) => {
|
|
139
|
+
demand = resolve;
|
|
140
|
+
deliver();
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
async cancel(reason) {
|
|
144
|
+
ended = true;
|
|
145
|
+
buffered = undefined;
|
|
146
|
+
settleDemand();
|
|
147
|
+
await reader.cancel(resetReason(reason));
|
|
148
|
+
},
|
|
149
|
+
}, { highWaterMark: 0 });
|
|
150
|
+
}
|
|
151
|
+
/** Both halves of one of `@moq/qmux`'s bidirectional streams. */
|
|
152
|
+
export function bidirectional(stream, mapFailure, sessionEnd) {
|
|
153
|
+
return {
|
|
154
|
+
readable: recvReadable(stream.readable, mapFailure, sessionEnd),
|
|
155
|
+
writable: sendWritable(stream.writable, mapFailure),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=streams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streams.js","sourceRoot":"","sources":["../src/streams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQzD,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,KAAiC,EAAE,UAAsB;IACpF,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACjC,IAAI,IAA+B,CAAC;IACpC,wFAAwF;IACxF,MAAM,MAAM,GAAG,IAAI,OAAO,CAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC9C,IAAI,GAAG,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACvB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,SAAS,GAAG,CAAC,MAAe,EAAQ,EAAE;QAC1C,IAAI,OAAO;YAAE,OAAO;QACpB,OAAO,GAAG,IAAI,CAAC;QACf,kGAAkG;QAClG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,C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E,aAAa,EAAE,CAAC,EAAE,CACrB,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,aAAa,CAC3B,MAAsF,EACtF,UAAsB,EACtB,UAAsB;IAEtB,OAAO;QACL,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC;QAC/D,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;KACpD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** A `MoqtTransport` over one QMux-over-WebSocket dial (spec/transport-adapter.md, "Session lifetime"). */
|
|
2
|
+
import type { BidirectionalStreamLike, MoqtSendStreamOptions, MoqtTransport } from '@caprid/moq-core';
|
|
3
|
+
import { type CloseInfo } from './errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* The QMux wire format every MOQT protocol is offered on. moq-relay pairs `moqt-18` and newer only with `qmux-01`
|
|
6
|
+
* (`QMUX01_ONLY_ALPNS` in `rs/moq-relay/src/websocket.rs`), so each protocol goes out as `qmux-01.<protocol>`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const QMUX_VERSION = "qmux-01";
|
|
9
|
+
/** The transport for one dial. `ready` resolves once the peer selected a protocol; closing first cancels the dial. */
|
|
10
|
+
export declare class WebSocketTransport implements MoqtTransport {
|
|
11
|
+
#private;
|
|
12
|
+
readonly incomingUnidirectionalStreams: ReadableStream<ReadableStream<Uint8Array>>;
|
|
13
|
+
readonly incomingBidirectionalStreams: ReadableStream<BidirectionalStreamLike>;
|
|
14
|
+
/** Resolves on an application close from either end and rejects with a session error otherwise (TA-9). */
|
|
15
|
+
readonly closed: Promise<CloseInfo>;
|
|
16
|
+
/** Resolves once the session is established and the peer selected an offered protocol (TA-7). */
|
|
17
|
+
readonly ready: Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* @param url The `wss:` (or `ws:`) URL, path and query included: the relay reads both from the upgrade request.
|
|
20
|
+
* @param protocols The MOQT protocols to offer, in preference order, each as `qmux-01.<protocol>`.
|
|
21
|
+
*/
|
|
22
|
+
constructor(url: string, protocols: readonly string[]);
|
|
23
|
+
/** The protocol the peer selected, without its `qmux-01.` prefix (TA-8); empty until `ready` resolves. */
|
|
24
|
+
get protocol(): string;
|
|
25
|
+
/** QMux schedules stream data by `sendOrder` as WebTransport does: the highest first, round-robin among equals. */
|
|
26
|
+
createUnidirectionalStream(options?: MoqtSendStreamOptions): Promise<WritableStream<Uint8Array>>;
|
|
27
|
+
createBidirectionalStream(): Promise<BidirectionalStreamLike>;
|
|
28
|
+
/** Close with a QMux APPLICATION_CLOSE (TA-10); before `ready`, cancel the dial instead (TA-11). */
|
|
29
|
+
close({ closeCode, reason }?: {
|
|
30
|
+
closeCode?: number;
|
|
31
|
+
reason?: string;
|
|
32
|
+
}): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAE3G,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtG,OAAO,EAAE,KAAK,SAAS,EAAwC,MAAM,aAAa,CAAC;AAGnF;;;GAGG;AACH,eAAO,MAAM,YAAY,YAAY,CAAC;AAsBtC,sHAAsH;AACtH,qBAAa,kBAAmB,YAAW,aAAa;;IACtD,QAAQ,CAAC,6BAA6B,EAAE,cAAc,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IACnF,QAAQ,CAAC,4BAA4B,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAC;IAC/E,0GAA0G;IAC1G,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,iGAAiG;IACjG,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAgB9B;;;OAGG;gBACS,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE;IAkFrD,0GAA0G;IAC1G,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,mHAAmH;IAC7G,0BAA0B,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAShG,yBAAyB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IASnE,oGAAoG;IACpG,KAAK,CAAC,EAAE,SAAa,EAAE,MAAW,EAAE,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,IAAI;CAwE1F"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/** A `MoqtTransport` over one QMux-over-WebSocket dial (spec/transport-adapter.md, "Session lifetime"). */
|
|
2
|
+
import Session from '@moq/qmux';
|
|
3
|
+
import { isStreamError, WebSocketSessionError } from './errors.js';
|
|
4
|
+
import { bidirectional, recvReadable, sendWritable } from './streams.js';
|
|
5
|
+
/**
|
|
6
|
+
* The QMux wire format every MOQT protocol is offered on. moq-relay pairs `moqt-18` and newer only with `qmux-01`
|
|
7
|
+
* (`QMUX01_ONLY_ALPNS` in `rs/moq-relay/src/websocket.rs`), so each protocol goes out as `qmux-01.<protocol>`.
|
|
8
|
+
*/
|
|
9
|
+
export const QMUX_VERSION = 'qmux-01';
|
|
10
|
+
/**
|
|
11
|
+
* The longest close reason sent, in UTF-8 bytes. `@moq/qmux` refuses to close at all when the APPLICATION_CLOSE frame
|
|
12
|
+
* would not fit one QMux record (16382 bytes by default), so a longer reason is cut short here, as QUIC's own close
|
|
13
|
+
* cuts it to a packet.
|
|
14
|
+
*/
|
|
15
|
+
const MAX_REASON_BYTES = 1024;
|
|
16
|
+
/** `reason`, cut at a character boundary to at most {@link MAX_REASON_BYTES} UTF-8 bytes. */
|
|
17
|
+
function boundedReason(reason) {
|
|
18
|
+
const bytes = new TextEncoder().encode(reason);
|
|
19
|
+
if (bytes.byteLength <= MAX_REASON_BYTES)
|
|
20
|
+
return reason;
|
|
21
|
+
// A cut inside a character leaves a replacement character, which the trailing slice drops.
|
|
22
|
+
const cut = new TextDecoder().decode(bytes.subarray(0, MAX_REASON_BYTES));
|
|
23
|
+
return cut.endsWith('\uFFFD') ? cut.slice(0, -1) : cut;
|
|
24
|
+
}
|
|
25
|
+
function messageOf(error) {
|
|
26
|
+
return error instanceof Error ? error.message : String(error);
|
|
27
|
+
}
|
|
28
|
+
/** The transport for one dial. `ready` resolves once the peer selected a protocol; closing first cancels the dial. */
|
|
29
|
+
export class WebSocketTransport {
|
|
30
|
+
incomingUnidirectionalStreams;
|
|
31
|
+
incomingBidirectionalStreams;
|
|
32
|
+
/** Resolves on an application close from either end and rejects with a session error otherwise (TA-9). */
|
|
33
|
+
closed;
|
|
34
|
+
/** Resolves once the session is established and the peer selected an offered protocol (TA-7). */
|
|
35
|
+
ready;
|
|
36
|
+
#session;
|
|
37
|
+
#protocol = '';
|
|
38
|
+
#established = false;
|
|
39
|
+
#closeRequested;
|
|
40
|
+
/** Set once the session is over, by either end: a stream failure after it is a session error (TA-12). */
|
|
41
|
+
#ended = false;
|
|
42
|
+
/** The peer's application close, when it closed the session (TA-24). */
|
|
43
|
+
#peerClose;
|
|
44
|
+
/** Set once the session ended by an application close from either end (TA-9). */
|
|
45
|
+
#cleanEnd = false;
|
|
46
|
+
#fail;
|
|
47
|
+
/** Settles once the session is over, by either end, with the error a receive stream still open reports (TA-12). */
|
|
48
|
+
#sessionEnd;
|
|
49
|
+
/**
|
|
50
|
+
* @param url The `wss:` (or `ws:`) URL, path and query included: the relay reads both from the upgrade request.
|
|
51
|
+
* @param protocols The MOQT protocols to offer, in preference order, each as `qmux-01.<protocol>`.
|
|
52
|
+
*/
|
|
53
|
+
constructor(url, protocols) {
|
|
54
|
+
const offered = [...protocols];
|
|
55
|
+
this.#session = new Session(url, {
|
|
56
|
+
protocols: offered,
|
|
57
|
+
versions: Object.fromEntries(offered.map((protocol) => [protocol, QMUX_VERSION])),
|
|
58
|
+
// Offer only the MOQT protocols: a bare `qmux-01` or `webtransport` would let the relay pick moq-lite in SETUP.
|
|
59
|
+
requireProtocol: true,
|
|
60
|
+
});
|
|
61
|
+
const session = this.#session;
|
|
62
|
+
let resolveReady;
|
|
63
|
+
let rejectReady;
|
|
64
|
+
this.ready = new Promise((resolve, reject) => {
|
|
65
|
+
resolveReady = resolve;
|
|
66
|
+
rejectReady = reject;
|
|
67
|
+
});
|
|
68
|
+
this.ready.catch(() => { });
|
|
69
|
+
let resolveClosed;
|
|
70
|
+
let rejectClosed;
|
|
71
|
+
this.closed = new Promise((resolve, reject) => {
|
|
72
|
+
resolveClosed = resolve;
|
|
73
|
+
rejectClosed = reject;
|
|
74
|
+
});
|
|
75
|
+
this.closed.catch(() => { });
|
|
76
|
+
this.#fail = (error) => {
|
|
77
|
+
rejectReady(error);
|
|
78
|
+
rejectClosed(error);
|
|
79
|
+
};
|
|
80
|
+
// Registered before any stream exists, so the session's end is known by the time a stream fails because of it.
|
|
81
|
+
this.#sessionEnd = session.closed.then((info) => {
|
|
82
|
+
this.#ended = true;
|
|
83
|
+
this.#cleanEnd = true;
|
|
84
|
+
if (!this.#closeRequested)
|
|
85
|
+
this.#peerClose = { closeCode: info.closeCode ?? 0, reason: info.reason ?? '' };
|
|
86
|
+
return this.#sessionError(new Error('the session closed'));
|
|
87
|
+
}, (error) => {
|
|
88
|
+
this.#ended = true;
|
|
89
|
+
return this.#sessionError(error);
|
|
90
|
+
});
|
|
91
|
+
session.ready.then(() => {
|
|
92
|
+
if (this.#closeRequested)
|
|
93
|
+
return; // close() already failed ready and closed (TA-11).
|
|
94
|
+
// The WebSocket handshake fails on a selection that was not offered; one that selects nothing still opens.
|
|
95
|
+
const selected = session.protocol;
|
|
96
|
+
if (!offered.includes(selected)) {
|
|
97
|
+
session.close({ closeCode: 0, reason: '' });
|
|
98
|
+
this.#fail(new WebSocketSessionError(selected
|
|
99
|
+
? `the peer selected ${JSON.stringify(selected)}, which was not offered`
|
|
100
|
+
: 'the peer selected no protocol'));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.#protocol = selected;
|
|
104
|
+
this.#established = true;
|
|
105
|
+
resolveReady();
|
|
106
|
+
session.closed.then((info) => resolveClosed(this.#closeRequested ?? { closeCode: info.closeCode ?? 0, reason: info.reason ?? '' }), (error) => rejectClosed(this.#sessionError(error)));
|
|
107
|
+
}, (error) => {
|
|
108
|
+
if (this.#closeRequested)
|
|
109
|
+
return;
|
|
110
|
+
this.#fail(new WebSocketSessionError(`the WebSocket dial failed: ${messageOf(error)}`, { cause: error }));
|
|
111
|
+
});
|
|
112
|
+
this.incomingUnidirectionalStreams = this.#incoming(session.incomingUnidirectionalStreams, (stream) => recvReadable(stream, this.#mapFailure, this.#sessionEnd));
|
|
113
|
+
this.incomingBidirectionalStreams = this.#incoming(session.incomingBidirectionalStreams, (stream) => bidirectional(stream, this.#mapFailure, this.#sessionEnd));
|
|
114
|
+
}
|
|
115
|
+
/** The protocol the peer selected, without its `qmux-01.` prefix (TA-8); empty until `ready` resolves. */
|
|
116
|
+
get protocol() {
|
|
117
|
+
return this.#protocol;
|
|
118
|
+
}
|
|
119
|
+
/** QMux schedules stream data by `sendOrder` as WebTransport does: the highest first, round-robin among equals. */
|
|
120
|
+
async createUnidirectionalStream(options) {
|
|
121
|
+
await this.ready;
|
|
122
|
+
try {
|
|
123
|
+
return sendWritable(await this.#session.createUnidirectionalStream(options), this.#mapFailure);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
throw this.#mapFailure(error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async createBidirectionalStream() {
|
|
130
|
+
await this.ready;
|
|
131
|
+
try {
|
|
132
|
+
return bidirectional(await this.#session.createBidirectionalStream(), this.#mapFailure, this.#sessionEnd);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
throw this.#mapFailure(error);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** Close with a QMux APPLICATION_CLOSE (TA-10); before `ready`, cancel the dial instead (TA-11). */
|
|
139
|
+
close({ closeCode = 0, reason = '' } = {}) {
|
|
140
|
+
if (this.#closeRequested)
|
|
141
|
+
return;
|
|
142
|
+
// An application close code is a 32-bit value, as on a WebTransport session.
|
|
143
|
+
const code = Number.isInteger(closeCode) && closeCode >= 0 && closeCode <= 0xffff_ffff ? closeCode : 0;
|
|
144
|
+
const bounded = boundedReason(String(reason));
|
|
145
|
+
this.#closeRequested = { closeCode: code, reason: bounded };
|
|
146
|
+
if (!this.#established)
|
|
147
|
+
this.#fail(new WebSocketSessionError('the dial was cancelled'));
|
|
148
|
+
try {
|
|
149
|
+
this.#session.close({ closeCode: code, reason: bounded });
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// The session refuses nothing once it has ended, but close() must never throw (TA-10).
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** A stream failure as the contract reports it: the stream's own as it is, anything else after the end as a session error. */
|
|
156
|
+
#mapFailure = (error) => {
|
|
157
|
+
if (isStreamError(error) || !this.#ended)
|
|
158
|
+
return error;
|
|
159
|
+
return this.#sessionError(error);
|
|
160
|
+
};
|
|
161
|
+
#sessionError(error) {
|
|
162
|
+
if (error instanceof WebSocketSessionError)
|
|
163
|
+
return error;
|
|
164
|
+
const close = this.#peerClose;
|
|
165
|
+
const message = close
|
|
166
|
+
? `the peer closed the session (code ${close.closeCode}${close.reason ? `, ${close.reason}` : ''})`
|
|
167
|
+
: `the WebSocket session ended: ${messageOf(error)}`;
|
|
168
|
+
return new WebSocketSessionError(message, { cause: error, close });
|
|
169
|
+
}
|
|
170
|
+
/** Streams the peer opens. The readable closes after a clean end and errors otherwise (TA-12), with no read pending. */
|
|
171
|
+
#incoming(inner, wrap) {
|
|
172
|
+
const reader = inner.getReader();
|
|
173
|
+
return new ReadableStream({
|
|
174
|
+
start: (controller) => {
|
|
175
|
+
// Either throws once the readable already ended, which needs nothing more.
|
|
176
|
+
reader.closed.then(() => {
|
|
177
|
+
try {
|
|
178
|
+
controller.close();
|
|
179
|
+
}
|
|
180
|
+
catch { }
|
|
181
|
+
}, (error) => {
|
|
182
|
+
try {
|
|
183
|
+
// `@moq/qmux` errors its incoming queues after a peer's application close too.
|
|
184
|
+
if (this.#cleanEnd)
|
|
185
|
+
controller.close();
|
|
186
|
+
else
|
|
187
|
+
controller.error(this.#sessionError(error));
|
|
188
|
+
}
|
|
189
|
+
catch { }
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
pull: async (controller) => {
|
|
193
|
+
let result;
|
|
194
|
+
try {
|
|
195
|
+
result = await reader.read();
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return; // `start` errors the readable as the inner one errors.
|
|
199
|
+
}
|
|
200
|
+
if (result.done)
|
|
201
|
+
return;
|
|
202
|
+
try {
|
|
203
|
+
controller.enqueue(wrap(result.value));
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
// The readable was cancelled while the stream arrived; the session is going with it.
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
cancel: async (reason) => {
|
|
210
|
+
await reader.cancel(reason);
|
|
211
|
+
},
|
|
212
|
+
}, { highWaterMark: 0 });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAG3G,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,EAAkB,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,EAAE,aAAa,EAAmB,YAAY,EAAmB,YAAY,EAAE,MAAM,cAAc,CAAC;AAE3G;;;GAGG;AACH,M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C,CAAC;oBACnD,CAAC;oBAAC,MAAM,CAAC,CAAA,CAAC;gBACZ,CAAC,CACF,CAAC;YACJ,CAAC;YACD,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;gBACzB,IAAI,MAAuC,CAAC;gBAC5C,IAAI,CAAC;oBACH,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC/B,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,CAAC,uDAAuD;gBACjE,CAAC;gBACD,IAAI,MAAM,CAAC,IAAI;oBAAE,OAAO;gBACxB,IAAI,CAAC;oBACH,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBACzC,CAAC;gBAAC,MAAM,CAAC;oBACP,qFAAqF;gBACvF,CAAC;YACH,CAAC;YACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;gBACvB,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9B,CAAC;SACF,EACD,EAAE,aAAa,EAAE,CAAC,EAAE,CACrB,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caprid/relay-websocket",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "QMux-over-WebSocket transport adapter for the Relay SDK, for networks and browsers without WebTransport",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/caprids/relay-sdks.git",
|
|
9
|
+
"directory": "ts/packages/relay-websocket"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@moq/qmux": "0.3.3",
|
|
25
|
+
"@caprid/moq-core": "0.1.0"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=24"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p tsconfig.json"
|
|
35
|
+
}
|
|
6
36
|
}
|