livekit-client 1.2.5 → 1.2.6

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.
@@ -10357,7 +10357,7 @@ function computeBitrate(currentStats, prevStats) {
10357
10357
  return (bytesNow - bytesPrev) * 8 * 1000 / (currentStats.timestamp - prevStats.timestamp);
10358
10358
  }
10359
10359
 
10360
- var version$1 = "1.2.5";
10360
+ var version$1 = "1.2.6";
10361
10361
 
10362
10362
  const version = version$1;
10363
10363
  const protocolVersion = 8;
@@ -21097,6 +21097,7 @@ class Room extends events.exports.EventEmitter {
21097
21097
  this.recreateEngine();
21098
21098
  this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
21099
21099
  reject(new ConnectionError('could not establish signal connection'));
21100
+ return;
21100
21101
  } // don't return until ICE connected
21101
21102
 
21102
21103
 
@@ -21134,9 +21135,8 @@ class Room extends events.exports.EventEmitter {
21134
21135
  this.setAndEmitConnectionState(ConnectionState.Connected);
21135
21136
  resolve();
21136
21137
  });
21137
- });
21138
+ }).finally(() => this.connectFuture = undefined);
21138
21139
  this.connectFuture = new Future(connectPromise);
21139
- this.connectFuture.promise.finally(() => this.connectFuture = undefined);
21140
21140
  return this.connectFuture.promise;
21141
21141
  };
21142
21142
  /**
@@ -21265,10 +21265,7 @@ class Room extends events.exports.EventEmitter {
21265
21265
 
21266
21266
  if (info.state === ParticipantInfo_State.DISCONNECTED) {
21267
21267
  this.handleParticipantDisconnected(info.sid, remoteParticipant);
21268
- } else if (isNewParticipant) {
21269
- // fire connected event
21270
- this.emitWhenConnected(RoomEvent.ParticipantConnected, remoteParticipant);
21271
- } else {
21268
+ } else if (!isNewParticipant) {
21272
21269
  // just update, no events
21273
21270
  remoteParticipant.updateInfo(info);
21274
21271
  }
@@ -21712,13 +21709,15 @@ class Room extends events.exports.EventEmitter {
21712
21709
  }
21713
21710
 
21714
21711
  onTrackAdded(mediaTrack, stream, receiver) {
21715
- // don't fire onSubscribed when connecting
21712
+ var _a, _b; // don't fire onSubscribed when connecting
21716
21713
  // WebRTC fires onTrack as soon as setRemoteDescription is called on the offer
21717
21714
  // at that time, ICE connectivity has not been established so the track is not
21718
21715
  // technically subscribed.
21719
21716
  // We'll defer these events until when the room is connected or eventually disconnected.
21720
- if (this.connectFuture) {
21721
- this.connectFuture.promise.then(() => {
21717
+
21718
+
21719
+ if (this.connectFuture || this.reconnectFuture) {
21720
+ Promise.allSettled([(_a = this.connectFuture) === null || _a === void 0 ? void 0 : _a.promise, (_b = this.reconnectFuture) === null || _b === void 0 ? void 0 : _b.promise]).then(() => {
21722
21721
  this.onTrackAdded(mediaTrack, stream, receiver);
21723
21722
  });
21724
21723
  return;
@@ -21860,7 +21859,10 @@ class Room extends events.exports.EventEmitter {
21860
21859
  this.participants.set(id, participant);
21861
21860
 
21862
21861
  if (info) {
21863
- this.identityToSid.set(info.identity, info.sid);
21862
+ this.identityToSid.set(info.identity, info.sid); // if we have valid info and the participant wasn't in the map before, we can assume the participant is new
21863
+ // firing here to make sure that `ParticipantConnected` fires before the initial track events
21864
+
21865
+ this.emitWhenConnected(RoomEvent.ParticipantConnected, participant);
21864
21866
  } // also forward events
21865
21867
  // trackPublished is only fired for tracks added after both local participant
21866
21868
  // and remote participant joined the room