@statewalker/webrun-streams-signaling 0.2.0 → 0.4.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/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { newMessagePipe } from "@statewalker/webrun-streams";
1
2
  //#region src/byte-queue.ts
2
3
  /**
3
4
  * Minimal eager push/pull byte queue backing the `recv` side of the
@@ -85,86 +86,195 @@ const ROOM_EVENT = {
85
86
  * multiplexing (`webrun-rpc`'s port stack, via `messageTargetOverByteChannel`) can run on top.
86
87
  */
87
88
  /**
89
+ * `whenDrained` resolves once the bytes sent and not yet written out are at
90
+ * most this: the transport can take more. The same mark the ws, peerjs,
91
+ * livekit and webrtc adapters use.
92
+ */
93
+ const DRAIN_LOW_WATER = 262144;
94
+ /**
88
95
  * Wrap an established `RTCDataChannel` as a {@link ByteChannel}. Outbound bytes
89
- * go through `channel.send`; inbound `message` events feed `recv`.
96
+ * go through `channel.send`; inbound `message` events feed `recv`. A message
97
+ * that is not bytes, or a `send` that fails (a closed channel, Chrome's full
98
+ * send queue), ends the channel: the stream above it lost a message.
99
+ * `bufferedAmount` is the data channel's; `whenDrained` waits for its
100
+ * `bufferedamountlow`.
90
101
  */
91
102
  function byteChannelFromDataChannel(channel) {
92
103
  const queue = makeByteQueue();
93
104
  let closedResolve;
105
+ let ended = false;
94
106
  const closed = new Promise((r) => {
95
107
  closedResolve = r;
96
108
  });
97
- const onMessage = (ev) => queue.push(toBytes(ev.data));
98
- const onClose = () => {
109
+ const drainWaiters = /* @__PURE__ */ new Set();
110
+ const onMessage = (ev) => {
111
+ if (ended) return;
112
+ let bytes;
113
+ try {
114
+ bytes = toBytes(ev.data);
115
+ } catch {
116
+ close();
117
+ return;
118
+ }
119
+ queue.push(bytes);
120
+ };
121
+ const onDrained = () => {
122
+ for (const w of [...drainWaiters]) w();
123
+ drainWaiters.clear();
124
+ };
125
+ const end = () => {
126
+ if (ended) return;
127
+ ended = true;
128
+ channel.removeEventListener("message", onMessage);
129
+ channel.removeEventListener("close", end);
130
+ channel.removeEventListener("bufferedamountlow", onDrained);
99
131
  queue.done();
100
132
  closedResolve();
133
+ onDrained();
134
+ };
135
+ const close = () => {
136
+ end();
137
+ try {
138
+ channel.close();
139
+ } catch {}
101
140
  };
102
141
  channel.binaryType = "arraybuffer";
142
+ channel.bufferedAmountLowThreshold = DRAIN_LOW_WATER;
103
143
  channel.addEventListener("message", onMessage);
104
- channel.addEventListener("close", onClose);
144
+ channel.addEventListener("close", end);
145
+ channel.addEventListener("bufferedamountlow", onDrained);
105
146
  return {
106
147
  send(bytes) {
148
+ if (ended) return;
107
149
  try {
108
150
  channel.send(bytes);
109
- } catch {}
151
+ } catch {
152
+ close();
153
+ }
110
154
  },
111
155
  recv: queue.recv,
112
156
  closed,
113
- close() {
114
- channel.removeEventListener("message", onMessage);
115
- channel.removeEventListener("close", onClose);
116
- try {
117
- channel.close();
118
- } catch {}
119
- queue.done();
120
- closedResolve();
157
+ close,
158
+ get bufferedAmount() {
159
+ return channel.bufferedAmount ?? 0;
160
+ },
161
+ whenDrained() {
162
+ if (ended || (channel.bufferedAmount ?? 0) <= 262144) return Promise.resolve();
163
+ return new Promise((resolve) => drainWaiters.add(resolve));
121
164
  }
122
165
  };
123
166
  }
124
167
  /**
168
+ * The topic a {@link byteChannelFromRoom} channel's packets carry, the same
169
+ * default as `webrun-streams-livekit`'s `messageTargetOverLiveKit`; packets on
170
+ * other topics are someone else's. The goodbye goes on this topic with
171
+ * `/close` appended, as there.
172
+ */
173
+ const DEFAULT_ROOM_TOPIC = "webrun/port-stack";
174
+ /**
175
+ * The largest packet a {@link byteChannelFromRoom} channel publishes, as in
176
+ * `webrun-streams-livekit`: livekit-client (2.x) refuses a larger one.
177
+ */
178
+ const DEFAULT_ROOM_MAX_FRAME_BYTES = 64e3;
179
+ /**
125
180
  * Build a {@link ByteChannel} to a single room participant over a LiveKit-style
126
- * `Room`. Outbound bytes are published to `peerId`; inbound `dataReceived`
127
- * events from `peerId` feed `recv`. This is the per-participant filtering the
128
- * retired `vcs-port-livekit` `livekit-port` performed, adapted to ByteChannel.
181
+ * `Room`. Outbound bytes are published reliably to `peerId` on the channel's
182
+ * topic; inbound `dataReceived` events from `peerId` on that topic feed
183
+ * `recv`. The packets and the goodbye follow `webrun-streams-livekit`'s
184
+ * conventions, so the port stack over this channel talks to one over
185
+ * `messageTargetOverLiveKit` with the same topic.
186
+ *
187
+ * The channel ends when the room disconnects, the participant leaves, the
188
+ * peer's goodbye arrives, a reliable publish fails, or a `send` exceeds
189
+ * `maxFrameBytes`. When it ends on this side, a goodbye on the close topic
190
+ * ends the peer's channel too: the room stays connected, so nothing else would.
191
+ * `bufferedAmount` counts bytes whose publish has not settled.
129
192
  */
130
- function byteChannelFromRoom(room, peerId) {
193
+ function byteChannelFromRoom(room, peerId, options = {}) {
194
+ const topic = options.topic ?? "webrun/port-stack";
195
+ const closeTopic = `${topic}/close`;
196
+ const maxFrameBytes = options.maxFrameBytes ?? 64e3;
131
197
  const queue = makeByteQueue();
132
198
  let closedResolve;
133
199
  const closed = new Promise((r) => {
134
200
  closedResolve = r;
135
201
  });
136
202
  let ended = false;
203
+ let inFlight = 0;
204
+ const drainWaiters = /* @__PURE__ */ new Set();
205
+ const wakeDrainWaiters = () => {
206
+ if (inFlight > 262144 && !ended) return;
207
+ for (const w of [...drainWaiters]) w();
208
+ drainWaiters.clear();
209
+ };
137
210
  const onData = (...args) => {
138
- const payload = args[0];
139
- if (args[1]?.identity !== peerId) return;
140
- if (payload != null) queue.push(toBytes(payload));
211
+ const [payload, participant, , packetTopic] = args;
212
+ if (ended || participant?.identity !== peerId) return;
213
+ if (packetTopic === closeTopic) {
214
+ end(false);
215
+ return;
216
+ }
217
+ if (packetTopic !== topic || payload == null) return;
218
+ let bytes;
219
+ try {
220
+ bytes = toBytes(payload);
221
+ } catch {
222
+ end(true);
223
+ return;
224
+ }
225
+ queue.push(bytes);
141
226
  };
142
227
  const onParticipantDisconnected = (...args) => {
143
- if (args[0]?.identity === peerId) end();
228
+ if (args[0]?.identity === peerId) end(false);
144
229
  };
145
- const end = () => {
230
+ const onDisconnected = () => end(false);
231
+ /** `tellPeer`: it ended on this side, and the room is still there to say so. */
232
+ const end = (tellPeer) => {
146
233
  if (ended) return;
147
234
  ended = true;
148
235
  room.off(ROOM_EVENT.dataReceived, onData);
149
236
  room.off(ROOM_EVENT.participantDisconnected, onParticipantDisconnected);
150
- room.off(ROOM_EVENT.disconnected, end);
237
+ room.off(ROOM_EVENT.disconnected, onDisconnected);
151
238
  queue.done();
152
239
  closedResolve();
240
+ wakeDrainWaiters();
241
+ if (tellPeer) room.localParticipant.publishData(/* @__PURE__ */ new Uint8Array(0), {
242
+ reliable: true,
243
+ destinationIdentities: [peerId],
244
+ topic: closeTopic
245
+ }).catch(() => void 0);
153
246
  };
154
247
  room.on(ROOM_EVENT.dataReceived, onData);
155
248
  room.on(ROOM_EVENT.participantDisconnected, onParticipantDisconnected);
156
- room.on(ROOM_EVENT.disconnected, end);
249
+ room.on(ROOM_EVENT.disconnected, onDisconnected);
157
250
  return {
158
251
  send(bytes) {
159
252
  if (ended) return;
253
+ if (bytes.byteLength > maxFrameBytes) {
254
+ end(true);
255
+ throw new RangeError(`webrun-streams-signaling: a ${bytes.byteLength}-byte packet exceeds maxFrameBytes (${maxFrameBytes})`);
256
+ }
257
+ const size = bytes.byteLength;
258
+ inFlight += size;
160
259
  room.localParticipant.publishData(bytes, {
161
260
  reliable: true,
162
- destinationIdentities: [peerId]
163
- }).catch(end);
261
+ destinationIdentities: [peerId],
262
+ topic
263
+ }).then(() => void 0, () => end(true)).finally(() => {
264
+ inFlight -= size;
265
+ wakeDrainWaiters();
266
+ });
164
267
  },
165
268
  recv: queue.recv,
166
269
  closed,
167
- close: end
270
+ close: () => end(true),
271
+ get bufferedAmount() {
272
+ return inFlight;
273
+ },
274
+ whenDrained() {
275
+ if (ended || inFlight <= 262144) return Promise.resolve();
276
+ return new Promise((resolve) => drainWaiters.add(resolve));
277
+ }
168
278
  };
169
279
  }
170
280
  //#endregion
@@ -178,6 +288,8 @@ function byteChannelFromRoom(room, peerId) {
178
288
  * reliable packets silently.
179
289
  */
180
290
  const DEFAULT_MAX_MESSAGE_SIZE = 16128;
291
+ /** How long a closed channel's `recv` may take to hand over what it still holds before the pipe ends. */
292
+ const CLOSE_DRAIN_MS = 50;
181
293
  /**
182
294
  * A `ByteChannel` this package hands back (`PeerManager`, `QrSignaling`,
183
295
  * `RoomManager`) as a pipe for `webrun-rpc`'s port stack:
@@ -195,49 +307,38 @@ const DEFAULT_MAX_MESSAGE_SIZE = 16128;
195
307
  * Messages already received when the channel closes are still delivered.
196
308
  */
197
309
  function messageTargetOverByteChannel(channel, options = {}) {
198
- const listeners = /* @__PURE__ */ new Set();
199
- const life = new AbortController();
200
- let closedHere = false;
201
- const end = (reason) => {
202
- if (!life.signal.aborted) life.abort(reason);
203
- };
204
- channel.closed.then(() => end(/* @__PURE__ */ new Error("webrun-streams-signaling: the channel closed")));
205
- (async () => {
206
- for await (const bytes of channel.recv) {
207
- if (closedHere) break;
208
- const event = new MessageEvent("message", { data: bytes.slice() });
209
- for (const listener of [...listeners]) try {
210
- Promise.resolve(listener(event)).catch(() => void 0);
310
+ const control = newMessagePipe({
311
+ send: (bytes) => channel.send(bytes),
312
+ bufferedAmount: () => channel.bufferedAmount ?? 0,
313
+ ...channel.whenDrained ? {
314
+ isDrained: () => false,
315
+ whenDrained: () => channel.whenDrained?.() ?? Promise.resolve()
316
+ } : { isDrained: () => true },
317
+ close: (local) => {
318
+ if (!local) return;
319
+ try {
320
+ channel.close();
211
321
  } catch {}
212
322
  }
213
- end(/* @__PURE__ */ new Error("webrun-streams-signaling: the channel closed"));
214
- })().catch((err) => end(err instanceof Error ? err : new Error(String(err), { cause: err })));
215
- return {
216
- signal: life.signal,
323
+ }, {
324
+ name: "webrun-streams-signaling",
217
325
  maxMessageSize: options.maxMessageSize ?? 16128,
218
- target: {
219
- addEventListener: (_type, listener) => {
220
- listeners.add(listener);
221
- },
222
- removeEventListener: (_type, listener) => {
223
- listeners.delete(listener);
224
- },
225
- postMessage(message) {
226
- const bytes = message instanceof Uint8Array ? message : message instanceof ArrayBuffer ? new Uint8Array(message) : ArrayBuffer.isView(message) ? new Uint8Array(message.buffer, message.byteOffset, message.byteLength) : void 0;
227
- if (!bytes) throw new TypeError(`webrun-streams-signaling: a byte pipe carries Uint8Array, ArrayBuffer or a view, got ${Object.prototype.toString.call(message)}`);
228
- if (life.signal.aborted) return;
229
- channel.send(bytes.slice());
230
- },
231
- async close() {
232
- listeners.clear();
233
- closedHere = true;
234
- end(/* @__PURE__ */ new Error("webrun-streams-signaling: closed locally"));
235
- try {
236
- channel.close();
237
- } catch {}
238
- }
326
+ maxFrameBytes: options.maxFrameBytes,
327
+ copyOnSend: true,
328
+ copyOnDeliver: true
329
+ });
330
+ const closedMessage = "webrun-streams-signaling: the channel closed";
331
+ (async () => {
332
+ for await (const bytes of channel.recv) {
333
+ if (control.ended) break;
334
+ control.deliver(bytes);
239
335
  }
240
- };
336
+ })().then(() => control.end(/* @__PURE__ */ new Error(closedMessage)), (err) => control.end(err instanceof Error ? err : new Error(String(err), { cause: err }), true));
337
+ channel.closed.then(() => {
338
+ if (control.ended) return;
339
+ setTimeout(() => control.end(/* @__PURE__ */ new Error(closedMessage)), CLOSE_DRAIN_MS).unref?.();
340
+ });
341
+ return control.pipe;
241
342
  }
242
343
  //#endregion
243
344
  //#region src/peer-connection.ts
@@ -284,6 +385,10 @@ var PeerConnection = class {
284
385
  getRole() {
285
386
  return this.role;
286
387
  }
388
+ /** Whether the remote description (the peer's offer or answer) has been applied. */
389
+ hasRemoteDescription() {
390
+ return this.remoteDescriptionSet;
391
+ }
287
392
  getDataChannel() {
288
393
  return this.dataChannel;
289
394
  }
@@ -490,6 +595,7 @@ var PeerConnection = class {
490
595
  const cleanup = () => {
491
596
  this.off("open", onOpen);
492
597
  this.off("error", onError);
598
+ this.off("stateChange", onState);
493
599
  clearTimeout(timer);
494
600
  };
495
601
  const onOpen = () => {
@@ -502,8 +608,14 @@ var PeerConnection = class {
502
608
  cleanup();
503
609
  reject(error);
504
610
  };
611
+ const onState = (state) => {
612
+ if (state !== "closed") return;
613
+ cleanup();
614
+ reject(/* @__PURE__ */ new Error("Connection closed before the data channel opened"));
615
+ };
505
616
  this.on("open", onOpen);
506
617
  this.on("error", onError);
618
+ this.on("stateChange", onState);
507
619
  const timer = setTimeout(() => {
508
620
  cleanup();
509
621
  reject(/* @__PURE__ */ new Error(`Connection timeout after ${timeout}ms`));
@@ -549,10 +661,18 @@ var PeerManager = class {
549
661
  }
550
662
  /** Dial `peerId` and resolve with the established channel. */
551
663
  async connect(peerId) {
664
+ const previous = this.connections.get(peerId);
665
+ if (previous) this.forget(peerId, previous);
552
666
  const pc = this.makeConnection(peerId, "initiator");
553
667
  const channel = pc.open();
554
- await pc.connect();
555
- return channel;
668
+ try {
669
+ await pc.connect();
670
+ return await channel;
671
+ } catch (err) {
672
+ channel.catch(() => void 0);
673
+ this.forget(peerId, pc);
674
+ throw err;
675
+ }
556
676
  }
557
677
  /** Register a handler for inbound connections. Returns an unsubscribe fn. */
558
678
  onConnection(handler) {
@@ -562,27 +682,52 @@ var PeerManager = class {
562
682
  /** Tear down all connections and stop listening for signaling. */
563
683
  close() {
564
684
  this.unsubscribe();
565
- for (const pc of this.connections.values()) pc.close();
685
+ const all = [...this.connections.values()];
566
686
  this.connections.clear();
687
+ for (const pc of all) pc.close();
567
688
  this.connectionHandlers.clear();
568
689
  }
569
690
  makeConnection(peerId, role) {
570
691
  const pc = new PeerConnection(role, this.options);
571
692
  pc.on("signal", (msg) => this.signaling.send(peerId, msg));
572
- pc.on("close", () => this.connections.delete(peerId));
693
+ pc.on("close", () => this.forget(peerId, pc));
694
+ pc.on("stateChange", (state) => {
695
+ if (state === "failed" || state === "closed") this.forget(peerId, pc);
696
+ });
573
697
  this.connections.set(peerId, pc);
574
698
  return pc;
575
699
  }
700
+ /** Close `pc` and drop it, unless a newer connection to `peerId` replaced it. */
701
+ forget(peerId, pc) {
702
+ if (this.connections.get(peerId) !== pc) return;
703
+ this.connections.delete(peerId);
704
+ pc.close();
705
+ }
706
+ fail(peerId, pc, err) {
707
+ const live = this.connections.get(peerId) === pc;
708
+ this.forget(peerId, pc);
709
+ if (!live) return;
710
+ const error = err instanceof Error ? err : new Error(String(err), { cause: err });
711
+ try {
712
+ this.options.onError?.(error, peerId);
713
+ } catch {}
714
+ }
576
715
  onSignal(from, msg) {
577
716
  let pc = this.connections.get(from);
717
+ if (pc && msg.type === "offer" && (pc.getRole() === "responder" || pc.hasRemoteDescription())) {
718
+ this.forget(from, pc);
719
+ pc = void 0;
720
+ }
578
721
  if (!pc) {
579
722
  if (msg.type !== "offer") return;
580
- pc = this.makeConnection(from, "responder");
581
- pc.open().then((channel) => {
723
+ const responder = this.makeConnection(from, "responder");
724
+ pc = responder;
725
+ responder.open().then((channel) => {
582
726
  for (const handler of this.connectionHandlers) handler(from, channel);
583
- });
727
+ }, (err) => this.fail(from, responder, err));
584
728
  }
585
- pc.handleSignal(msg);
729
+ const target = pc;
730
+ target.handleSignal(msg).catch((err) => this.fail(from, target, err));
586
731
  }
587
732
  };
588
733
  //#endregion
@@ -618,13 +763,44 @@ function compressSdp(sdp) {
618
763
  function expandSdp(compressed) {
619
764
  return `${compressed.split("\n").join("\r\n")}\r\n`;
620
765
  }
621
- /** Compress an ICE candidate to its essential parts. */
766
+ /**
767
+ * Candidate attributes after `typ` that a connection needs: the related
768
+ * address of a srflx/relay candidate and the TCP type of a TCP one. Others
769
+ * (`generation`, `ufrag`, `network-id`, ...) are dropped to keep the QR small.
770
+ */
771
+ const KEPT_CANDIDATE_ATTRIBUTES = /* @__PURE__ */ new Set([
772
+ "raddr",
773
+ "rport",
774
+ "tcptype"
775
+ ]);
776
+ /** An `sdpMLineIndex` as it travels: empty for null. */
777
+ function indexToString(index) {
778
+ return index == null ? "" : String(index);
779
+ }
780
+ function indexFromString(text) {
781
+ if (!text) return null;
782
+ const index = Number.parseInt(text, 10);
783
+ return Number.isNaN(index) ? null : index;
784
+ }
785
+ /**
786
+ * Compress an ICE candidate to its essential parts. A candidate that carries
787
+ * attributes a connection needs (see {@link KEPT_CANDIDATE_ATTRIBUTES}) goes
788
+ * in the raw (`R:`) form, with only those attributes kept.
789
+ */
622
790
  function compressCandidate(candidate) {
623
791
  const { candidate: c, sdpMid, sdpMLineIndex } = candidate;
624
- const match = c.match(/candidate:(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+typ\s+(\S+)/);
625
- if (!match) return `R:${sdpMid ?? ""}:${sdpMLineIndex ?? 0}:${c}`;
626
- const [, foundation, component, protocol, priority, ip, port, type] = match;
627
- return `${foundation}|${component}|${protocol}|${priority}|${ip}|${port}|${type}|${sdpMid ?? ""}|${sdpMLineIndex ?? 0}`;
792
+ const index = indexToString(sdpMLineIndex);
793
+ const match = c.match(/candidate:(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+typ\s+(\S+)(.*)$/);
794
+ if (!match) return `R:${sdpMid ?? ""}:${index}:${c}`;
795
+ const [base, foundation, component, protocol, priority, ip, port, type, rest] = match;
796
+ const words = rest.trim().split(/\s+/).filter(Boolean);
797
+ const kept = [];
798
+ for (let i = 0; i + 1 < words.length; i += 2) if (KEPT_CANDIDATE_ATTRIBUTES.has(words[i])) kept.push(words[i], words[i + 1]);
799
+ if (kept.length) {
800
+ const head = base.slice(0, base.length - rest.length);
801
+ return `R:${sdpMid ?? ""}:${index}:${head} ${kept.join(" ")}`;
802
+ }
803
+ return `${foundation}|${component}|${protocol}|${priority}|${ip}|${port}|${type}|${sdpMid ?? ""}|${index}`;
628
804
  }
629
805
  /** Expand a compressed ICE candidate. */
630
806
  function expandCandidate(compressed) {
@@ -633,7 +809,7 @@ function expandCandidate(compressed) {
633
809
  return {
634
810
  candidate: rest.join(":"),
635
811
  sdpMid: sdpMid || null,
636
- sdpMLineIndex: Number.parseInt(sdpMLineIndexStr, 10) || null
812
+ sdpMLineIndex: indexFromString(sdpMLineIndexStr)
637
813
  };
638
814
  }
639
815
  const parts = compressed.split("|");
@@ -642,7 +818,7 @@ function expandCandidate(compressed) {
642
818
  return {
643
819
  candidate: `candidate:${foundation} ${component} ${protocol} ${priority} ${ip} ${port} typ ${type}`,
644
820
  sdpMid: sdpMid || null,
645
- sdpMLineIndex: sdpMLineIndexStr ? Number.parseInt(sdpMLineIndexStr, 10) : null
821
+ sdpMLineIndex: indexFromString(sdpMLineIndexStr)
646
822
  };
647
823
  }
648
824
  /** Create a compressed signal for QR code exchange. */
@@ -702,7 +878,6 @@ var QrSignaling = class {
702
878
  /** Create an offer QR; `accept(answerQr)` finishes the handshake. */
703
879
  async offer() {
704
880
  const pc = new PeerConnection("initiator", this.connection);
705
- const channel = pc.open();
706
881
  await pc.connect();
707
882
  await pc.waitForIceGathering();
708
883
  const description = pc.getLocalDescription();
@@ -710,15 +885,22 @@ var QrSignaling = class {
710
885
  return {
711
886
  qr: encodeSignal(createCompressedSignal(this.sessionId, "initiator", description, pc.getCollectedCandidates())),
712
887
  accept: async (answerQr) => {
713
- const parsed = parseCompressedSignal(decodeSignal(answerQr));
714
- await pc.handleSignal({
715
- type: "answer",
716
- sdp: parsed.description.sdp
717
- });
718
- for (const candidate of parsed.candidates) await pc.handleSignal({
719
- type: "candidate",
720
- candidate
721
- });
888
+ const channel = pc.open();
889
+ try {
890
+ const parsed = parseCompressedSignal(decodeSignal(answerQr));
891
+ await pc.handleSignal({
892
+ type: "answer",
893
+ sdp: parsed.description.sdp
894
+ });
895
+ for (const candidate of parsed.candidates) await pc.handleSignal({
896
+ type: "candidate",
897
+ candidate
898
+ });
899
+ } catch (err) {
900
+ channel.catch(() => void 0);
901
+ pc.close();
902
+ throw err;
903
+ }
722
904
  return channel;
723
905
  }
724
906
  };
@@ -830,10 +1012,10 @@ var RoomManager = class {
830
1012
  } };
831
1013
  } };
832
1014
  }
833
- /** Open a {@link ByteChannel} to a specific participant. */
834
- async channelTo(peerId) {
1015
+ /** Open a {@link ByteChannel} to a specific participant (see {@link byteChannelFromRoom}). */
1016
+ async channelTo(peerId, options) {
835
1017
  if (!this.room) throw new Error("channelTo() before join()");
836
- return byteChannelFromRoom(this.room, peerId);
1018
+ return byteChannelFromRoom(this.room, peerId, options);
837
1019
  }
838
1020
  /** Leave the room: unsubscribe and disconnect. */
839
1021
  async leave() {
@@ -847,4 +1029,4 @@ var RoomManager = class {
847
1029
  }
848
1030
  };
849
1031
  //#endregion
850
- export { DEFAULT_ICE_SERVERS, DEFAULT_MAX_MESSAGE_SIZE, PeerConnection, PeerManager, QrSignaling, ROOM_EVENT, RoomManager, byteChannelFromDataChannel, byteChannelFromRoom, createCompressedSignal, decodeSignal, encodeSignal, generateSessionId, messageTargetOverByteChannel, parseCompressedSignal };
1032
+ export { DEFAULT_ICE_SERVERS, DEFAULT_MAX_MESSAGE_SIZE, DEFAULT_ROOM_MAX_FRAME_BYTES, DEFAULT_ROOM_TOPIC, DRAIN_LOW_WATER, PeerConnection, PeerManager, QrSignaling, ROOM_EVENT, RoomManager, byteChannelFromDataChannel, byteChannelFromRoom, createCompressedSignal, decodeSignal, encodeSignal, generateSessionId, messageTargetOverByteChannel, parseCompressedSignal };
@@ -1,5 +1,5 @@
1
+ import { type MessagePipe, type MessagePipeTarget } from "@statewalker/webrun-streams";
1
2
  import type { ByteChannel } from "./types.js";
2
- type Listener = (event: MessageEvent) => void | Promise<void>;
3
3
  /**
4
4
  * The payload ceiling for a channel over an `RTCDataChannel` (`PeerManager`,
5
5
  * `QrSignaling`, `PeerConnection`): 16 KiB, the message size every browser
@@ -10,16 +10,14 @@ type Listener = (event: MessageEvent) => void | Promise<void>;
10
10
  */
11
11
  export declare const DEFAULT_MAX_MESSAGE_SIZE: number;
12
12
  /** What `messageTargetOverByteChannel` gives: a pipe of bytes, its life, and its payload ceiling. */
13
- export interface ByteChannelMessageTarget {
14
- /** A `MessageTarget` (as `@statewalker/webrun-rpc` defines it) of bytes, one channel message each. */
15
- target: {
16
- addEventListener(type: "message", listener: Listener): void;
17
- removeEventListener(type: "message", listener: Listener): void;
18
- /** Sends one message; `TypeError` for anything but bytes. */
19
- postMessage(message: unknown): void;
20
- /** Closes the channel. */
21
- close(): Promise<void>;
22
- };
13
+ export interface ByteChannelMessageTarget extends MessagePipe {
14
+ /**
15
+ * A `MessageTarget` (as `@statewalker/webrun-rpc` defines it) of bytes, one
16
+ * channel message each. `bufferedAmount` is the channel's (0 where it cannot
17
+ * tell); `whenDrained` is the channel's, or resolves at once over a channel
18
+ * without one.
19
+ */
20
+ target: MessagePipeTarget;
23
21
  /** Aborts when the channel closes. Pass it as `overPipe`'s `signal`. */
24
22
  signal: AbortSignal;
25
23
  /** Pass as `overPipe`'s `maxMessageSize`. */
@@ -43,6 +41,6 @@ export interface ByteChannelMessageTarget {
43
41
  */
44
42
  export declare function messageTargetOverByteChannel(channel: ByteChannel, options?: {
45
43
  maxMessageSize?: number;
44
+ maxFrameBytes?: number;
46
45
  }): ByteChannelMessageTarget;
47
- export {};
48
46
  //# sourceMappingURL=message-target.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-target.d.ts","sourceRoot":"","sources":["../src/message-target.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,QAAkB,CAAC;AAExD,qGAAqG;AACrG,MAAM,WAAW,wBAAwB;IACvC,sGAAsG;IACtG,MAAM,EAAE;QACN,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;QAC5D,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;QAC/D,6DAA6D;QAC7D,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;QACpC,0BAA0B;QAC1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;KACxB,CAAC;IACF,wEAAwE;IACxE,MAAM,EAAE,WAAW,CAAC;IACpB,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAO,GACxC,wBAAwB,CA6D1B"}
1
+ {"version":3,"file":"message-target.d.ts","sourceRoot":"","sources":["../src/message-target.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,QAAkB,CAAC;AAExD,qGAAqG;AACrG,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D;;;;;OAKG;IACH,MAAM,EAAE,iBAAiB,CAAC;IAC1B,wEAAwE;IACxE,MAAM,EAAE,WAAW,CAAC;IACpB,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;CACxB;AAKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GAChE,wBAAwB,CAoD1B"}
@@ -32,6 +32,8 @@ export declare class PeerConnection {
32
32
  constructor(role: PeerRole, options?: WebRtcConnectionOptions);
33
33
  getState(): ConnectionState;
34
34
  getRole(): PeerRole;
35
+ /** Whether the remote description (the peer's offer or answer) has been applied. */
36
+ hasRemoteDescription(): boolean;
35
37
  getDataChannel(): RTCDataChannel | null;
36
38
  on<K extends keyof PeerConnectionEvents>(event: K, listener: PeerConnectionEvents[K]): this;
37
39
  off<K extends keyof PeerConnectionEvents>(event: K, listener: PeerConnectionEvents[K]): this;
@@ -1 +1 @@
1
- {"version":3,"file":"peer-connection.d.ts","sourceRoot":"","sources":["../src/peer-connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AASpB;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAW;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAClD,OAAO,CAAC,EAAE,CAAkC;IAC5C,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,KAAK,CAA0B;IAEvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAGZ;IAEd,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,oBAAoB,CAAS;IAErC,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,oBAAoB,CAAS;IAErC,YAAY,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAE,uBAA4B,EAGhE;IAED,QAAQ,IAAI,eAAe,CAE1B;IAED,OAAO,IAAI,QAAQ,CAElB;IAED,cAAc,IAAI,cAAc,GAAG,IAAI,CAEtC;IAED,EAAE,CAAC,CAAC,SAAS,MAAM,oBAAoB,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI,CAQ1F;IAED,GAAG,CAAC,CAAC,SAAS,MAAM,oBAAoB,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE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are new.
10
10
  */
11
11
  import type { ByteChannel, SignalingTransport, WebRtcConnectionOptions } from "./types.js";
12
- export type PeerManagerOptions = WebRtcConnectionOptions;
12
+ export type PeerManagerOptions = WebRtcConnectionOptions & {
13
+ /**
14
+ * Called when a connection fails with no caller to tell: a signal it
15
+ * rejects (an offer during glare, malformed SDP or candidates), or an
16
+ * inbound connection whose channel never opens. The connection has already
17
+ * been closed and forgotten, so the peer can dial again. Errors are dropped
18
+ * when unset. A failed `connect()` rejects instead.
19
+ */
20
+ onError?: (error: Error, peerId: string) => void;
21
+ };
13
22
  export declare class PeerManager {
14
23
  private readonly signaling;
15
24
  private readonly options;
@@ -24,6 +33,9 @@ export declare class PeerManager {
24
33
  /** Tear down all connections and stop listening for signaling. */
25
34
  close(): void;
26
35
  private makeConnection;
36
+ /** Close `pc` and drop it, unless a newer connection to `peerId` replaced it. */
37
+ private forget;
38
+ private fail;
27
39
  private onSignal;
28
40
  }
29
41
  //# sourceMappingURL=peer-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"peer-manager.d.ts","sourceRoot":"","sources":["../src/peer-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,WAAW,EAEX,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAEzD,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqC;IACjE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAwD;IAC3F,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IAEzC,YAAY,SAAS,EAAE,kBAAkB,EAAE,OAAO,GAAE,kBAAuB,EAI1E;IAED,8DAA8D;IACxD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAA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