@yz-social/webrtc 0.1.11 → 0.1.13

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.
Files changed (2) hide show
  1. package/index.js +7 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -30,7 +30,7 @@ export class WebRTC {
30
30
  // Number of instances at a time (if previous have been garbage collected), as of 1/27/26:
31
31
  static suggestedInstancesLimit =
32
32
  globalThis.navigator.vendor?.startsWith('Apple') ? 150 : // Safari will open 256, but it won't reliably keep them all open at once.
33
- globalThis.navigator.userAgent?.includes('Firefox') ? 150 : // I can sometimes get maybe a dozen more, but not with refresh.
33
+ globalThis.navigator.userAgent?.includes('Firefox') ? 150 : // 256 on an M5 chip. On an i9 MBP, I can sometimes get more than 150, but not with refresh.
34
34
  (typeof(globalThis.process) !== 'undefined') ? 249 : // NodeJS
35
35
  256;
36
36
  constructor({configuration = {iceServers: WebRTC.iceServers}, ...properties}) {
@@ -67,7 +67,7 @@ export class WebRTC {
67
67
  this.pc.ondatachannel = e => this.ondatachannel(e.channel);
68
68
  this.pc.onicecandidateerror = error => {
69
69
  const {errorCode, errorText, url, address, port} = error;
70
- console.error(errorText, {errorCode, url, address, port});
70
+ this.log(`${errorCode}: ${errorText || '(ice failure)'} ${address}:${port} @${url}`);
71
71
  };
72
72
  this.pc.oniceconnectionstatechange = () => {
73
73
  if (!this.pc) return;
@@ -203,13 +203,13 @@ export class WebRTC {
203
203
  pendingSignals = [];
204
204
  responseSerializer = Promise.resolve();
205
205
  async respond(signals = []) { // Apply a list of signals, and promise a list of responding signals as soon as any are available, or empty list when connected
206
- // This is used by a peer that is receiving signals in an out-of-band network request, and witing for a response. (Compare transferSignals.)
206
+ // This is used by a peer that is receiving signals in an out-of-band network request, and waiting for a response. (Compare transferSignals.)
207
207
  return this.responseSerializer = this.responseSerializer.then(async () => {
208
208
  this.log('respond', signals.length, 'signals');
209
- const {promise, resolve} = Promise.withResolvers;
209
+ const {promise, resolve} = Promise.withResolvers();
210
210
  this.signalsReadyResolver = resolve;
211
211
  await this.onSignals(signals);
212
- await promise;
212
+ if (!this.pendingSignals.length) await promise;
213
213
  this.signalsReadyResolver = null;
214
214
  return this.collectPendingSignals();
215
215
  });
@@ -330,11 +330,11 @@ export class WebRTC {
330
330
  return;
331
331
  }
332
332
  const remote = stats.get(candidatePair.remoteCandidateId);
333
- const {protocol, candidateType} = remote;
333
+ const {protocol, candidateType, address} = remote;
334
334
  const now = Date.now();
335
335
  const statsElapsed = now - this.connectionStartTime;
336
336
  Object.assign(this, {stats, transport, candidatePair, remote, protocol, candidateType, statsTime: now, statsElapsed});
337
- if (doLogging) console.info(this.name, 'connected', protocol, candidateType, (statsElapsed/1e3).toFixed(1));
337
+ if (doLogging) console.info(this.name, 'connected', protocol, candidateType, address, (statsElapsed/1e3).toFixed(1));
338
338
  }
339
339
 
340
340
  static getPublicIP(stunServer = "stun:stun.l.google.com:19302") { // Promise external/WAN/public IP addresses for this device.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yz-social/webrtc",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Streamlined portable webrtc management of p2p and client2server.",
5
5
  "keywords": [
6
6
  "webrtc",