livekit-client 1.15.9 → 1.15.11
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +38 -19
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts +1 -1
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +2 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/errors.d.ts +2 -1
- package/dist/src/room/errors.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +1 -1
- package/dist/ts4.2/src/room/Room.d.ts +2 -1
- package/dist/ts4.2/src/room/errors.d.ts +2 -1
- package/package.json +1 -1
- package/src/api/SignalClient.ts +14 -5
- package/src/room/RTCEngine.ts +3 -0
- package/src/room/Room.ts +26 -17
- package/src/room/errors.ts +1 -0
@@ -10614,7 +10614,7 @@ function getMatch(exp, ua) {
|
|
10614
10614
|
return match && match.length >= id && match[id] || '';
|
10615
10615
|
}
|
10616
10616
|
|
10617
|
-
var version$1 = "1.15.
|
10617
|
+
var version$1 = "1.15.11";
|
10618
10618
|
|
10619
10619
|
const version = version$1;
|
10620
10620
|
const protocolVersion = 11;
|
@@ -14938,7 +14938,7 @@ class SignalClient {
|
|
14938
14938
|
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener('abort', abortHandler);
|
14939
14939
|
this.log.debug("connecting to ".concat(url + params), this.logContext);
|
14940
14940
|
if (this.ws) {
|
14941
|
-
yield this.close();
|
14941
|
+
yield this.close(false);
|
14942
14942
|
}
|
14943
14943
|
this.ws = new WebSocket(url + params);
|
14944
14944
|
this.ws.binaryType = 'arraybuffer';
|
@@ -15005,7 +15005,7 @@ class SignalClient {
|
|
15005
15005
|
shouldProcessMessage = true;
|
15006
15006
|
}
|
15007
15007
|
} else if (this.isEstablishingConnection && resp.message.case === 'leave') {
|
15008
|
-
reject(new ConnectionError('Received leave request while trying to (re)connect'));
|
15008
|
+
reject(new ConnectionError('Received leave request while trying to (re)connect', 4 /* ConnectionErrorReason.LeaveRequest */));
|
15009
15009
|
} else if (!opts.reconnect) {
|
15010
15010
|
// non-reconnect case, should receive join response first
|
15011
15011
|
reject(new ConnectionError("did not receive join response, got ".concat((_d = resp.message) === null || _d === void 0 ? void 0 : _d.case, " instead")));
|
@@ -15035,10 +15035,13 @@ class SignalClient {
|
|
15035
15035
|
}));
|
15036
15036
|
}
|
15037
15037
|
close() {
|
15038
|
+
let updateState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
15038
15039
|
return __awaiter(this, void 0, void 0, function* () {
|
15039
15040
|
const unlock = yield this.closingLock.lock();
|
15040
15041
|
try {
|
15041
|
-
|
15042
|
+
if (updateState) {
|
15043
|
+
this.state = SignalConnectionState.DISCONNECTING;
|
15044
|
+
}
|
15042
15045
|
if (this.ws) {
|
15043
15046
|
this.ws.onmessage = null;
|
15044
15047
|
this.ws.onopen = null;
|
@@ -15061,7 +15064,9 @@ class SignalClient {
|
|
15061
15064
|
this.ws = undefined;
|
15062
15065
|
}
|
15063
15066
|
} finally {
|
15064
|
-
|
15067
|
+
if (updateState) {
|
15068
|
+
this.state = SignalConnectionState.DISCONNECTED;
|
15069
|
+
}
|
15065
15070
|
this.clearPingInterval();
|
15066
15071
|
unlock();
|
15067
15072
|
}
|
@@ -17781,6 +17786,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
17781
17786
|
if (error instanceof ConnectionError && error.reason === 0 /* ConnectionErrorReason.NotAllowed */) {
|
17782
17787
|
throw new UnexpectedConnectionState('could not reconnect, token might be expired');
|
17783
17788
|
}
|
17789
|
+
if (error instanceof ConnectionError && error.reason === 4 /* ConnectionErrorReason.LeaveRequest */) {
|
17790
|
+
throw error;
|
17791
|
+
}
|
17784
17792
|
throw new SignalReconnectError(message);
|
17785
17793
|
}
|
17786
17794
|
this.emit(EngineEvent.SignalResumed);
|
@@ -21758,6 +21766,7 @@ class Room extends eventsExports.EventEmitter {
|
|
21758
21766
|
this.audioEnabled = true;
|
21759
21767
|
this.isVideoPlaybackBlocked = false;
|
21760
21768
|
this.log = livekitLogger;
|
21769
|
+
this.bufferedEvents = [];
|
21761
21770
|
this.connect = (url, token, opts) => __awaiter(this, void 0, void 0, function* () {
|
21762
21771
|
var _c;
|
21763
21772
|
// In case a disconnect called happened right before the connect call, make sure the disconnect is completed first by awaiting its lock
|
@@ -22034,10 +22043,15 @@ class Room extends eventsExports.EventEmitter {
|
|
22034
22043
|
}
|
22035
22044
|
// set the srcObject to null on page hide in order to prevent lock screen controls to show up for it
|
22036
22045
|
dummyAudioEl.srcObject = document.hidden ? null : stream;
|
22046
|
+
if (!document.hidden) {
|
22047
|
+
this.log.debug('page visible again, triggering startAudio to resume playback and update playback status', this.logContext);
|
22048
|
+
this.startAudio();
|
22049
|
+
}
|
22037
22050
|
});
|
22038
22051
|
document.body.append(dummyAudioEl);
|
22039
22052
|
this.once(RoomEvent.Disconnected, () => {
|
22040
22053
|
dummyAudioEl === null || dummyAudioEl === void 0 ? void 0 : dummyAudioEl.remove();
|
22054
|
+
dummyAudioEl = null;
|
22041
22055
|
});
|
22042
22056
|
}
|
22043
22057
|
elements.push(dummyAudioEl);
|
@@ -22098,7 +22112,7 @@ class Room extends eventsExports.EventEmitter {
|
|
22098
22112
|
this.log.debug("signal reconnected to server, region ".concat(joinResponse.serverRegion), Object.assign(Object.assign({}, this.logContext), {
|
22099
22113
|
region: joinResponse.serverRegion
|
22100
22114
|
}));
|
22101
|
-
this.
|
22115
|
+
this.bufferedEvents = [];
|
22102
22116
|
this.applyJoinResponse(joinResponse);
|
22103
22117
|
try {
|
22104
22118
|
// unpublish & republish tracks
|
@@ -22120,10 +22134,7 @@ class Room extends eventsExports.EventEmitter {
|
|
22120
22134
|
this.setAndEmitConnectionState(ConnectionState.Connected);
|
22121
22135
|
this.emit(RoomEvent.Reconnected);
|
22122
22136
|
this.registerConnectionReconcile();
|
22123
|
-
|
22124
|
-
this.participants.forEach(participant => {
|
22125
|
-
this.emit(RoomEvent.ParticipantConnected, participant);
|
22126
|
-
});
|
22137
|
+
this.emitBufferedEvents();
|
22127
22138
|
});
|
22128
22139
|
this.handleParticipantUpdates = participantInfos => {
|
22129
22140
|
// handle changes to participant state, and send events
|
@@ -22352,7 +22363,6 @@ class Room extends eventsExports.EventEmitter {
|
|
22352
22363
|
};
|
22353
22364
|
this.setMaxListeners(100);
|
22354
22365
|
this.participants = new Map();
|
22355
|
-
this.cachedParticipantSids = [];
|
22356
22366
|
this.identityToSid = new Map();
|
22357
22367
|
this.options = Object.assign(Object.assign({}, roomOptionDefaults), options);
|
22358
22368
|
this.log = getLogger((_a = this.options.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.Room);
|
@@ -22455,17 +22465,14 @@ class Room extends eventsExports.EventEmitter {
|
|
22455
22465
|
if (this.setAndEmitConnectionState(ConnectionState.Reconnecting)) {
|
22456
22466
|
this.emit(RoomEvent.Reconnecting);
|
22457
22467
|
}
|
22458
|
-
this.cachedParticipantSids = Array.from(this.participants.keys());
|
22459
22468
|
}).on(EngineEvent.Resumed, () => {
|
22460
22469
|
this.setAndEmitConnectionState(ConnectionState.Connected);
|
22461
22470
|
this.emit(RoomEvent.Reconnected);
|
22462
22471
|
this.registerConnectionReconcile();
|
22463
22472
|
this.updateSubscriptions();
|
22464
|
-
|
22465
|
-
const diffParticipants = Array.from(this.participants.values()).filter(p => !this.cachedParticipantSids.includes(p.sid));
|
22466
|
-
diffParticipants.forEach(p => this.emit(RoomEvent.ParticipantConnected, p));
|
22467
|
-
this.cachedParticipantSids = [];
|
22473
|
+
this.emitBufferedEvents();
|
22468
22474
|
}).on(EngineEvent.SignalResumed, () => {
|
22475
|
+
this.bufferedEvents = [];
|
22469
22476
|
if (this.state === ConnectionState.Reconnecting) {
|
22470
22477
|
this.sendSyncState();
|
22471
22478
|
}
|
@@ -22774,6 +22781,7 @@ class Room extends eventsExports.EventEmitter {
|
|
22774
22781
|
// clear out existing remote participants, since they may have attached
|
22775
22782
|
// the old engine
|
22776
22783
|
this.participants.clear();
|
22784
|
+
this.bufferedEvents = [];
|
22777
22785
|
this.maybeCreateEngine();
|
22778
22786
|
}
|
22779
22787
|
onTrackAdded(mediaTrack, stream, receiver) {
|
@@ -22832,6 +22840,7 @@ class Room extends eventsExports.EventEmitter {
|
|
22832
22840
|
let reason = arguments.length > 1 ? arguments[1] : undefined;
|
22833
22841
|
var _a;
|
22834
22842
|
this.clearConnectionReconcile();
|
22843
|
+
this.bufferedEvents = [];
|
22835
22844
|
if (this.state === ConnectionState.Disconnected) {
|
22836
22845
|
return;
|
22837
22846
|
}
|
@@ -23056,12 +23065,22 @@ class Room extends eventsExports.EventEmitter {
|
|
23056
23065
|
this.emit(RoomEvent.ConnectionStateChanged, this.state);
|
23057
23066
|
return true;
|
23058
23067
|
}
|
23068
|
+
emitBufferedEvents() {
|
23069
|
+
this.bufferedEvents.forEach(_ref2 => {
|
23070
|
+
let [ev, args] = _ref2;
|
23071
|
+
this.emit(ev, ...args);
|
23072
|
+
});
|
23073
|
+
this.bufferedEvents = [];
|
23074
|
+
}
|
23059
23075
|
emitWhenConnected(event) {
|
23076
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
23077
|
+
args[_key - 1] = arguments[_key];
|
23078
|
+
}
|
23060
23079
|
if (this.state === ConnectionState.Connected) {
|
23061
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
23062
|
-
args[_key - 1] = arguments[_key];
|
23063
|
-
}
|
23064
23080
|
return this.emit(event, ...args);
|
23081
|
+
} else if (this.state === ConnectionState.Reconnecting) {
|
23082
|
+
// in case the room is reconnecting, buffer the events by firing them later after emitting RoomEvent.Reconnected
|
23083
|
+
this.bufferedEvents.push([event, args]);
|
23065
23084
|
}
|
23066
23085
|
return false;
|
23067
23086
|
}
|