livekit-client 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/livekit-client.esm.mjs +62 -21
- 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.map +1 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/RegionUrlProvider.d.ts +1 -0
- package/dist/src/room/RegionUrlProvider.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/track/RemoteTrack.d.ts.map +1 -1
- package/dist/src/room/track/Track.d.ts +4 -1
- package/dist/src/room/track/Track.d.ts.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/ts4.2/src/room/RegionUrlProvider.d.ts +1 -0
- package/dist/ts4.2/src/room/track/Track.d.ts +4 -1
- package/dist/ts4.2/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/SignalClient.ts +3 -1
- package/src/room/RTCEngine.ts +47 -10
- package/src/room/RegionUrlProvider.ts +5 -0
- package/src/room/Room.ts +2 -1
- package/src/room/track/RemoteTrack.ts +7 -4
- package/src/room/track/Track.ts +1 -1
- package/src/version.ts +1 -1
@@ -10499,10 +10499,10 @@ function getOSVersion(ua) {
|
|
10499
10499
|
return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
|
10500
10500
|
}
|
10501
10501
|
|
10502
|
-
var version$1 = "2.1.
|
10502
|
+
var version$1 = "2.1.3";
|
10503
10503
|
|
10504
10504
|
const version = version$1;
|
10505
|
-
const protocolVersion =
|
10505
|
+
const protocolVersion = 13;
|
10506
10506
|
|
10507
10507
|
/**
|
10508
10508
|
* Timers that can be overridden with platform specific implementations
|
@@ -12933,8 +12933,9 @@ class SignalClient {
|
|
12933
12933
|
return this.sendRequest({
|
12934
12934
|
case: 'leave',
|
12935
12935
|
value: new LeaveRequest({
|
12936
|
-
|
12937
|
-
|
12936
|
+
reason: DisconnectReason.CLIENT_INITIATED,
|
12937
|
+
// server doesn't process this field, keeping it here to indicate the intent of a full disconnect
|
12938
|
+
action: LeaveRequest_Action.DISCONNECT
|
12938
12939
|
})
|
12939
12940
|
});
|
12940
12941
|
}
|
@@ -16223,7 +16224,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
16223
16224
|
}
|
16224
16225
|
configure(joinResponse) {
|
16225
16226
|
return __awaiter(this, void 0, void 0, function* () {
|
16226
|
-
var _a;
|
16227
|
+
var _a, _b;
|
16227
16228
|
// already configured
|
16228
16229
|
if (this.pcManager && this.pcManager.currentState !== PCTransportState.NEW) {
|
16229
16230
|
return;
|
@@ -16268,7 +16269,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
16268
16269
|
this.pcManager.onTrack = ev => {
|
16269
16270
|
this.emit(EngineEvent.MediaTrackAdded, ev.track, ev.streams[0], ev.receiver);
|
16270
16271
|
};
|
16271
|
-
|
16272
|
+
if (!supportOptionalDatachannel((_b = joinResponse.serverInfo) === null || _b === void 0 ? void 0 : _b.protocol)) {
|
16273
|
+
this.createDataChannels();
|
16274
|
+
}
|
16272
16275
|
});
|
16273
16276
|
}
|
16274
16277
|
setupSignalClientCallbacks() {
|
@@ -16335,17 +16338,27 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
16335
16338
|
this.handleDisconnect('signal', ReconnectReason.RR_SIGNAL_DISCONNECTED);
|
16336
16339
|
};
|
16337
16340
|
this.client.onLeave = leave => {
|
16338
|
-
if (leave === null || leave === void 0 ? void 0 : leave.canReconnect) {
|
16339
|
-
this.fullReconnectOnNext = true;
|
16340
|
-
// reconnect immediately instead of waiting for next attempt
|
16341
|
-
this.handleDisconnect(leaveReconnect);
|
16342
|
-
} else {
|
16343
|
-
this.emit(EngineEvent.Disconnected, leave === null || leave === void 0 ? void 0 : leave.reason);
|
16344
|
-
this.close();
|
16345
|
-
}
|
16346
16341
|
this.log.debug('client leave request', Object.assign(Object.assign({}, this.logContext), {
|
16347
16342
|
reason: leave === null || leave === void 0 ? void 0 : leave.reason
|
16348
16343
|
}));
|
16344
|
+
if (leave.regions && this.regionUrlProvider) {
|
16345
|
+
this.log.debug('updating regions', this.logContext);
|
16346
|
+
this.regionUrlProvider.setServerReportedRegions(leave.regions);
|
16347
|
+
}
|
16348
|
+
switch (leave.action) {
|
16349
|
+
case LeaveRequest_Action.DISCONNECT:
|
16350
|
+
this.emit(EngineEvent.Disconnected, leave === null || leave === void 0 ? void 0 : leave.reason);
|
16351
|
+
this.close();
|
16352
|
+
break;
|
16353
|
+
case LeaveRequest_Action.RECONNECT:
|
16354
|
+
this.fullReconnectOnNext = true;
|
16355
|
+
// reconnect immediately instead of waiting for next attempt
|
16356
|
+
this.handleDisconnect(leaveReconnect);
|
16357
|
+
break;
|
16358
|
+
case LeaveRequest_Action.RESUME:
|
16359
|
+
// reconnect immediately instead of waiting for next attempt
|
16360
|
+
this.handleDisconnect(leaveReconnect);
|
16361
|
+
}
|
16349
16362
|
};
|
16350
16363
|
}
|
16351
16364
|
makeRTCConfiguration(serverResponse) {
|
@@ -16729,7 +16742,15 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
16729
16742
|
if (!transport) {
|
16730
16743
|
throw new ConnectionError("".concat(transportName, " connection not set"));
|
16731
16744
|
}
|
16732
|
-
|
16745
|
+
let needNegotiation = false;
|
16746
|
+
if (!subscriber && !_this2.dataChannelForKind(kind, subscriber)) {
|
16747
|
+
_this2.createDataChannels();
|
16748
|
+
needNegotiation = true;
|
16749
|
+
}
|
16750
|
+
if (!needNegotiation && !subscriber && !_this2.pcManager.publisher.isICEConnected && _this2.pcManager.publisher.getICEConnectionState() !== 'checking') {
|
16751
|
+
needNegotiation = true;
|
16752
|
+
}
|
16753
|
+
if (needNegotiation) {
|
16733
16754
|
// start negotiation
|
16734
16755
|
_this2.negotiate();
|
16735
16756
|
}
|
@@ -16782,6 +16803,10 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
16782
16803
|
return;
|
16783
16804
|
}
|
16784
16805
|
this.pcManager.requirePublisher();
|
16806
|
+
// don't negotiate without any transceivers or data channel, it will generate sdp without ice frag then negotiate failed
|
16807
|
+
if (this.pcManager.publisher.getTransceivers().length == 0 && !this.lossyDC && !this.reliableDC) {
|
16808
|
+
this.createDataChannels();
|
16809
|
+
}
|
16785
16810
|
const abortController = new AbortController();
|
16786
16811
|
const handleClosed = () => {
|
16787
16812
|
abortController.abort();
|
@@ -16922,6 +16947,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
16922
16947
|
}
|
16923
16948
|
}
|
16924
16949
|
class SignalReconnectError extends Error {}
|
16950
|
+
function supportOptionalDatachannel(protocol) {
|
16951
|
+
return protocol !== undefined && protocol > 13;
|
16952
|
+
}
|
16925
16953
|
|
16926
16954
|
class RegionUrlProvider {
|
16927
16955
|
constructor(url, token) {
|
@@ -16980,6 +17008,10 @@ class RegionUrlProvider {
|
|
16980
17008
|
}
|
16981
17009
|
});
|
16982
17010
|
}
|
17011
|
+
setServerReportedRegions(regions) {
|
17012
|
+
this.regionSettings = regions;
|
17013
|
+
this.lastUpdateAt = Date.now();
|
17014
|
+
}
|
16983
17015
|
}
|
16984
17016
|
function getCloudConfigUrl(serverUrl) {
|
16985
17017
|
return "".concat(serverUrl.protocol.replace('ws', 'http'), "//").concat(serverUrl.host, "/settings");
|
@@ -17048,12 +17080,21 @@ class RemoteTrack extends Track {
|
|
17048
17080
|
}
|
17049
17081
|
registerTimeSyncUpdate() {
|
17050
17082
|
const loop = () => {
|
17051
|
-
var _a
|
17083
|
+
var _a;
|
17052
17084
|
this.timeSyncHandle = requestAnimationFrame(() => loop());
|
17053
|
-
const
|
17054
|
-
if (
|
17055
|
-
|
17056
|
-
|
17085
|
+
const sources = (_a = this.receiver) === null || _a === void 0 ? void 0 : _a.getSynchronizationSources()[0];
|
17086
|
+
if (sources) {
|
17087
|
+
const {
|
17088
|
+
timestamp,
|
17089
|
+
rtpTimestamp
|
17090
|
+
} = sources;
|
17091
|
+
if (rtpTimestamp && this.rtpTimestamp !== rtpTimestamp) {
|
17092
|
+
this.emit(TrackEvent.TimeSyncUpdate, {
|
17093
|
+
timestamp,
|
17094
|
+
rtpTimestamp
|
17095
|
+
});
|
17096
|
+
this.rtpTimestamp = rtpTimestamp;
|
17097
|
+
}
|
17057
17098
|
}
|
17058
17099
|
};
|
17059
17100
|
loop();
|
@@ -20569,7 +20610,7 @@ class Room extends eventsExports.EventEmitter {
|
|
20569
20610
|
if (onLeave) {
|
20570
20611
|
onLeave(new LeaveRequest({
|
20571
20612
|
reason: DisconnectReason.CLIENT_INITIATED,
|
20572
|
-
|
20613
|
+
action: LeaveRequest_Action.RECONNECT
|
20573
20614
|
}));
|
20574
20615
|
}
|
20575
20616
|
});
|