@yz-social/webrtc 0.1.14 → 0.1.15

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 +10 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -26,6 +26,13 @@ export class WebRTC {
26
26
  delete this.dataChannelOursPromises;
27
27
  delete this.dataChannelTheirsPromises;
28
28
  }
29
+ reportStates(label) {
30
+ const pc = this.pc;
31
+ const sctp = pc?.sctp;
32
+ const transport = sctp?.transport;
33
+ const iceTransport = transport?.iceTransport;
34
+ this.flog(label, 'connectionState:', pc?.connectionState, 'signalingState:', pc?.signalingState, 'iceConnectionState:', pc?.iceConnectionState, 'iceGatheringState:', pc?.iceGatheringState, 'transport state:', sctp?.state, transport?.state, iceTransport?.state, iceTransport?.gatheringState);
35
+ }
29
36
 
30
37
  // Number of instances at a time (if previous have been garbage collected), as of 1/27/26:
31
38
  static suggestedInstancesLimit =
@@ -46,7 +53,7 @@ export class WebRTC {
46
53
  if (!pc) return null;
47
54
  const state = pc.connectionState;
48
55
  if (state === 'connected') return this.signalsReadyResolver?.();
49
- if (['new', 'connecting'/*, 'failed'*/].includes(state)) return null; // On failed, iceconnectionstatechange will restartIce.
56
+ if (['new', 'connecting', 'failed'].includes(state)) return null; // On failed, iceconnectionstatechange will restartIce.
50
57
  // closed, disconnected: resolve this.closed promise.
51
58
  this.cleanup();
52
59
  return resolve(pc);
@@ -75,7 +82,7 @@ export class WebRTC {
75
82
  this._resolveIceCompleted?.(true);
76
83
  break;
77
84
  case 'failed': // This doesn't mean the connection is broken. It could just be looking for a better transport.
78
- this.pc.restartIce();
85
+ this.renegotiate();
79
86
  break;
80
87
  default:
81
88
  ;
@@ -97,7 +104,7 @@ export class WebRTC {
97
104
  };
98
105
  }
99
106
  async renegotiate() { // Trigger negotiationneeded and promise to resolve when completed. Used in testing.
100
- this._resolveIceCompleted?.(false); // clearing old promise, if any.
107
+ if (this._iceConnected) return this._iceConnected;
101
108
  const promise = this.iceConnected;
102
109
  this.pc.restartIce();
103
110
  return promise;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yz-social/webrtc",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Streamlined portable webrtc management of p2p and client2server.",
5
5
  "keywords": [
6
6
  "webrtc",