@statewalker/webrun-streams-signaling 0.1.6 → 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 +83 -36
- package/dist/byte-channel.d.ts +49 -9
- package/dist/byte-channel.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +406 -56
- package/dist/message-target.d.ts +55 -0
- package/dist/message-target.d.ts.map +1 -0
- package/dist/peer-connection.d.ts +4 -3
- package/dist/peer-connection.d.ts.map +1 -1
- package/dist/peer-manager.d.ts +15 -4
- package/dist/peer-manager.d.ts.map +1 -1
- package/dist/qr-signaling.d.ts +2 -3
- package/dist/qr-signaling.d.ts.map +1 -1
- package/dist/room-manager.d.ts +5 -5
- package/dist/room-manager.d.ts.map +1 -1
- package/dist/types.d.ts +23 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -6
- package/src/byte-channel.ts +188 -35
- package/src/index.ts +11 -3
- package/src/message-target.ts +137 -0
- package/src/peer-connection.ts +15 -2
- package/src/peer-manager.ts +71 -13
- package/src/qr-signaling.ts +56 -14
- package/src/room-manager.ts +6 -7
- package/src/types.ts +24 -3
package/README.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
## What it is
|
|
4
4
|
|
|
5
5
|
Connection-setup helpers for peer-to-peer links. Each one runs a handshake and hands back an
|
|
6
|
-
established
|
|
6
|
+
established `ByteChannel` (`send` / `recv` / `closed` / `close`, declared by this package).
|
|
7
7
|
`PeerManager` runs WebRTC offer/answer/ICE over a signaling transport you supply; `QrSignaling`
|
|
8
8
|
pairs two devices without a server by exchanging compact QR strings; `RoomManager` joins a
|
|
9
9
|
LiveKit-style room and opens a channel per participant. What runs on the channel afterwards —
|
|
10
|
-
typically `webrun-
|
|
10
|
+
typically `webrun-rpc`'s port stack, through `messageTargetOverByteChannel` — is up to you.
|
|
11
11
|
|
|
12
12
|
## Why it exists
|
|
13
13
|
|
|
@@ -37,13 +37,18 @@ pass an `rtc` factory from a WebRTC implementation.
|
|
|
37
37
|
| Export | Purpose |
|
|
38
38
|
| --- | --- |
|
|
39
39
|
| `new PeerManager(signaling, options?)` | WebRTC connections keyed by peer id over a `SignalingTransport`. `connect(peerId): Promise<ByteChannel>`, `onConnection((peerId, ch) => void): () => void`, `close()`. |
|
|
40
|
-
| `PeerManagerOptions` |
|
|
40
|
+
| `PeerManagerOptions` | `WebRtcConnectionOptions` plus `onError?: (error, peerId) => void`, called when a connection fails with no caller to tell (a signal it rejects, an inbound channel that never opens). |
|
|
41
41
|
| `new QrSignaling(options?)` | Serverless pairing. `offer(): Promise<{ qr, accept(answerQr): Promise<ByteChannel> }>`, `answer(offerQr): Promise<{ qr, channel }>`, `getSessionId()`. |
|
|
42
42
|
| `QrSignalingOptions` | `{ sessionId?: string; connection?: WebRtcConnectionOptions }`. |
|
|
43
|
-
| `new RoomManager(options: RoomManagerOptions)` | Room membership. `join(room)`, `participants(): AsyncIterable<string>`, `channelTo(peerId): Promise<ByteChannel
|
|
44
|
-
| `new PeerConnection(role, options?)` | One WebRTC connection's lifecycle, which `PeerManager` and `QrSignaling` build on. `connect()`, `handleSignal(msg)`, `open(): Promise<ByteChannel>`, `waitForIceGathering()`, `getLocalDescription()`, `getCollectedCandidates()`, `getState()`, `getRole()`, `getDataChannel()`, `on` / `off`, `close()`. |
|
|
45
|
-
| `byteChannelFromDataChannel(dc)` | Wrap an `RTCDataChannel` as a `ByteChannel`. |
|
|
46
|
-
| `byteChannelFromRoom(room, peerId)` | A `ByteChannel` to one participant of a `RoomLike
|
|
43
|
+
| `new RoomManager(options: RoomManagerOptions)` | Room membership. `join(room)`, `participants(): AsyncIterable<string>`, `channelTo(peerId, options?): Promise<ByteChannel>` (a `byteChannelFromRoom` channel), `leave()`. |
|
|
44
|
+
| `new PeerConnection(role, options?)` | One WebRTC connection's lifecycle, which `PeerManager` and `QrSignaling` build on. `connect()`, `handleSignal(msg)`, `open(): Promise<ByteChannel>`, `waitForIceGathering()`, `getLocalDescription()`, `getCollectedCandidates()`, `getState()`, `getRole()`, `hasRemoteDescription()`, `getDataChannel()`, `on` / `off`, `close()`. |
|
|
45
|
+
| `byteChannelFromDataChannel(dc)` | Wrap an `RTCDataChannel` as a `ByteChannel`, with the data channel's `bufferedAmount` and a `whenDrained()` that waits for `bufferedamountlow`. |
|
|
46
|
+
| `byteChannelFromRoom(room, peerId, options?)` | A `ByteChannel` to one participant of a `RoomLike`, on its own data topic (`options.topic`, default `DEFAULT_ROOM_TOPIC`). It closes when the room disconnects, the participant leaves, the peer's channel closes, a reliable publish fails, or a `send` exceeds `options.maxFrameBytes` (default `DEFAULT_ROOM_MAX_FRAME_BYTES`), so whatever runs on it learns the other end is gone. Packets and goodbye follow `webrun-streams-livekit`'s conventions. |
|
|
47
|
+
| `ByteChannelFromRoomOptions` | `{ topic?: string; maxFrameBytes?: number }`. |
|
|
48
|
+
| `DEFAULT_ROOM_TOPIC`, `DEFAULT_ROOM_MAX_FRAME_BYTES` | `"webrun/port-stack"` and `64_000`, the same defaults as `webrun-streams-livekit`. |
|
|
49
|
+
| `messageTargetOverByteChannel(channel, options?)` | A `ByteChannel` as `{ target, signal, maxMessageSize }` for `webrun-rpc`'s `overPipe`: a `MessageTarget` of bytes, a signal aborted when the channel closes, and the payload ceiling (`DEFAULT_MAX_MESSAGE_SIZE`, 16 KiB − 256, what every browser pair delivers over a data channel; pass `maxMessageSize: 12 * 1024` for a `byteChannelFromRoom` channel). `target` also has the channel's `bufferedAmount` and `whenDrained()`, so `overPipe` with `frameSize` paces its frames by the transport. It must be the channel's only reader. |
|
|
50
|
+
| `DRAIN_LOW_WATER` | `256 * 1024`. The channels' `whenDrained()` resolves once `bufferedAmount` is at most this. |
|
|
51
|
+
| `ByteChannel` | The channel type: `send`, `recv`, `closed`, `close`, and optional `bufferedAmount` / `whenDrained()`. It used to come from `@statewalker/webrun-streams`; it is declared here since `emulateMux` was removed. |
|
|
47
52
|
| `generateSessionId()`, `createCompressedSignal(...)`, `parseCompressedSignal(signal)`, `encodeSignal(signal)`, `decodeSignal(text)` | The pure QR payload functions. |
|
|
48
53
|
|
|
49
54
|
Types and constants: `SignalingTransport` (`localId`, `send(to, msg)`,
|
|
@@ -52,7 +57,7 @@ Types and constants: `SignalingTransport` (`localId`, `send(to, msg)`,
|
|
|
52
57
|
`PeerConnectionEvents` (`stateChange`, `signal`, `open`, `close`, `error`),
|
|
53
58
|
`WebRtcConnectionOptions`, `RtcPeerConnectionFactory`, `DEFAULT_ICE_SERVERS` (two Google STUN
|
|
54
59
|
servers), `CompressedSignal`, `RoomLike`, `RoomParticipantLike`, `RoomLocalParticipantLike`,
|
|
55
|
-
`RoomManagerOptions` (`url`, `getToken(room)`, `roomFactory`), `ROOM_EVENT` (the
|
|
60
|
+
`RoomManagerOptions` (`url`, `getToken(room)`, `roomFactory`), `ROOM_EVENT` (the four LiveKit
|
|
56
61
|
event names used), `ParticipantInfo` (exported, not used by any API here).
|
|
57
62
|
|
|
58
63
|
`WebRtcConnectionOptions`:
|
|
@@ -60,7 +65,7 @@ event names used), `ParticipantInfo` (exported, not used by any API here).
|
|
|
60
65
|
| option | default | meaning |
|
|
61
66
|
| --- | --- | --- |
|
|
62
67
|
| `iceServers` | `DEFAULT_ICE_SERVERS` | ICE servers. |
|
|
63
|
-
| `connectionTimeout` | 30000 ms | How long `open()` waits for the data channel. |
|
|
68
|
+
| `connectionTimeout` | 30000 ms | How long `open()` waits for the data channel (for `QrSignaling`'s initiator, from `accept`). |
|
|
64
69
|
| `iceGatheringTimeout` | 5000 ms | How long `QrSignaling` waits for ICE gathering before using what it has. |
|
|
65
70
|
| `channelLabel` | `"webrun-data"` | Data channel label. |
|
|
66
71
|
| `ordered` | `true` | Ordered delivery. |
|
|
@@ -75,8 +80,10 @@ The `SignalingTransport` below is an in-memory bus, so both peers run in one pag
|
|
|
75
80
|
application it wraps your WebSocket or other rendezvous channel.
|
|
76
81
|
|
|
77
82
|
```ts
|
|
78
|
-
import {
|
|
83
|
+
import { msgpackCodec } from "@statewalker/webrun-msgpack";
|
|
84
|
+
import { connect, overPipe, serve } from "@statewalker/webrun-rpc";
|
|
79
85
|
import {
|
|
86
|
+
messageTargetOverByteChannel,
|
|
80
87
|
PeerManager,
|
|
81
88
|
type SignalingMessage,
|
|
82
89
|
type SignalingTransport,
|
|
@@ -99,17 +106,28 @@ const a = new PeerManager(bus("A"));
|
|
|
99
106
|
const b = new PeerManager(bus("B"));
|
|
100
107
|
|
|
101
108
|
b.onConnection((peerId, channel) => {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
const { target, signal, maxMessageSize } = messageTargetOverByteChannel(channel);
|
|
110
|
+
void serve(
|
|
111
|
+
{ mux: overPipe(target, { codec: msgpackCodec, side: "responder", signal, maxMessageSize }) },
|
|
112
|
+
async function* echo(input) {
|
|
113
|
+
for await (const chunk of input) yield chunk;
|
|
114
|
+
},
|
|
115
|
+
);
|
|
106
116
|
});
|
|
107
117
|
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
|
|
118
|
+
const pipe = messageTargetOverByteChannel(await a.connect("B"));
|
|
119
|
+
const { call, close } = await connect({
|
|
120
|
+
mux: overPipe(pipe.target, {
|
|
121
|
+
codec: msgpackCodec,
|
|
122
|
+
side: "initiator",
|
|
123
|
+
signal: pipe.signal,
|
|
124
|
+
maxMessageSize: pipe.maxMessageSize,
|
|
125
|
+
}),
|
|
126
|
+
});
|
|
127
|
+
for await (const chunk of call([new TextEncoder().encode("ping")])) {
|
|
111
128
|
console.log(new TextDecoder().decode(chunk)); // "ping"
|
|
112
129
|
}
|
|
130
|
+
await close();
|
|
113
131
|
|
|
114
132
|
a.close();
|
|
115
133
|
b.close();
|
|
@@ -167,7 +185,7 @@ for await (const peerId of rooms.participants()) {
|
|
|
167
185
|
ByteChannel ── send / recv / closed / close
|
|
168
186
|
│
|
|
169
187
|
▼
|
|
170
|
-
|
|
188
|
+
the port stack (messageTargetOverByteChannel) or any byte protocol (you run)
|
|
171
189
|
```
|
|
172
190
|
|
|
173
191
|
### How `PeerManager` routes signals
|
|
@@ -177,7 +195,15 @@ data channel and offer, and resolves when the channel opens. An inbound `offer`
|
|
|
177
195
|
peer creates a responder; `onConnection` handlers are called when its channel opens. Answers and
|
|
178
196
|
candidates from unknown peers are ignored. Candidates that arrive before the remote description
|
|
179
197
|
is set are queued and applied after it. When ICE gathering completes, a `{ type: "ready" }`
|
|
180
|
-
signal is sent; receivers ignore it. A connection is forgotten when its data channel
|
|
198
|
+
signal is sent; receivers ignore it. A connection is closed and forgotten when its data channel
|
|
199
|
+
closes, when its state becomes `failed` or `closed`, when its channel does not open, or when it
|
|
200
|
+
rejects a signal; the peer's next offer then starts a new responder. A connection makes one
|
|
201
|
+
offer, so a new offer from a peer means it started over (for example it reloaded before ICE
|
|
202
|
+
reported a failure here): if this side answered that peer before, or dialed it and already applied
|
|
203
|
+
its answer, the old connection is closed and the offer starts a new responder at once. An offer
|
|
204
|
+
to a connection that is still waiting for its answer is glare: both dials fail (reported through
|
|
205
|
+
`onError` on this side) and must be retried. `connect(peerId)` replaces any existing connection to
|
|
206
|
+
that peer.
|
|
181
207
|
|
|
182
208
|
### What `answer()` waits for
|
|
183
209
|
|
|
@@ -190,16 +216,19 @@ the initiator has applied the answer, which needs the answer QR. So `answer()` r
|
|
|
190
216
|
above does not complete. The test suite uses a mock `RTCPeerConnection` that opens the channel as
|
|
191
217
|
soon as both descriptions are set on one side, so it does not exercise this ordering.
|
|
192
218
|
|
|
193
|
-
`offer()`
|
|
194
|
-
|
|
195
|
-
|
|
219
|
+
`offer()` does not wait for its channel: `accept` does, so `connectionTimeout` counts from
|
|
220
|
+
`accept`, not from the offer, and the people scanning the codes can take as long as they need.
|
|
221
|
+
If applying the answer fails, `accept` closes the connection and rejects.
|
|
196
222
|
|
|
197
223
|
### How QR payloads stay small
|
|
198
224
|
|
|
199
225
|
`createCompressedSignal` keeps only the SDP lines needed to connect (`v=`, `o=`, `s=`, `t=`,
|
|
200
226
|
`m=`, `c=`, `a=group:`, `a=ice-ufrag:`, `a=ice-pwd:`, `a=fingerprint:`, `a=setup:`, `a=mid:`,
|
|
201
|
-
`a=sctp-port:`, `a=max-message-size:`) and packs each candidate into a `|`-separated string
|
|
202
|
-
|
|
227
|
+
`a=sctp-port:`, `a=max-message-size:`) and packs each candidate into a `|`-separated string,
|
|
228
|
+
dropping the attributes after `typ`. A candidate that carries `raddr`, `rport` or `tcptype` (a
|
|
229
|
+
srflx, relay or TCP candidate) is kept raw instead, prefixed `R:`, with only those attributes, and
|
|
230
|
+
so is a candidate that does not parse. A null `sdpMLineIndex` travels as an empty field, so 0
|
|
231
|
+
stays 0. `encodeSignal` is URL-safe base64 of the
|
|
203
232
|
JSON, without padding. `parseCompressedSignal` throws `Unsupported protocol version: <v>` for any
|
|
204
233
|
version other than 1, and a malformed packed candidate throws
|
|
205
234
|
`Invalid compressed candidate: <text>`.
|
|
@@ -209,13 +238,25 @@ version other than 1, and a malformed packed candidate throws
|
|
|
209
238
|
- Both channels buffer inbound bytes from the moment they are created, so data that arrives
|
|
210
239
|
before your `for await` starts is not lost.
|
|
211
240
|
- `byteChannelFromDataChannel` sets `binaryType = "arraybuffer"` and copies every inbound payload.
|
|
212
|
-
A non-byte message (a string)
|
|
213
|
-
|
|
214
|
-
or on `close()
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
241
|
+
A non-byte message (a string) ends the channel, as does a `send` that throws (a closed channel,
|
|
242
|
+
or Chrome's full 16 MiB send queue): either way the stream above lost a message. `closed`
|
|
243
|
+
resolves on the data channel's `close` event or on `close()`; a `send` after that is ignored.
|
|
244
|
+
It sets `bufferedAmountLowThreshold` to `DRAIN_LOW_WATER`; `whenDrained()` resolves on
|
|
245
|
+
`bufferedamountlow` or when the channel ends.
|
|
246
|
+
- `messageTargetOverByteChannel`'s `whenDrained()` is the channel's, and resolves at once over a
|
|
247
|
+
channel without one or once the pipe has ended.
|
|
248
|
+
- `byteChannelFromRoom` publishes with `reliable: true` to `destinationIdentities: [peerId]` on
|
|
249
|
+
its topic, and accepts `dataReceived` events from that participant on that topic only; packets
|
|
250
|
+
with no participant, from anyone else, or on another topic are ignored, so several channels to
|
|
251
|
+
one participant can share a room on different topics. It ends when the room disconnects, the
|
|
252
|
+
participant leaves, a reliable publish fails, a `send` exceeds `maxFrameBytes` (that `send`
|
|
253
|
+
throws `RangeError`), or the peer's goodbye arrives. When it ends on this side (`close()`, an
|
|
254
|
+
oversized `send`, a failed publish) it publishes an empty goodbye on `<topic>/close`, the same
|
|
255
|
+
convention as `webrun-streams-livekit`'s `CLOSE_TOPIC`, so the peer's channel ends although the
|
|
256
|
+
room stays connected. The topic, goodbye and frame ceiling match `messageTargetOverLiveKit`'s
|
|
257
|
+
defaults, so the port stack over this channel talks to one over that adapter. `bufferedAmount`
|
|
258
|
+
counts bytes whose publish has not settled; `whenDrained()` resolves once that is at most
|
|
259
|
+
`DRAIN_LOW_WATER`.
|
|
219
260
|
|
|
220
261
|
### What `RoomManager` tracks
|
|
221
262
|
|
|
@@ -231,14 +272,20 @@ that joins, and ends at `leave()`. Departures are not reported. Only the most re
|
|
|
231
272
|
- `connect()` on a responder throws `connect() should only be called by initiator`; an offer to an
|
|
232
273
|
initiator throws `Received offer but not in responder role`; an answer to a responder throws
|
|
233
274
|
`Received answer but not in initiator role`.
|
|
234
|
-
-
|
|
235
|
-
|
|
236
|
-
|
|
275
|
+
- `PeerManager`: a failed `connect()` rejects and forgets the connection. A failure with no caller
|
|
276
|
+
(an offer during glare, malformed SDP or candidates, an inbound channel that never opens) closes
|
|
277
|
+
and forgets the connection and goes to `onError`; without `onError` it is dropped. Either way
|
|
278
|
+
`onConnection` is not called for it.
|
|
279
|
+
- `PeerConnection.open()` also rejects with `Connection closed before the data channel opened`
|
|
280
|
+
when the connection is closed first.
|
|
237
281
|
|
|
238
282
|
### Dependencies
|
|
239
283
|
|
|
240
|
-
Zero runtime
|
|
241
|
-
|
|
284
|
+
Zero runtime dependencies: the bundle imports nothing, and `ByteChannel` is declared here.
|
|
285
|
+
`@statewalker/webrun-rpc`, `-msgpack`, `-streams` and `-streams-conformance` are dev dependencies of the tests:
|
|
286
|
+
`tests/conformance.test.ts` runs the conformance suite over `messageTargetOverByteChannel` and the
|
|
287
|
+
port stack, on `byteChannelFromDataChannel` and on `byteChannelFromRoom` (in-process stand-ins for
|
|
288
|
+
the data channel and the room). `livekit-client` is an optional peer, used only through the
|
|
242
289
|
`RoomLike` shape you inject. A neutrality test (`tests/neutrality.test.ts`) keeps the source from
|
|
243
290
|
importing anything else.
|
|
244
291
|
|
package/dist/byte-channel.d.ts
CHANGED
|
@@ -3,21 +3,61 @@
|
|
|
3
3
|
* requires. The original `vcs-port-*` helpers surfaced an established
|
|
4
4
|
* connection as a Web `MessagePort` (via the out-of-scope `datachannel-port` /
|
|
5
5
|
* `livekit-port` byte bridges); here the established primitive is wrapped
|
|
6
|
-
* *directly* as a
|
|
7
|
-
* multiplexing (`
|
|
6
|
+
* *directly* as a {@link ByteChannel} so the byte transport +
|
|
7
|
+
* multiplexing (`webrun-rpc`'s port stack, via `messageTargetOverByteChannel`) can run on top.
|
|
8
8
|
*/
|
|
9
|
-
import type { ByteChannel } from "
|
|
10
|
-
|
|
9
|
+
import type { ByteChannel, RoomLike } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* `whenDrained` resolves once the bytes sent and not yet written out are at
|
|
12
|
+
* most this: the transport can take more. The same mark the ws, peerjs,
|
|
13
|
+
* livekit and webrtc adapters use.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DRAIN_LOW_WATER: number;
|
|
11
16
|
/**
|
|
12
17
|
* Wrap an established `RTCDataChannel` as a {@link ByteChannel}. Outbound bytes
|
|
13
|
-
* go through `channel.send`; inbound `message` events feed `recv`.
|
|
18
|
+
* go through `channel.send`; inbound `message` events feed `recv`. A message
|
|
19
|
+
* that is not bytes, or a `send` that fails (a closed channel, Chrome's full
|
|
20
|
+
* send queue), ends the channel: the stream above it lost a message.
|
|
21
|
+
* `bufferedAmount` is the data channel's; `whenDrained` waits for its
|
|
22
|
+
* `bufferedamountlow`.
|
|
14
23
|
*/
|
|
15
24
|
export declare function byteChannelFromDataChannel(channel: RTCDataChannel): ByteChannel;
|
|
25
|
+
/**
|
|
26
|
+
* The topic a {@link byteChannelFromRoom} channel's packets carry, the same
|
|
27
|
+
* default as `webrun-streams-livekit`'s `messageTargetOverLiveKit`; packets on
|
|
28
|
+
* other topics are someone else's. The goodbye goes on this topic with
|
|
29
|
+
* `/close` appended, as there.
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_ROOM_TOPIC = "webrun/port-stack";
|
|
32
|
+
/**
|
|
33
|
+
* The largest packet a {@link byteChannelFromRoom} channel publishes, as in
|
|
34
|
+
* `webrun-streams-livekit`: livekit-client (2.x) refuses a larger one.
|
|
35
|
+
*/
|
|
36
|
+
export declare const DEFAULT_ROOM_MAX_FRAME_BYTES = 64000;
|
|
37
|
+
/** Options for {@link byteChannelFromRoom}. */
|
|
38
|
+
export interface ByteChannelFromRoomOptions {
|
|
39
|
+
/**
|
|
40
|
+
* The data topic, default {@link DEFAULT_ROOM_TOPIC}; the goodbye uses it
|
|
41
|
+
* with `/close` appended. Both ends must agree. Use another to run two
|
|
42
|
+
* channels to the same participant.
|
|
43
|
+
*/
|
|
44
|
+
topic?: string;
|
|
45
|
+
/** The largest packet sent; past it `send` ends the channel and throws `RangeError`. Default {@link DEFAULT_ROOM_MAX_FRAME_BYTES}. */
|
|
46
|
+
maxFrameBytes?: number;
|
|
47
|
+
}
|
|
16
48
|
/**
|
|
17
49
|
* Build a {@link ByteChannel} to a single room participant over a LiveKit-style
|
|
18
|
-
* `Room`. Outbound bytes are published to `peerId
|
|
19
|
-
* events from `peerId`
|
|
20
|
-
*
|
|
50
|
+
* `Room`. Outbound bytes are published reliably to `peerId` on the channel's
|
|
51
|
+
* topic; inbound `dataReceived` events from `peerId` on that topic feed
|
|
52
|
+
* `recv`. The packets and the goodbye follow `webrun-streams-livekit`'s
|
|
53
|
+
* conventions, so the port stack over this channel talks to one over
|
|
54
|
+
* `messageTargetOverLiveKit` with the same topic.
|
|
55
|
+
*
|
|
56
|
+
* The channel ends when the room disconnects, the participant leaves, the
|
|
57
|
+
* peer's goodbye arrives, a reliable publish fails, or a `send` exceeds
|
|
58
|
+
* `maxFrameBytes`. When it ends on this side, a goodbye on the close topic
|
|
59
|
+
* ends the peer's channel too: the room stays connected, so nothing else would.
|
|
60
|
+
* `bufferedAmount` counts bytes whose publish has not settled.
|
|
21
61
|
*/
|
|
22
|
-
export declare function byteChannelFromRoom(room: RoomLike, peerId: string): ByteChannel;
|
|
62
|
+
export declare function byteChannelFromRoom(room: RoomLike, peerId: string, options?: ByteChannelFromRoomOptions): ByteChannel;
|
|
23
63
|
//# sourceMappingURL=byte-channel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"byte-channel.d.ts","sourceRoot":"","sources":["../src/byte-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"byte-channel.d.ts","sourceRoot":"","sources":["../src/byte-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGxD;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAa,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAuE/E;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD,+CAA+C;AAC/C,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sIAAsI;IACtI,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,0BAA+B,GACvC,WAAW,CA0Gb"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generic P2P signaling / connection-setup helpers, relocated from the retiring
|
|
5
5
|
* `@statewalker/vcs-port-{webrtc,livekit}` packages and adapted to yield
|
|
6
|
-
*
|
|
6
|
+
* {@link ByteChannel}s. Signaling here is *transport-setup only*:
|
|
7
7
|
* it establishes a peer connection and hands back an established channel; the
|
|
8
|
-
* byte transport + multiplexing is `@statewalker/webrun-
|
|
8
|
+
* byte transport + multiplexing is `@statewalker/webrun-rpc`'s port stack.
|
|
9
9
|
*
|
|
10
10
|
* - {@link PeerManager} — WebRTC peer discovery + connection over a signaling transport.
|
|
11
11
|
* - {@link QrSignaling} — serverless offer/answer exchange via QR strings.
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
*/
|
|
16
|
-
export { byteChannelFromDataChannel, byteChannelFromRoom } from "./byte-channel.js";
|
|
16
|
+
export { type ByteChannelFromRoomOptions, byteChannelFromDataChannel, byteChannelFromRoom, DEFAULT_ROOM_MAX_FRAME_BYTES, DEFAULT_ROOM_TOPIC, DRAIN_LOW_WATER, } from "./byte-channel.js";
|
|
17
|
+
export * from "./message-target.js";
|
|
17
18
|
export { PeerConnection } from "./peer-connection.js";
|
|
18
19
|
export { PeerManager, type PeerManagerOptions } from "./peer-manager.js";
|
|
19
20
|
export { createCompressedSignal, decodeSignal, encodeSignal, generateSessionId, parseCompressedSignal, QrSignaling, type QrSignalingOptions, } from "./qr-signaling.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,KAAK,0BAA0B,EAC/B,0BAA0B,EAC1B,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,cAAc,YAAY,CAAC"}
|