livekit-client 2.0.4 → 2.0.5
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.
- package/dist/livekit-client.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +10 -8
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +77 -52
- 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/e2ee/worker/FrameCryptor.d.ts +1 -0
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/logger.d.ts +2 -2
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +3 -2
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +1 -2
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/participant/RemoteParticipant.d.ts +4 -0
- package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +1 -1
- package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +1 -0
- package/dist/ts4.2/src/logger.d.ts +2 -2
- package/dist/ts4.2/src/room/RTCEngine.d.ts +3 -2
- package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -2
- package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +4 -0
- package/package.json +1 -1
- package/src/api/SignalClient.ts +9 -5
- package/src/e2ee/worker/FrameCryptor.ts +12 -6
- package/src/logger.ts +21 -18
- package/src/room/RTCEngine.ts +12 -8
- package/src/room/Room.ts +15 -2
- package/src/room/participant/Participant.ts +0 -2
- package/src/room/participant/RemoteParticipant.ts +8 -0
- package/src/room/track/LocalVideoTrack.ts +5 -1
- package/src/room/track/utils.ts +18 -11
- package/src/room/utils.ts +3 -0
@@ -309,6 +309,7 @@ var LoggerNames;
|
|
309
309
|
LoggerNames["E2EE"] = "lk-e2ee";
|
310
310
|
})(LoggerNames || (LoggerNames = {}));
|
311
311
|
let livekitLogger = loglevelExports.getLogger('livekit');
|
312
|
+
const livekitLoggers = Object.values(LoggerNames).map(name => loglevelExports.getLogger(name));
|
312
313
|
livekitLogger.setDefaultLevel(LogLevel.info);
|
313
314
|
/**
|
314
315
|
* @internal
|
@@ -322,13 +323,7 @@ function setLogLevel(level, loggerName) {
|
|
322
323
|
if (loggerName) {
|
323
324
|
loglevelExports.getLogger(loggerName).setLevel(level);
|
324
325
|
}
|
325
|
-
for (const logger of
|
326
|
-
let [logrName] = _ref;
|
327
|
-
return logrName.startsWith('livekit');
|
328
|
-
}).map(_ref2 => {
|
329
|
-
let [, logr] = _ref2;
|
330
|
-
return logr;
|
331
|
-
})) {
|
326
|
+
for (const logger of livekitLoggers) {
|
332
327
|
logger.setLevel(level);
|
333
328
|
}
|
334
329
|
}
|
@@ -336,21 +331,23 @@ function setLogLevel(level, loggerName) {
|
|
336
331
|
* use this to hook into the logging function to allow sending internal livekit logs to third party services
|
337
332
|
* if set, the browser logs will lose their stacktrace information (see https://github.com/pimterry/loglevel#writing-plugins)
|
338
333
|
*/
|
339
|
-
function setLogExtension(extension) {
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
334
|
+
function setLogExtension(extension, logger) {
|
335
|
+
const loggers = logger ? [logger] : livekitLoggers;
|
336
|
+
loggers.forEach(logR => {
|
337
|
+
const originalFactory = logR.methodFactory;
|
338
|
+
logR.methodFactory = (methodName, configLevel, loggerName) => {
|
339
|
+
const rawMethod = originalFactory(methodName, configLevel, loggerName);
|
340
|
+
const logLevel = LogLevel[methodName];
|
341
|
+
const needLog = logLevel >= configLevel && logLevel < LogLevel.silent;
|
342
|
+
return (msg, context) => {
|
343
|
+
if (context) rawMethod(msg, context);else rawMethod(msg);
|
344
|
+
if (needLog) {
|
345
|
+
extension(logLevel, msg, context);
|
346
|
+
}
|
347
|
+
};
|
351
348
|
};
|
352
|
-
|
353
|
-
|
349
|
+
logR.setLevel(logR.getLevel());
|
350
|
+
});
|
354
351
|
}
|
355
352
|
const workerLogger = loglevelExports.getLogger('lk-e2ee');
|
356
353
|
|
@@ -10711,7 +10708,7 @@ function getMatch(exp, ua) {
|
|
10711
10708
|
return match && match.length >= id && match[id] || '';
|
10712
10709
|
}
|
10713
10710
|
|
10714
|
-
var version$1 = "2.0.
|
10711
|
+
var version$1 = "2.0.5";
|
10715
10712
|
|
10716
10713
|
const version = version$1;
|
10717
10714
|
const protocolVersion = 12;
|
@@ -13700,20 +13697,26 @@ function getTrackPublicationInfo(tracks) {
|
|
13700
13697
|
function getLogContextFromTrack(track) {
|
13701
13698
|
if (track instanceof Track) {
|
13702
13699
|
return {
|
13703
|
-
|
13704
|
-
|
13705
|
-
|
13706
|
-
|
13707
|
-
|
13700
|
+
trackID: track.sid,
|
13701
|
+
source: track.source,
|
13702
|
+
muted: track.isMuted,
|
13703
|
+
enabled: track.mediaStreamTrack.enabled,
|
13704
|
+
kind: track.kind,
|
13705
|
+
streamID: track.mediaStreamID,
|
13706
|
+
streamTrackID: track.mediaStreamTrack.id
|
13708
13707
|
};
|
13709
13708
|
} else {
|
13710
13709
|
return {
|
13711
|
-
|
13712
|
-
|
13713
|
-
|
13714
|
-
|
13715
|
-
|
13716
|
-
|
13710
|
+
trackID: track.trackSid,
|
13711
|
+
enabled: track.isEnabled,
|
13712
|
+
muted: track.isMuted,
|
13713
|
+
trackInfo: Object.assign({
|
13714
|
+
mimeType: track.mimeType,
|
13715
|
+
name: track.trackName,
|
13716
|
+
encrypted: track.isEncrypted,
|
13717
|
+
kind: track.kind,
|
13718
|
+
source: track.source
|
13719
|
+
}, track.track ? getLogContextFromTrack(track.track) : {})
|
13717
13720
|
};
|
13718
13721
|
}
|
13719
13722
|
}
|
@@ -13830,6 +13833,9 @@ function supportsSetCodecPreferences(transceiver) {
|
|
13830
13833
|
return false;
|
13831
13834
|
}
|
13832
13835
|
function isBrowserSupported() {
|
13836
|
+
if (typeof RTCPeerConnection === 'undefined') {
|
13837
|
+
return false;
|
13838
|
+
}
|
13833
13839
|
return supportsTransceiver() || supportsAddTrack();
|
13834
13840
|
}
|
13835
13841
|
function isFireFox() {
|
@@ -15174,7 +15180,7 @@ class SignalClient {
|
|
15174
15180
|
this.handleWSError(ev);
|
15175
15181
|
});
|
15176
15182
|
this.ws.onmessage = ev => __awaiter(this, void 0, void 0, function* () {
|
15177
|
-
var _a, _b, _c
|
15183
|
+
var _a, _b, _c;
|
15178
15184
|
// not considered connected until JoinResponse is received
|
15179
15185
|
let resp;
|
15180
15186
|
if (typeof ev.data === 'string') {
|
@@ -15210,16 +15216,17 @@ class SignalClient {
|
|
15210
15216
|
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
|
15211
15217
|
this.startPingInterval();
|
15212
15218
|
if (((_b = resp.message) === null || _b === void 0 ? void 0 : _b.case) === 'reconnect') {
|
15213
|
-
resolve(
|
15219
|
+
resolve(resp.message.value);
|
15214
15220
|
} else {
|
15215
|
-
|
15221
|
+
this.log.debug('declaring signal reconnected without reconnect response received', this.logContext);
|
15222
|
+
resolve(undefined);
|
15216
15223
|
shouldProcessMessage = true;
|
15217
15224
|
}
|
15218
15225
|
} else if (this.isEstablishingConnection && resp.message.case === 'leave') {
|
15219
15226
|
reject(new ConnectionError('Received leave request while trying to (re)connect', 4 /* ConnectionErrorReason.LeaveRequest */));
|
15220
15227
|
} else if (!opts.reconnect) {
|
15221
15228
|
// non-reconnect case, should receive join response first
|
15222
|
-
reject(new ConnectionError("did not receive join response, got ".concat((
|
15229
|
+
reject(new ConnectionError("did not receive join response, got ".concat((_c = resp.message) === null || _c === void 0 ? void 0 : _c.case, " instead")));
|
15223
15230
|
}
|
15224
15231
|
if (!shouldProcessMessage) {
|
15225
15232
|
return;
|
@@ -17374,11 +17381,12 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
17374
17381
|
}
|
17375
17382
|
/** @internal */
|
17376
17383
|
get logContext() {
|
17377
|
-
var _a, _b, _c, _d, _e, _f;
|
17384
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
17378
17385
|
return {
|
17379
17386
|
room: (_b = (_a = this.latestJoinResponse) === null || _a === void 0 ? void 0 : _a.room) === null || _b === void 0 ? void 0 : _b.name,
|
17380
|
-
|
17381
|
-
|
17387
|
+
roomID: (_d = (_c = this.latestJoinResponse) === null || _c === void 0 ? void 0 : _c.room) === null || _d === void 0 ? void 0 : _d.sid,
|
17388
|
+
participant: (_f = (_e = this.latestJoinResponse) === null || _e === void 0 ? void 0 : _e.participant) === null || _f === void 0 ? void 0 : _f.identity,
|
17389
|
+
pID: (_h = (_g = this.latestJoinResponse) === null || _g === void 0 ? void 0 : _g.participant) === null || _h === void 0 ? void 0 : _h.sid
|
17382
17390
|
};
|
17383
17391
|
}
|
17384
17392
|
join(url, token, opts, abortSignal) {
|
@@ -17974,13 +17982,10 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
17974
17982
|
}
|
17975
17983
|
this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts), this.logContext);
|
17976
17984
|
this.emit(EngineEvent.Resuming);
|
17985
|
+
let res;
|
17977
17986
|
try {
|
17978
17987
|
this.setupSignalClientCallbacks();
|
17979
|
-
|
17980
|
-
if (res) {
|
17981
|
-
const rtcConfig = this.makeRTCConfiguration(res);
|
17982
|
-
this.pcManager.updateConfiguration(rtcConfig);
|
17983
|
-
}
|
17988
|
+
res = yield this.client.reconnect(this.url, this.token, this.participantSid, reason);
|
17984
17989
|
} catch (error) {
|
17985
17990
|
let message = '';
|
17986
17991
|
if (error instanceof Error) {
|
@@ -17998,6 +18003,12 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
17998
18003
|
throw new SignalReconnectError(message);
|
17999
18004
|
}
|
18000
18005
|
this.emit(EngineEvent.SignalResumed);
|
18006
|
+
if (res) {
|
18007
|
+
const rtcConfig = this.makeRTCConfiguration(res);
|
18008
|
+
this.pcManager.updateConfiguration(rtcConfig);
|
18009
|
+
} else {
|
18010
|
+
this.log.warn('Did not receive reconnect response', this.logContext);
|
18011
|
+
}
|
18001
18012
|
if (this.shouldFailNext) {
|
18002
18013
|
this.shouldFailNext = false;
|
18003
18014
|
throw new Error('simulated failure');
|
@@ -19315,7 +19326,10 @@ function setPublishingLayersForSender(sender, senderEncodings, qualities, sender
|
|
19315
19326
|
return;
|
19316
19327
|
}
|
19317
19328
|
if (encodings.length !== senderEncodings.length) {
|
19318
|
-
log.warn('cannot set publishing layers, encodings mismatch')
|
19329
|
+
log.warn('cannot set publishing layers, encodings mismatch', Object.assign(Object.assign({}, logContext), {
|
19330
|
+
encodings,
|
19331
|
+
senderEncodings
|
19332
|
+
}));
|
19319
19333
|
return;
|
19320
19334
|
}
|
19321
19335
|
let hasChanged = false;
|
@@ -20207,10 +20221,7 @@ function qualityFromProto(q) {
|
|
20207
20221
|
class Participant extends eventsExports.EventEmitter {
|
20208
20222
|
get logContext() {
|
20209
20223
|
var _a, _b;
|
20210
|
-
return Object.assign(
|
20211
|
-
participantSid: this.sid,
|
20212
|
-
participantId: this.identity
|
20213
|
-
});
|
20224
|
+
return Object.assign({}, (_b = (_a = this.loggerOptions) === null || _a === void 0 ? void 0 : _a.loggerContextCb) === null || _b === void 0 ? void 0 : _b.call(_a));
|
20214
20225
|
}
|
20215
20226
|
get isEncrypted() {
|
20216
20227
|
return this.trackPublications.size > 0 && Array.from(this.trackPublications.values()).every(tr => tr.isEncrypted);
|
@@ -21700,6 +21711,12 @@ class RemoteParticipant extends Participant {
|
|
21700
21711
|
static fromParticipantInfo(signalClient, pi) {
|
21701
21712
|
return new RemoteParticipant(signalClient, pi.sid, pi.identity, pi.name, pi.metadata);
|
21702
21713
|
}
|
21714
|
+
get logContext() {
|
21715
|
+
return Object.assign(Object.assign({}, super.logContext), {
|
21716
|
+
rpID: this.sid,
|
21717
|
+
remoteParticipant: this.identity
|
21718
|
+
});
|
21719
|
+
}
|
21703
21720
|
/** @internal */
|
21704
21721
|
constructor(signalClient, sid, identity, name, metadata, loggerOptions) {
|
21705
21722
|
super(sid, identity || '', name, metadata, loggerOptions);
|
@@ -21994,6 +22011,13 @@ class Room extends eventsExports.EventEmitter {
|
|
21994
22011
|
this.isResuming = false;
|
21995
22012
|
this.connect = (url, token, opts) => __awaiter(this, void 0, void 0, function* () {
|
21996
22013
|
var _c;
|
22014
|
+
if (!isBrowserSupported()) {
|
22015
|
+
if (isReactNative()) {
|
22016
|
+
throw Error("WebRTC isn't detected, have you called registerGlobals?");
|
22017
|
+
} else {
|
22018
|
+
throw Error("LiveKit doesn't seem to be supported on this browser. Try to update your browser and make sure no browser extensions are disabling webRTC.");
|
22019
|
+
}
|
22020
|
+
}
|
21997
22021
|
// In case a disconnect called happened right before the connect call, make sure the disconnect is completed first by awaiting its lock
|
21998
22022
|
const unlockDisconnect = yield this.disconnectLock.lock();
|
21999
22023
|
if (this.state === ConnectionState.Connected) {
|
@@ -22654,8 +22678,9 @@ class Room extends eventsExports.EventEmitter {
|
|
22654
22678
|
var _a;
|
22655
22679
|
return {
|
22656
22680
|
room: this.name,
|
22657
|
-
|
22658
|
-
|
22681
|
+
roomID: (_a = this.roomInfo) === null || _a === void 0 ? void 0 : _a.sid,
|
22682
|
+
participant: this.localParticipant.identity,
|
22683
|
+
pID: this.localParticipant.sid
|
22659
22684
|
};
|
22660
22685
|
}
|
22661
22686
|
/**
|