@caprid/relay-websocket 0.2.0 → 0.3.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/README.md +8 -6
- package/dist/fallback.d.ts +20 -15
- package/dist/fallback.d.ts.map +1 -1
- package/dist/fallback.js +126 -81
- package/dist/fallback.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Pass one of its factories as the SDK's `createTransport`. Build it once and reus
|
|
|
20
20
|
import { connectRelaySubscriber } from '@caprid/relay';
|
|
21
21
|
import { createWebSocketTransport, withWebSocketFallback } from '@caprid/relay-websocket';
|
|
22
22
|
|
|
23
|
-
// WebTransport first; WebSocket
|
|
23
|
+
// WebTransport first; WebSocket races it once WebTransport has had 250 ms.
|
|
24
24
|
const subscriber = await connectRelaySubscriber({ url, getToken, createTransport: withWebSocketFallback() });
|
|
25
25
|
|
|
26
26
|
// Always WebSocket.
|
|
@@ -30,11 +30,13 @@ const other = await connectRelaySubscriber({ url, getToken, createTransport: cre
|
|
|
30
30
|
- `createWebSocketTransport()` dials the endpoint's `wss:` URL and offers `qmux-01.moqt-22`, then `qmux-01.moqt-20`.
|
|
31
31
|
`https:` becomes `wss:` with the path and query unchanged, so the token travels in the upgrade request. The factory
|
|
32
32
|
declares `framing: 'websocket'`.
|
|
33
|
-
- `withWebSocketFallback({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
- `withWebSocketFallback({ webSocketDelayMs, onFallback })` dials the runtime's `WebTransport` first. If that
|
|
34
|
+
handshake has not completed within `webSocketDelayMs` (default 250, as Happy Eyeballs), it dials WebSocket alongside
|
|
35
|
+
it; a WebTransport handshake that fails sooner starts the WebSocket at once. The first ready carries the session and
|
|
36
|
+
the other dial is closed. Where the runtime has no usable `WebTransport`, as in Node or a Safari without it, it dials
|
|
37
|
+
WebSocket at once. The adapter calls `onFallback(reason)` each time a connection ends up on WebSocket, and every
|
|
38
|
+
connection decides afresh. After `ready`, the factory's `framing` and the transport's `carrier` say which transport
|
|
39
|
+
won.
|
|
38
40
|
|
|
39
41
|
## What differs from WebTransport
|
|
40
42
|
|
package/dist/fallback.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* WebTransport first, then QMux over WebSocket: the fallback policy (spec/behavior.md, "Transport
|
|
3
|
-
* transport stands for whichever dial wins, so the SDK's connect call sees a single factory.
|
|
2
|
+
* WebTransport first, then QMux over WebSocket racing it: the fallback policy (spec/behavior.md, "Transport
|
|
3
|
+
* fallback"). One transport stands for whichever dial wins, so the SDK's connect call sees a single factory.
|
|
4
4
|
*/
|
|
5
5
|
import type { BidirectionalStreamLike, MoqtSendStreamOptions, MoqtTransport } from '@caprid/moq-core';
|
|
6
6
|
import { type CloseInfo } from './errors.js';
|
|
@@ -9,23 +9,28 @@ export type FallbackCarrier = 'webtransport' | 'websocket';
|
|
|
9
9
|
/** Options for {@link withWebSocketFallback}. */
|
|
10
10
|
export interface WebSocketFallbackOptions {
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* The WebTransport dial's head start, in milliseconds: if its handshake has not completed by then, the WebSocket dial
|
|
13
|
+
* starts too and the first to be ready carries the session. Default 250, the Connection Attempt Delay of Happy
|
|
14
|
+
* Eyeballs (RFC 8305). 0 starts both dials at once. A WebTransport handshake that fails sooner starts the WebSocket
|
|
15
|
+
* dial straight away.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
webSocketDelayMs?: number;
|
|
17
18
|
/**
|
|
18
|
-
* Called once when a
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Called once when a connection ends up on WebSocket, with why WebTransport was not used: its handshake failed, the
|
|
20
|
+
* WebSocket was ready first (both an error), or the runtime has no usable `WebTransport` (`undefined`). For logging;
|
|
21
|
+
* it cannot change the outcome.
|
|
21
22
|
*/
|
|
22
23
|
onFallback?: (reason: unknown) => void;
|
|
23
24
|
}
|
|
24
|
-
/** The handshake timeout `value` gives, 4 s when it is undefined; a TypeError or RangeError for one a timer cannot hold. */
|
|
25
|
-
export declare function assertHandshakeTimeout(value: unknown): number;
|
|
26
25
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* The WebSocket delay the options give, 250 ms when unset; a TypeError or RangeError for one a timer cannot hold, or
|
|
27
|
+
* for `handshakeTimeoutMs`, which it replaced.
|
|
28
|
+
*/
|
|
29
|
+
export declare function assertFallbackOptions(options: WebSocketFallbackOptions): number;
|
|
30
|
+
/**
|
|
31
|
+
* A transport that dials WebTransport and, unless that is ready within the WebSocket delay, QMux over WebSocket
|
|
32
|
+
* alongside it: the first ready carries the session and the other is closed. Before `ready` it stands in for the dials
|
|
33
|
+
* in progress; after, it is the winner's.
|
|
29
34
|
*/
|
|
30
35
|
export declare class FallbackTransport implements MoqtTransport {
|
|
31
36
|
#private;
|
|
@@ -38,13 +43,13 @@ export declare class FallbackTransport implements MoqtTransport {
|
|
|
38
43
|
/** The winner's incoming bidirectional streams. */
|
|
39
44
|
readonly incomingBidirectionalStreams: ReadableStream<BidirectionalStreamLike>;
|
|
40
45
|
constructor(url: string, protocols: readonly string[], options?: WebSocketFallbackOptions);
|
|
41
|
-
/** The transport the session runs on
|
|
46
|
+
/** The transport the session runs on; undefined until `ready`. */
|
|
42
47
|
get carrier(): FallbackCarrier | undefined;
|
|
43
48
|
/** The protocol the winner's peer selected (TA-8); empty until `ready` resolves. */
|
|
44
49
|
get protocol(): string;
|
|
45
50
|
createUnidirectionalStream(options?: MoqtSendStreamOptions): Promise<WritableStream<Uint8Array>>;
|
|
46
51
|
createBidirectionalStream(): Promise<BidirectionalStreamLike>;
|
|
47
|
-
/** Close the winner (TA-10); before `ready`, cancel
|
|
52
|
+
/** Close the winner (TA-10); before `ready`, cancel every dial in progress (TA-11). */
|
|
48
53
|
close(info?: {
|
|
49
54
|
closeCode?: number;
|
|
50
55
|
reason?: string;
|
package/dist/fallback.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../src/fallback.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtG,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,aAAa,CAAC;AAMpE,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,WAAW,CAAC;AAE3D,iDAAiD;AACjD,MAAM,WAAW,wBAAwB;IACvC
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../src/fallback.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtG,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,aAAa,CAAC;AAMpE,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,WAAW,CAAC;AAE3D,iDAAiD;AACjD,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;AAQD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAW/E;AAcD;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,aAAa;;IACrD,gHAAgH;IAChH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,oDAAoD;IACpD,QAAQ,CAAC,6BAA6B,EAAE,cAAc,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IACnF,mDAAmD;IACnD,QAAQ,CAAC,4BAA4B,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAC;gBAUnE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,GAAE,wBAA6B;IAY7F,kEAAkE;IAClE,IAAI,OAAO,IAAI,eAAe,GAAG,SAAS,CAEzC;IAED,oFAAoF;IACpF,IAAI,QAAQ,IAAI,MAAM,CAErB;IAEK,0BAA0B,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAIhG,yBAAyB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAInE,uFAAuF;IACvF,KAAK,CAAC,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,IAAI;CAiKhE;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYlD"}
|
package/dist/fallback.js
CHANGED
|
@@ -6,22 +6,37 @@ function usableWebTransport() {
|
|
|
6
6
|
return undefined;
|
|
7
7
|
return 'protocol' in WebTransport.prototype ? WebTransport : undefined;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The WebSocket delay the options give, 250 ms when unset; a TypeError or RangeError for one a timer cannot hold, or
|
|
11
|
+
* for `handshakeTimeoutMs`, which it replaced.
|
|
12
|
+
*/
|
|
13
|
+
export function assertFallbackOptions(options) {
|
|
14
|
+
if ('handshakeTimeoutMs' in options)
|
|
15
|
+
throw new TypeError('handshakeTimeoutMs was replaced by webSocketDelayMs: the WebSocket dial now races WebTransport');
|
|
16
|
+
const value = options.webSocketDelayMs;
|
|
11
17
|
if (value === undefined)
|
|
12
|
-
return
|
|
18
|
+
return 250;
|
|
13
19
|
if (typeof value !== 'number')
|
|
14
|
-
throw new TypeError('
|
|
15
|
-
if (!Number.isFinite(value) || value
|
|
16
|
-
throw new RangeError('
|
|
20
|
+
throw new TypeError('webSocketDelayMs must be a number of milliseconds');
|
|
21
|
+
if (!Number.isFinite(value) || value < 0 || value > 2_147_483_647)
|
|
22
|
+
throw new RangeError('webSocketDelayMs must be between 0 and 2147483647 milliseconds');
|
|
17
23
|
return value;
|
|
18
24
|
}
|
|
19
|
-
class
|
|
20
|
-
name = '
|
|
25
|
+
class WebTransportOutpaced extends Error {
|
|
26
|
+
name = 'WebTransportOutpaced';
|
|
27
|
+
}
|
|
28
|
+
function closeQuietly(transport, info) {
|
|
29
|
+
try {
|
|
30
|
+
transport.close(info);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// A failed handshake may leave a transport that already refuses close().
|
|
34
|
+
}
|
|
21
35
|
}
|
|
22
36
|
/**
|
|
23
|
-
* A transport that dials WebTransport and
|
|
24
|
-
*
|
|
37
|
+
* A transport that dials WebTransport and, unless that is ready within the WebSocket delay, QMux over WebSocket
|
|
38
|
+
* alongside it: the first ready carries the session and the other is closed. Before `ready` it stands in for the dials
|
|
39
|
+
* in progress; after, it is the winner's.
|
|
25
40
|
*/
|
|
26
41
|
export class FallbackTransport {
|
|
27
42
|
/** Resolves once one of the dials is ready; rejects with the WebSocket dial's failure, or when closed first. */
|
|
@@ -32,14 +47,16 @@ export class FallbackTransport {
|
|
|
32
47
|
incomingUnidirectionalStreams;
|
|
33
48
|
/** The winner's incoming bidirectional streams. */
|
|
34
49
|
incomingBidirectionalStreams;
|
|
35
|
-
|
|
36
|
-
#
|
|
50
|
+
/** The dials still in progress. */
|
|
51
|
+
#dials = new Set();
|
|
37
52
|
#winner;
|
|
38
|
-
#
|
|
53
|
+
#carrier;
|
|
54
|
+
/** Ends the race without a winner; unset once it has ended. */
|
|
55
|
+
#cancel;
|
|
39
56
|
#won;
|
|
40
57
|
constructor(url, protocols, options = {}) {
|
|
41
|
-
const
|
|
42
|
-
this.#won = this.#
|
|
58
|
+
const delayMs = assertFallbackOptions(options);
|
|
59
|
+
this.#won = this.#race(url, protocols, delayMs, options.onFallback);
|
|
43
60
|
this.#won.catch(() => { });
|
|
44
61
|
this.ready = this.#won.then(() => undefined);
|
|
45
62
|
this.closed = this.#won.then((winner) => winner.closed);
|
|
@@ -47,7 +64,7 @@ export class FallbackTransport {
|
|
|
47
64
|
this.incomingUnidirectionalStreams = this.#incoming((winner) => winner.incomingUnidirectionalStreams);
|
|
48
65
|
this.incomingBidirectionalStreams = this.#incoming((winner) => winner.incomingBidirectionalStreams);
|
|
49
66
|
}
|
|
50
|
-
/** The transport the session runs on
|
|
67
|
+
/** The transport the session runs on; undefined until `ready`. */
|
|
51
68
|
get carrier() {
|
|
52
69
|
return this.#carrier;
|
|
53
70
|
}
|
|
@@ -61,77 +78,105 @@ export class FallbackTransport {
|
|
|
61
78
|
async createBidirectionalStream() {
|
|
62
79
|
return (await this.#won).createBidirectionalStream();
|
|
63
80
|
}
|
|
64
|
-
/** Close the winner (TA-10); before `ready`, cancel
|
|
81
|
+
/** Close the winner (TA-10); before `ready`, cancel every dial in progress (TA-11). */
|
|
65
82
|
close(info = {}) {
|
|
66
|
-
if (
|
|
67
|
-
this.#
|
|
68
|
-
|
|
69
|
-
this.#
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
// A failed handshake may leave a transport that already refuses close().
|
|
73
|
-
}
|
|
83
|
+
if (this.#winner)
|
|
84
|
+
closeQuietly(this.#winner, info);
|
|
85
|
+
else
|
|
86
|
+
this.#cancel?.(info);
|
|
74
87
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let fallbackReason;
|
|
78
|
-
let webTransport;
|
|
79
|
-
if (NativeWebTransport) {
|
|
80
|
-
try {
|
|
81
|
-
webTransport = new NativeWebTransport(url, { protocols: [...protocols] });
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
// A runtime that refuses the dial outright (a policy, a URL it will not take) falls back too.
|
|
85
|
-
fallbackReason = error;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (webTransport) {
|
|
89
|
-
webTransport.closed.catch(() => { });
|
|
90
|
-
this.#current = webTransport;
|
|
91
|
-
this.#carrier = 'webtransport';
|
|
88
|
+
#race(url, protocols, delayMs, onFallback) {
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
92
90
|
let timer;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.#
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
let webTransportPending = false;
|
|
92
|
+
let webTransportFailure;
|
|
93
|
+
let webSocketStarted = false;
|
|
94
|
+
let webSocketFailure;
|
|
95
|
+
const end = (info) => {
|
|
96
|
+
this.#cancel = undefined;
|
|
97
|
+
clearTimeout(timer);
|
|
98
|
+
for (const dial of this.#dials)
|
|
99
|
+
closeQuietly(dial, info);
|
|
100
|
+
this.#dials.clear();
|
|
101
|
+
};
|
|
102
|
+
this.#cancel = (info) => {
|
|
103
|
+
end(info);
|
|
104
|
+
reject(new WebSocketSessionError('the dial was cancelled'));
|
|
105
|
+
};
|
|
106
|
+
const win = (winner, carrier) => {
|
|
107
|
+
// A dial ready after the race ended lost it, or was cancelled.
|
|
108
|
+
if (!this.#cancel)
|
|
109
|
+
return closeQuietly(winner);
|
|
110
|
+
this.#dials.delete(winner);
|
|
111
|
+
end();
|
|
112
|
+
this.#winner = winner;
|
|
113
|
+
this.#carrier = carrier;
|
|
114
|
+
// Settled before the callback, so a close() from it closes the winner rather than cancelling a dial.
|
|
115
|
+
resolve(winner);
|
|
116
|
+
if (carrier === 'websocket') {
|
|
117
|
+
const reason = webTransportPending
|
|
118
|
+
? new WebTransportOutpaced('the WebSocket was ready before the WebTransport handshake completed')
|
|
119
|
+
: webTransportFailure;
|
|
120
|
+
try {
|
|
121
|
+
onFallback?.(reason);
|
|
122
|
+
}
|
|
123
|
+
catch { }
|
|
107
124
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
};
|
|
126
|
+
// Neither dial can still win: the connection fails with the WebSocket dial's failure.
|
|
127
|
+
const failIfLost = () => {
|
|
128
|
+
if (!this.#cancel || webTransportPending || !webSocketFailure)
|
|
129
|
+
return;
|
|
130
|
+
end();
|
|
131
|
+
reject(webSocketFailure.error);
|
|
132
|
+
};
|
|
133
|
+
const dialWebSocket = () => {
|
|
134
|
+
if (!this.#cancel || webSocketStarted)
|
|
135
|
+
return;
|
|
136
|
+
webSocketStarted = true;
|
|
111
137
|
clearTimeout(timer);
|
|
138
|
+
let webSocket;
|
|
139
|
+
try {
|
|
140
|
+
webSocket = new WebSocketTransport(toWebSocketUrl(url), protocols);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
webSocketFailure = { error };
|
|
144
|
+
return failIfLost();
|
|
145
|
+
}
|
|
146
|
+
this.#dials.add(webSocket);
|
|
147
|
+
webSocket.ready.then(() => win(webSocket, 'websocket'), (error) => {
|
|
148
|
+
this.#dials.delete(webSocket);
|
|
149
|
+
webSocketFailure = { error };
|
|
150
|
+
failIfLost();
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
const NativeWebTransport = usableWebTransport();
|
|
154
|
+
let webTransport;
|
|
155
|
+
if (NativeWebTransport) {
|
|
156
|
+
try {
|
|
157
|
+
webTransport = new NativeWebTransport(url, { protocols: [...protocols] });
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
// A runtime that refuses the dial outright (a policy, a URL it will not take) falls back too.
|
|
161
|
+
webTransportFailure = error;
|
|
162
|
+
}
|
|
112
163
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return;
|
|
130
|
-
try {
|
|
131
|
-
this.#current?.close();
|
|
132
|
-
}
|
|
133
|
-
catch { }
|
|
134
|
-
throw new WebSocketSessionError('the dial was cancelled');
|
|
164
|
+
if (!webTransport)
|
|
165
|
+
return dialWebSocket();
|
|
166
|
+
const dial = webTransport;
|
|
167
|
+
dial.closed.catch(() => { });
|
|
168
|
+
this.#dials.add(dial);
|
|
169
|
+
webTransportPending = true;
|
|
170
|
+
timer = setTimeout(dialWebSocket, delayMs);
|
|
171
|
+
dial.ready.then(() => win(dial, 'webtransport'), (error) => {
|
|
172
|
+
webTransportPending = false;
|
|
173
|
+
webTransportFailure = error;
|
|
174
|
+
if (this.#dials.delete(dial))
|
|
175
|
+
closeQuietly(dial);
|
|
176
|
+
dialWebSocket();
|
|
177
|
+
failIfLost();
|
|
178
|
+
});
|
|
179
|
+
});
|
|
135
180
|
}
|
|
136
181
|
/** The winner's incoming streams, one at a time; the readable ends with the winner's (TA-12). */
|
|
137
182
|
#incoming(select) {
|
package/dist/fallback.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.js","sourceRoot":"","sources":["../src/fallback.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"fallback.js","sourceRoot":"","sources":["../src/fallback.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAyBpD,iGAAiG;AACjG,SA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,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* (`spec/transport-adapter.md`), with the deviations the contract records for it.
|
|
6
6
|
*
|
|
7
7
|
* - {@link createWebSocketTransport}: always WebSocket.
|
|
8
|
-
* - {@link withWebSocketFallback}: WebTransport first, WebSocket
|
|
8
|
+
* - {@link withWebSocketFallback}: WebTransport first, racing a WebSocket once it has had a 250 ms head start.
|
|
9
9
|
*
|
|
10
10
|
* Pass either factory as the SDK's `createTransport`.
|
|
11
11
|
*
|
|
@@ -57,18 +57,19 @@ export interface FallbackConnection {
|
|
|
57
57
|
/** Resolves once one of the dials is ready and its peer selected a protocol. */
|
|
58
58
|
ready: Promise<void>;
|
|
59
59
|
/**
|
|
60
|
-
* `'webtransport'` while the
|
|
60
|
+
* `'webtransport'` while the dials are in progress or once WebTransport won, `'websocket'` once the WebSocket won.
|
|
61
61
|
* Both carry the path and token in the URL, so the SDK's SETUP is the same either way.
|
|
62
62
|
*/
|
|
63
63
|
readonly framing: FallbackCarrier;
|
|
64
64
|
}
|
|
65
|
-
/** Dials WebTransport, then QMux over WebSocket
|
|
65
|
+
/** Dials WebTransport, then races QMux over WebSocket against it; see {@link withWebSocketFallback}. */
|
|
66
66
|
export type FallbackTransportFactory = (url: string, protocols: string[]) => FallbackConnection;
|
|
67
67
|
/**
|
|
68
|
-
* A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
68
|
+
* A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first and, unless
|
|
69
|
+
* that handshake completes within `webSocketDelayMs` (default 250 ms, as Happy Eyeballs, RFC 8305), dials QMux over
|
|
70
|
+
* WebSocket alongside it. The first ready carries the session and the other dial is closed; a WebTransport handshake
|
|
71
|
+
* that fails sooner starts the WebSocket at once. Where the runtime has no usable `WebTransport` (Safari before
|
|
72
|
+
* WebTransport, Node), it dials WebSocket at once. Each connection decides afresh.
|
|
72
73
|
*
|
|
73
74
|
* ```ts
|
|
74
75
|
* import { connectRelayPublisher } from '@caprid/relay';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAEL,KAAK,eAAe,EACpB,iBAAiB,EAEjB,KAAK,wBAAwB,EAC9B,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAElG,iHAAiH;AACjH,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,kGAAkG;IAClG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,mHAAmH;AACnH,MAAM,WAAW,mBAAmB;IAClC,8CAA8C;IAC9C,SAAS,EAAE,sBAAsB,CAAC;IAClC,qFAAqF;IACrF,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,kHAAkH;IAClH,OAAO,EAAE,WAAW,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,mBAAmB,CAAC;AAElG;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,IAAI,yBAAyB,CAKpE;AAED,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,kEAAkE;IAClE,SAAS,EAAE,iBAAiB,CAAC;IAC7B,gFAAgF;IAChF,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB;;;OAGG;IAC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AAwB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,kBAAkB,CAAC;AAEhG;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,wBAA6B,GAAG,wBAAwB,CAYtG"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assertFallbackOptions, FallbackTransport, toWebSocketUrl, } from './fallback.js';
|
|
2
2
|
import { WebSocketTransport } from './transport.js';
|
|
3
3
|
export { WebSocketSessionError } from './errors.js';
|
|
4
4
|
/**
|
|
@@ -22,10 +22,11 @@ export function createWebSocketTransport() {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
* A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first and, unless
|
|
26
|
+
* that handshake completes within `webSocketDelayMs` (default 250 ms, as Happy Eyeballs, RFC 8305), dials QMux over
|
|
27
|
+
* WebSocket alongside it. The first ready carries the session and the other dial is closed; a WebTransport handshake
|
|
28
|
+
* that fails sooner starts the WebSocket at once. Where the runtime has no usable `WebTransport` (Safari before
|
|
29
|
+
* WebTransport, Node), it dials WebSocket at once. Each connection decides afresh.
|
|
29
30
|
*
|
|
30
31
|
* ```ts
|
|
31
32
|
* import { connectRelayPublisher } from '@caprid/relay';
|
|
@@ -35,7 +36,7 @@ export function createWebSocketTransport() {
|
|
|
35
36
|
* ```
|
|
36
37
|
*/
|
|
37
38
|
export function withWebSocketFallback(options = {}) {
|
|
38
|
-
|
|
39
|
+
assertFallbackOptions(options);
|
|
39
40
|
return (url, protocols) => {
|
|
40
41
|
const transport = new FallbackTransport(url, protocols, options);
|
|
41
42
|
return {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,qBAAqB,EAErB,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;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAoC,EAAE;IAC1E,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/B,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caprid/relay-websocket",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "QMux-over-WebSocket transport adapter for the Relay SDK, for networks and browsers without WebTransport",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@moq/qmux": "0.3.3",
|
|
25
|
-
"@caprid/moq-core": "0.
|
|
25
|
+
"@caprid/moq-core": "0.3.0"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=24"
|