@dimchansky/meshpost 0.1.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 +169 -33
- package/dist/blob.d.ts +45 -0
- package/dist/blob.js +364 -0
- package/dist/channel.d.ts +2 -2
- package/dist/channel.js +11 -3
- package/dist/combine.d.ts +18 -0
- package/dist/combine.js +340 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +5 -0
- package/dist/mqtt.js +33 -5
- package/dist/room.d.ts +38 -7
- package/dist/room.js +656 -57
- package/dist/signaling.d.ts +25 -1
- package/dist/signaling.js +49 -1
- package/dist/tabs.js +9 -1
- package/dist/turn.d.ts +13 -0
- package/dist/turn.js +213 -0
- package/dist/voice.d.ts +81 -0
- package/dist/voice.js +838 -0
- package/dist/ws.d.ts +14 -0
- package/dist/ws.js +272 -0
- package/docs/behavior.md +86 -14
- package/package.json +1 -1
package/dist/blob.js
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { createChannel } from './channel.js';
|
|
2
|
+
const opStart = 0x01;
|
|
3
|
+
const opData = 0x02;
|
|
4
|
+
const opAbort = 0x03;
|
|
5
|
+
const startHeaderBytes = 9;
|
|
6
|
+
const dataHeaderBytes = 5;
|
|
7
|
+
const abortFrameBytes = 5;
|
|
8
|
+
const maxPacketBytes = 16 * 1024;
|
|
9
|
+
const maxUint32 = 0xffff_ffff;
|
|
10
|
+
const defaultMaxReceiveBytes = 4 * 1024 * 1024;
|
|
11
|
+
const defaultChunkSize = 15 * 1024;
|
|
12
|
+
const defaultReceiveTimeoutMs = 30_000;
|
|
13
|
+
const defaultMaxConcurrentPerPeer = 4;
|
|
14
|
+
const encoder = new TextEncoder();
|
|
15
|
+
function listeners() {
|
|
16
|
+
const entries = new Set();
|
|
17
|
+
let closed = false;
|
|
18
|
+
return {
|
|
19
|
+
add(fn, options) {
|
|
20
|
+
const signal = options?.signal;
|
|
21
|
+
if (closed || signal?.aborted)
|
|
22
|
+
return () => { };
|
|
23
|
+
const entry = {
|
|
24
|
+
fn,
|
|
25
|
+
once: Boolean(options?.once),
|
|
26
|
+
off() {
|
|
27
|
+
if (!entries.delete(entry))
|
|
28
|
+
return;
|
|
29
|
+
signal?.removeEventListener('abort', entry.off);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
entries.add(entry);
|
|
33
|
+
signal?.addEventListener('abort', entry.off, { once: true });
|
|
34
|
+
return entry.off;
|
|
35
|
+
},
|
|
36
|
+
fire(...args) {
|
|
37
|
+
for (const entry of [...entries]) {
|
|
38
|
+
if (!entries.has(entry))
|
|
39
|
+
continue;
|
|
40
|
+
if (entry.once)
|
|
41
|
+
entry.off();
|
|
42
|
+
try {
|
|
43
|
+
entry.fn(...args);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
globalThis.reportError?.(error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
clear() {
|
|
51
|
+
closed = true;
|
|
52
|
+
for (const entry of [...entries])
|
|
53
|
+
entry.off();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a chunked reliable binary channel for payloads larger than Meshpost's 16 KiB packet limit.
|
|
59
|
+
* Built strictly on top of `createChannel(room, name, { delivery: 'reliable' })` and `room.onDrain`.
|
|
60
|
+
*/
|
|
61
|
+
export function createBlobChannel(room, name, options = {}) {
|
|
62
|
+
const channel = createChannel(room, name, { delivery: 'reliable' });
|
|
63
|
+
const nameBytesLen = encoder.encode(name).length;
|
|
64
|
+
const maxAllowedChunk = maxPacketBytes - (1 + nameBytesLen) - startHeaderBytes;
|
|
65
|
+
const maxReceiveBytes = options.maxReceiveBytes ?? defaultMaxReceiveBytes;
|
|
66
|
+
if (!Number.isSafeInteger(maxReceiveBytes) || maxReceiveBytes < 0 || maxReceiveBytes > maxUint32)
|
|
67
|
+
throw new RangeError('Invalid maxReceiveBytes');
|
|
68
|
+
const chunkSize = options.chunkSize ?? Math.min(defaultChunkSize, maxAllowedChunk);
|
|
69
|
+
if (!Number.isSafeInteger(chunkSize) || chunkSize <= 0 || chunkSize > maxAllowedChunk)
|
|
70
|
+
throw new RangeError(`chunkSize must be 1..${maxAllowedChunk}`);
|
|
71
|
+
const receiveTimeoutMs = options.receiveTimeoutMs ?? defaultReceiveTimeoutMs;
|
|
72
|
+
if (!Number.isSafeInteger(receiveTimeoutMs) ||
|
|
73
|
+
receiveTimeoutMs <= 0 ||
|
|
74
|
+
receiveTimeoutMs > 2_147_483_647)
|
|
75
|
+
throw new RangeError('Invalid receiveTimeoutMs');
|
|
76
|
+
const maxConcurrentPerPeer = options.maxConcurrentPerPeer ?? defaultMaxConcurrentPerPeer;
|
|
77
|
+
if (!Number.isSafeInteger(maxConcurrentPerPeer) ||
|
|
78
|
+
maxConcurrentPerPeer <= 0 ||
|
|
79
|
+
maxConcurrentPerPeer > 64)
|
|
80
|
+
throw new RangeError('Invalid maxConcurrentPerPeer');
|
|
81
|
+
const blobs = listeners();
|
|
82
|
+
const progresses = listeners();
|
|
83
|
+
const incoming = new Map();
|
|
84
|
+
const closeWaiters = new Set();
|
|
85
|
+
const internalAbort = new AbortController();
|
|
86
|
+
let nextTransferId = (crypto.getRandomValues(new Uint32Array(1))[0] & 0x7fff_ffff) + 1;
|
|
87
|
+
const isRoomClosed = () => room.signalingState === 'closed';
|
|
88
|
+
let closed = isRoomClosed();
|
|
89
|
+
const dropTransfer = (peerId, transferId) => {
|
|
90
|
+
const byPeer = incoming.get(peerId);
|
|
91
|
+
const entry = byPeer?.get(transferId);
|
|
92
|
+
if (!entry)
|
|
93
|
+
return;
|
|
94
|
+
clearTimeout(entry.timer);
|
|
95
|
+
byPeer.delete(transferId);
|
|
96
|
+
if (byPeer.size === 0)
|
|
97
|
+
incoming.delete(peerId);
|
|
98
|
+
};
|
|
99
|
+
const dropPeerTransfers = (peerId) => {
|
|
100
|
+
const byPeer = incoming.get(peerId);
|
|
101
|
+
if (!byPeer)
|
|
102
|
+
return;
|
|
103
|
+
for (const entry of byPeer.values())
|
|
104
|
+
clearTimeout(entry.timer);
|
|
105
|
+
incoming.delete(peerId);
|
|
106
|
+
};
|
|
107
|
+
const shutdown = () => {
|
|
108
|
+
if (closed)
|
|
109
|
+
return;
|
|
110
|
+
closed = true;
|
|
111
|
+
internalAbort.abort();
|
|
112
|
+
for (const byPeer of incoming.values()) {
|
|
113
|
+
for (const entry of byPeer.values())
|
|
114
|
+
clearTimeout(entry.timer);
|
|
115
|
+
}
|
|
116
|
+
incoming.clear();
|
|
117
|
+
for (const wake of [...closeWaiters])
|
|
118
|
+
wake();
|
|
119
|
+
closeWaiters.clear();
|
|
120
|
+
blobs.clear();
|
|
121
|
+
progresses.clear();
|
|
122
|
+
};
|
|
123
|
+
const sendAbort = (peerId, transferId) => {
|
|
124
|
+
if (isRoomClosed())
|
|
125
|
+
return;
|
|
126
|
+
const frame = new Uint8Array(abortFrameBytes);
|
|
127
|
+
const view = new DataView(frame.buffer);
|
|
128
|
+
frame[0] = opAbort;
|
|
129
|
+
view.setUint32(1, transferId);
|
|
130
|
+
try {
|
|
131
|
+
channel.send(frame, { to: peerId });
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// Ignore errors if room closed concurrently.
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const waitForDrain = (peerId, signal) => new Promise((resolve) => {
|
|
138
|
+
if (closed || signal?.aborted) {
|
|
139
|
+
resolve('abort');
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (isRoomClosed()) {
|
|
143
|
+
resolve('unavailable');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const ctrl = new AbortController();
|
|
147
|
+
let settled = false;
|
|
148
|
+
const done = (outcome) => {
|
|
149
|
+
if (settled)
|
|
150
|
+
return;
|
|
151
|
+
settled = true;
|
|
152
|
+
ctrl.abort();
|
|
153
|
+
closeWaiters.delete(onClose);
|
|
154
|
+
signal?.removeEventListener('abort', onAbort);
|
|
155
|
+
resolve(outcome);
|
|
156
|
+
};
|
|
157
|
+
const onClose = () => done('abort');
|
|
158
|
+
const onAbort = () => done('abort');
|
|
159
|
+
closeWaiters.add(onClose);
|
|
160
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
161
|
+
room.onDrain((id, delivery) => {
|
|
162
|
+
if (id === peerId && delivery === 'reliable')
|
|
163
|
+
done('drain');
|
|
164
|
+
}, { signal: ctrl.signal });
|
|
165
|
+
room.onPeerLeave((id) => {
|
|
166
|
+
if (id === peerId)
|
|
167
|
+
done('unavailable');
|
|
168
|
+
}, { signal: ctrl.signal });
|
|
169
|
+
});
|
|
170
|
+
const sendToPeer = async (peerId, bytes, options) => {
|
|
171
|
+
const { onProgress, signal } = options;
|
|
172
|
+
if (closed || signal?.aborted)
|
|
173
|
+
return 'aborted';
|
|
174
|
+
if (isRoomClosed())
|
|
175
|
+
return 'unavailable';
|
|
176
|
+
if (bytes.byteLength > maxUint32)
|
|
177
|
+
return 'too-large';
|
|
178
|
+
const transferId = ++nextTransferId >>> 0;
|
|
179
|
+
const totalBytes = bytes.byteLength;
|
|
180
|
+
let offset = 0;
|
|
181
|
+
let started = false;
|
|
182
|
+
while (true) {
|
|
183
|
+
if (closed || signal?.aborted) {
|
|
184
|
+
if (started)
|
|
185
|
+
sendAbort(peerId, transferId);
|
|
186
|
+
return 'aborted';
|
|
187
|
+
}
|
|
188
|
+
if (isRoomClosed())
|
|
189
|
+
return 'unavailable';
|
|
190
|
+
const isStart = !started;
|
|
191
|
+
const sliceEnd = Math.min(totalBytes, offset + chunkSize);
|
|
192
|
+
const slice = bytes.subarray(offset, sliceEnd);
|
|
193
|
+
const headerLen = isStart ? startHeaderBytes : dataHeaderBytes;
|
|
194
|
+
const frame = new Uint8Array(headerLen + slice.byteLength);
|
|
195
|
+
const view = new DataView(frame.buffer);
|
|
196
|
+
frame[0] = isStart ? opStart : opData;
|
|
197
|
+
view.setUint32(1, transferId);
|
|
198
|
+
if (isStart)
|
|
199
|
+
view.setUint32(5, totalBytes);
|
|
200
|
+
frame.set(slice, headerLen);
|
|
201
|
+
let result;
|
|
202
|
+
try {
|
|
203
|
+
result = channel.send(frame, { to: peerId });
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return 'unavailable';
|
|
207
|
+
}
|
|
208
|
+
const status = result.get(peerId);
|
|
209
|
+
if (status === 'accepted') {
|
|
210
|
+
started = true;
|
|
211
|
+
offset = sliceEnd;
|
|
212
|
+
try {
|
|
213
|
+
onProgress?.(peerId, offset, totalBytes);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
globalThis.reportError?.(error);
|
|
217
|
+
}
|
|
218
|
+
if (offset >= totalBytes)
|
|
219
|
+
return 'sent';
|
|
220
|
+
}
|
|
221
|
+
else if (status === 'busy') {
|
|
222
|
+
const outcome = await waitForDrain(peerId, signal);
|
|
223
|
+
if (outcome === 'abort') {
|
|
224
|
+
if (started)
|
|
225
|
+
sendAbort(peerId, transferId);
|
|
226
|
+
return 'aborted';
|
|
227
|
+
}
|
|
228
|
+
if (outcome === 'unavailable')
|
|
229
|
+
return 'unavailable';
|
|
230
|
+
}
|
|
231
|
+
else if (status === 'too-large') {
|
|
232
|
+
if (started)
|
|
233
|
+
sendAbort(peerId, transferId);
|
|
234
|
+
return 'too-large';
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
return 'unavailable';
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
if (!closed) {
|
|
242
|
+
const internalListen = { signal: internalAbort.signal };
|
|
243
|
+
room.onPeerLeave((peerId) => dropPeerTransfers(peerId), internalListen);
|
|
244
|
+
room.onSignalingChange((state) => {
|
|
245
|
+
if (state === 'closed')
|
|
246
|
+
shutdown();
|
|
247
|
+
}, internalListen);
|
|
248
|
+
channel.onPacket((from, bytes) => {
|
|
249
|
+
if (closed || bytes.byteLength < abortFrameBytes)
|
|
250
|
+
return;
|
|
251
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
252
|
+
const op = bytes[0];
|
|
253
|
+
const transferId = view.getUint32(1);
|
|
254
|
+
if (op === opAbort) {
|
|
255
|
+
dropTransfer(from, transferId);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (op === opStart) {
|
|
259
|
+
if (bytes.byteLength < startHeaderBytes)
|
|
260
|
+
return;
|
|
261
|
+
const totalBytes = view.getUint32(5);
|
|
262
|
+
const payload = bytes.subarray(startHeaderBytes);
|
|
263
|
+
if (totalBytes > maxReceiveBytes || payload.byteLength > totalBytes)
|
|
264
|
+
return;
|
|
265
|
+
const existingByPeer = incoming.get(from);
|
|
266
|
+
if (existingByPeer?.has(transferId))
|
|
267
|
+
return;
|
|
268
|
+
if (payload.byteLength === totalBytes) {
|
|
269
|
+
if (totalBytes > 0) {
|
|
270
|
+
progresses.fire(from, { transferId, receivedBytes: totalBytes, totalBytes });
|
|
271
|
+
}
|
|
272
|
+
blobs.fire(from, payload.slice());
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (existingByPeer && existingByPeer.size >= maxConcurrentPerPeer)
|
|
276
|
+
return;
|
|
277
|
+
const initialCap = Math.min(totalBytes, Math.max(payload.byteLength, 16 * 1024));
|
|
278
|
+
const buffer = new Uint8Array(initialCap);
|
|
279
|
+
if (payload.byteLength > 0)
|
|
280
|
+
buffer.set(payload, 0);
|
|
281
|
+
const timer = setTimeout(() => dropTransfer(from, transferId), receiveTimeoutMs);
|
|
282
|
+
const entry = {
|
|
283
|
+
totalBytes,
|
|
284
|
+
maxFrames: Math.ceil(totalBytes / 256) + 64,
|
|
285
|
+
receivedBytes: payload.byteLength,
|
|
286
|
+
frames: 1,
|
|
287
|
+
buffer,
|
|
288
|
+
timer
|
|
289
|
+
};
|
|
290
|
+
let byPeer = existingByPeer;
|
|
291
|
+
if (!byPeer) {
|
|
292
|
+
byPeer = new Map();
|
|
293
|
+
incoming.set(from, byPeer);
|
|
294
|
+
}
|
|
295
|
+
byPeer.set(transferId, entry);
|
|
296
|
+
if (entry.receivedBytes > 0) {
|
|
297
|
+
progresses.fire(from, { transferId, receivedBytes: entry.receivedBytes, totalBytes });
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (op === opData) {
|
|
302
|
+
if (bytes.byteLength <= dataHeaderBytes)
|
|
303
|
+
return;
|
|
304
|
+
const byPeer = incoming.get(from);
|
|
305
|
+
const entry = byPeer?.get(transferId);
|
|
306
|
+
if (!entry)
|
|
307
|
+
return;
|
|
308
|
+
const payload = bytes.subarray(dataHeaderBytes);
|
|
309
|
+
entry.frames++;
|
|
310
|
+
if (entry.frames > entry.maxFrames ||
|
|
311
|
+
entry.receivedBytes + payload.byteLength > entry.totalBytes) {
|
|
312
|
+
dropTransfer(from, transferId);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const needed = entry.receivedBytes + payload.byteLength;
|
|
316
|
+
if (needed > entry.buffer.byteLength) {
|
|
317
|
+
let nextCap = entry.buffer.byteLength;
|
|
318
|
+
while (nextCap < needed)
|
|
319
|
+
nextCap = Math.min(entry.totalBytes, nextCap * 2);
|
|
320
|
+
const grown = new Uint8Array(nextCap);
|
|
321
|
+
grown.set(entry.buffer.subarray(0, entry.receivedBytes), 0);
|
|
322
|
+
entry.buffer = grown;
|
|
323
|
+
}
|
|
324
|
+
entry.buffer.set(payload, entry.receivedBytes);
|
|
325
|
+
entry.receivedBytes = needed;
|
|
326
|
+
clearTimeout(entry.timer);
|
|
327
|
+
progresses.fire(from, {
|
|
328
|
+
transferId,
|
|
329
|
+
receivedBytes: entry.receivedBytes,
|
|
330
|
+
totalBytes: entry.totalBytes
|
|
331
|
+
});
|
|
332
|
+
if (closed || byPeer?.get(transferId) !== entry)
|
|
333
|
+
return;
|
|
334
|
+
if (entry.receivedBytes === entry.totalBytes) {
|
|
335
|
+
dropTransfer(from, transferId);
|
|
336
|
+
blobs.fire(from, entry.buffer);
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
entry.timer = setTimeout(() => dropTransfer(from, transferId), receiveTimeoutMs);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}, internalListen);
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
name,
|
|
346
|
+
async send(bytes, sendOptions = {}) {
|
|
347
|
+
if (closed || isRoomClosed())
|
|
348
|
+
throw new Error('BlobChannel is closed');
|
|
349
|
+
if (!(bytes instanceof Uint8Array))
|
|
350
|
+
throw new TypeError('Expected a Uint8Array');
|
|
351
|
+
const targets = sendOptions.to === undefined ? [...room.peers] : [sendOptions.to];
|
|
352
|
+
const results = new Map();
|
|
353
|
+
if (targets.length === 0)
|
|
354
|
+
return results;
|
|
355
|
+
await Promise.all(targets.map(async (peerId) => {
|
|
356
|
+
results.set(peerId, await sendToPeer(peerId, bytes, sendOptions));
|
|
357
|
+
}));
|
|
358
|
+
return results;
|
|
359
|
+
},
|
|
360
|
+
onBlob: blobs.add,
|
|
361
|
+
onProgress: progresses.add,
|
|
362
|
+
close: shutdown
|
|
363
|
+
};
|
|
364
|
+
}
|
package/dist/channel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Delivery, Room, SendResult } from './room.js';
|
|
1
|
+
import type { Delivery, ListenOptions, Room, SendResult } from './room.js';
|
|
2
2
|
export interface ChannelOptions {
|
|
3
3
|
/** Delivery mode for this logical channel. @default 'unreliable' */
|
|
4
4
|
delivery?: Delivery;
|
|
@@ -16,7 +16,7 @@ export interface Channel {
|
|
|
16
16
|
/** Send a binary packet on this named channel synchronously. Returns a per-recipient result map. */
|
|
17
17
|
send(bytes: Uint8Array, options?: ChannelSendOptions): ReadonlyMap<string, SendResult>;
|
|
18
18
|
/** Subscribe to packets sent to this channel name. Returns an unsubscribe function. */
|
|
19
|
-
onPacket(fn: (from: string, bytes: Uint8Array) => void): () => void;
|
|
19
|
+
onPacket(fn: (from: string, bytes: Uint8Array) => void, options?: ListenOptions): () => void;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Create a named logical channel multiplexed over a Room's existing data channels.
|
package/dist/channel.js
CHANGED
|
@@ -28,16 +28,24 @@ export function createChannel(room, name, options = {}) {
|
|
|
28
28
|
framed.set(bytes, prefix.length);
|
|
29
29
|
return room.send(framed, sendOptions.to === undefined ? { delivery } : { to: sendOptions.to, delivery });
|
|
30
30
|
},
|
|
31
|
-
onPacket(fn) {
|
|
32
|
-
|
|
31
|
+
onPacket(fn, options) {
|
|
32
|
+
if (options?.signal?.aborted)
|
|
33
|
+
return () => { };
|
|
34
|
+
const once = Boolean(options?.once);
|
|
35
|
+
const roomOptions = options?.signal ? { signal: options.signal } : undefined;
|
|
36
|
+
let off = () => { };
|
|
37
|
+
off = room.onPacket((from, bytes, mode) => {
|
|
33
38
|
if (mode !== delivery || bytes.byteLength < prefix.length)
|
|
34
39
|
return;
|
|
35
40
|
for (let i = 0; i < prefix.length; i++) {
|
|
36
41
|
if (bytes[i] !== prefix[i])
|
|
37
42
|
return;
|
|
38
43
|
}
|
|
44
|
+
if (once)
|
|
45
|
+
off();
|
|
39
46
|
fn(from, bytes.subarray(prefix.length));
|
|
40
|
-
});
|
|
47
|
+
}, roomOptions);
|
|
48
|
+
return off;
|
|
41
49
|
}
|
|
42
50
|
};
|
|
43
51
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Signaling } from './signaling.js';
|
|
2
|
+
/**
|
|
3
|
+
* Combine multiple signaling adapters into one composite adapter.
|
|
4
|
+
* Merges peer rosters across all children, routes signals to reachable children that advertise the target peer,
|
|
5
|
+
* and stays `'online'` as long as at least one child adapter is `'online'`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function combineSignaling(...adapters: readonly Signaling[]): Signaling;
|
|
8
|
+
/**
|
|
9
|
+
* Decorate a network signaling adapter (`mqttSignaling()`, `wsSignaling()`, etc.) with instant
|
|
10
|
+
* same-browser `BroadcastChannel` discovery (`tabSignaling()`).
|
|
11
|
+
*
|
|
12
|
+
* - Exposes `primary`'s `SignalingState` and errors for `room.signalingState` / `room.onSignalingChange`
|
|
13
|
+
* (avoiding a permanently `'online'` indicator when network connectivity is lost).
|
|
14
|
+
* - Still connects same-browser tabs locally even while `primary` is `'connecting'` or `'offline'`.
|
|
15
|
+
* - Safely falls back to `primary` alone when `BroadcastChannel` is unavailable, on `file:` / opaque
|
|
16
|
+
* origins, or if `new BroadcastChannel(...)` throws `SecurityError`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function withLocalTabs(primary: Signaling): Signaling;
|