livekit-client 2.9.4 → 2.9.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.
- 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 +80 -17
- 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/Room.d.ts.map +1 -1
- package/dist/src/room/errors.d.ts +4 -0
- package/dist/src/room/errors.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +1 -0
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts +2 -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/room/errors.d.ts +4 -0
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -0
- package/dist/ts4.2/src/room/track/utils.d.ts +2 -1
- package/package.json +2 -2
- package/src/api/SignalClient.ts +28 -12
- package/src/room/RTCEngine.ts +1 -1
- package/src/room/Room.ts +1 -2
- package/src/room/errors.ts +10 -0
- package/src/room/participant/LocalParticipant.ts +28 -0
- package/src/room/track/LocalTrack.ts +1 -1
- package/src/room/track/utils.ts +31 -2
- package/src/room/utils.ts +1 -0
@@ -10455,6 +10455,13 @@ class PublishDataError extends LivekitError {
|
|
10455
10455
|
this.name = 'PublishDataError';
|
10456
10456
|
}
|
10457
10457
|
}
|
10458
|
+
class PublishTrackError extends LivekitError {
|
10459
|
+
constructor(message, status) {
|
10460
|
+
super(15, message);
|
10461
|
+
this.name = 'PublishTrackError';
|
10462
|
+
this.status = status;
|
10463
|
+
}
|
10464
|
+
}
|
10458
10465
|
class SignalRequestError extends LivekitError {
|
10459
10466
|
constructor(message, reason) {
|
10460
10467
|
super(15, message);
|
@@ -11162,7 +11169,7 @@ function getOSVersion(ua) {
|
|
11162
11169
|
return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
|
11163
11170
|
}
|
11164
11171
|
|
11165
|
-
var version$1 = "2.9.
|
11172
|
+
var version$1 = "2.9.6";
|
11166
11173
|
|
11167
11174
|
const version = version$1;
|
11168
11175
|
const protocolVersion = 15;
|
@@ -12274,13 +12281,25 @@ function detectSilence(track_1) {
|
|
12274
12281
|
* @internal
|
12275
12282
|
*/
|
12276
12283
|
function getNewAudioContext() {
|
12284
|
+
var _a;
|
12277
12285
|
const AudioContext =
|
12278
12286
|
// @ts-ignore
|
12279
12287
|
typeof window !== 'undefined' && (window.AudioContext || window.webkitAudioContext);
|
12280
12288
|
if (AudioContext) {
|
12281
|
-
|
12289
|
+
const audioContext = new AudioContext({
|
12282
12290
|
latencyHint: 'interactive'
|
12283
12291
|
});
|
12292
|
+
// If the audio context is suspended, we need to resume it when the user clicks on the page
|
12293
|
+
if (audioContext.state === 'suspended' && typeof window !== 'undefined' && ((_a = window.document) === null || _a === void 0 ? void 0 : _a.body)) {
|
12294
|
+
const handleResume = () => {
|
12295
|
+
audioContext.resume().then(() => {
|
12296
|
+
var _a;
|
12297
|
+
(_a = window.document.body) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', handleResume);
|
12298
|
+
});
|
12299
|
+
};
|
12300
|
+
window.document.body.addEventListener('click', handleResume);
|
12301
|
+
}
|
12302
|
+
return audioContext;
|
12284
12303
|
}
|
12285
12304
|
}
|
12286
12305
|
/**
|
@@ -12421,6 +12440,20 @@ function extractProcessorsFromOptions(options) {
|
|
12421
12440
|
optionsWithoutProcessor: newOptions
|
12422
12441
|
};
|
12423
12442
|
}
|
12443
|
+
function getTrackSourceFromProto(source) {
|
12444
|
+
switch (source) {
|
12445
|
+
case TrackSource.CAMERA:
|
12446
|
+
return Track.Source.Camera;
|
12447
|
+
case TrackSource.MICROPHONE:
|
12448
|
+
return Track.Source.Microphone;
|
12449
|
+
case TrackSource.SCREEN_SHARE:
|
12450
|
+
return Track.Source.ScreenShare;
|
12451
|
+
case TrackSource.SCREEN_SHARE_AUDIO:
|
12452
|
+
return Track.Source.ScreenShareAudio;
|
12453
|
+
default:
|
12454
|
+
return Track.Source.Unknown;
|
12455
|
+
}
|
12456
|
+
}
|
12424
12457
|
|
12425
12458
|
/**
|
12426
12459
|
* @experimental
|
@@ -12995,12 +13028,15 @@ class SignalClient {
|
|
12995
13028
|
}
|
12996
13029
|
connect(url, token, opts, abortSignal) {
|
12997
13030
|
this.connectOptions = opts;
|
12998
|
-
|
13031
|
+
const urlObj = new URL(toWebsocketUrl(url));
|
12999
13032
|
// strip trailing slash
|
13000
|
-
|
13001
|
-
|
13033
|
+
urlObj.pathname = urlObj.pathname.replace(/\/$/, '');
|
13034
|
+
urlObj.pathname += '/rtc';
|
13002
13035
|
const clientInfo = getClientInfo();
|
13003
13036
|
const params = createConnectionParams(token, clientInfo, opts);
|
13037
|
+
for (const [key, value] of params) {
|
13038
|
+
urlObj.searchParams.set(key, value);
|
13039
|
+
}
|
13004
13040
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
13005
13041
|
const unlock = yield this.connectionLock.lock();
|
13006
13042
|
try {
|
@@ -13017,11 +13053,18 @@ class SignalClient {
|
|
13017
13053
|
abortHandler();
|
13018
13054
|
}
|
13019
13055
|
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener('abort', abortHandler);
|
13020
|
-
|
13056
|
+
const redactedUrl = new URL(urlObj.toString());
|
13057
|
+
if (redactedUrl.searchParams.has('access_token')) {
|
13058
|
+
redactedUrl.searchParams.set('access_token', '<redacted>');
|
13059
|
+
}
|
13060
|
+
this.log.debug("connecting to ".concat(redactedUrl), Object.assign({
|
13061
|
+
reconnect: opts.reconnect,
|
13062
|
+
reconnectReason: opts.reconnectReason
|
13063
|
+
}, this.logContext));
|
13021
13064
|
if (this.ws) {
|
13022
13065
|
yield this.close(false);
|
13023
13066
|
}
|
13024
|
-
this.ws = new WebSocket(
|
13067
|
+
this.ws = new WebSocket(urlObj);
|
13025
13068
|
this.ws.binaryType = 'arraybuffer';
|
13026
13069
|
this.ws.onopen = () => {
|
13027
13070
|
clearTimeout(wsTimeout);
|
@@ -13031,7 +13074,10 @@ class SignalClient {
|
|
13031
13074
|
this.state = SignalConnectionState.DISCONNECTED;
|
13032
13075
|
clearTimeout(wsTimeout);
|
13033
13076
|
try {
|
13034
|
-
const
|
13077
|
+
const validateURL = new URL(urlObj.toString());
|
13078
|
+
validateURL.protocol = "http".concat(validateURL.protocol.substring(2));
|
13079
|
+
validateURL.pathname += '/validate';
|
13080
|
+
const resp = yield fetch(validateURL);
|
13035
13081
|
if (resp.status.toFixed(0).startsWith('4')) {
|
13036
13082
|
const msg = yield resp.text();
|
13037
13083
|
reject(new ConnectionError(msg, ConnectionErrorReason.NotAllowed, resp.status));
|
@@ -13183,7 +13229,7 @@ class SignalClient {
|
|
13183
13229
|
});
|
13184
13230
|
}
|
13185
13231
|
sendIceCandidate(candidate, target) {
|
13186
|
-
this.log.
|
13232
|
+
this.log.debug('sending ice candidate', Object.assign(Object.assign({}, this.logContext), {
|
13187
13233
|
candidate
|
13188
13234
|
}));
|
13189
13235
|
return this.sendRequest({
|
@@ -13573,7 +13619,7 @@ function createConnectionParams(token, info, opts) {
|
|
13573
13619
|
// @ts-ignore
|
13574
13620
|
params.set('network', navigator.connection.type);
|
13575
13621
|
}
|
13576
|
-
return
|
13622
|
+
return params;
|
13577
13623
|
}
|
13578
13624
|
|
13579
13625
|
var lib = {};
|
@@ -15592,11 +15638,10 @@ class LocalTrack extends Track {
|
|
15592
15638
|
if (!constraints) {
|
15593
15639
|
constraints = this._constraints;
|
15594
15640
|
}
|
15595
|
-
const
|
15596
|
-
{
|
15641
|
+
const {
|
15597
15642
|
deviceId
|
15598
|
-
} =
|
15599
|
-
otherConstraints = __rest(
|
15643
|
+
} = constraints,
|
15644
|
+
otherConstraints = __rest(constraints, ["deviceId"]);
|
15600
15645
|
this.log.debug('restarting track with constraints', Object.assign(Object.assign({}, this.logContext), {
|
15601
15646
|
constraints
|
15602
15647
|
}));
|
@@ -17448,7 +17493,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
17448
17493
|
if (!this.pcManager) {
|
17449
17494
|
return;
|
17450
17495
|
}
|
17451
|
-
this.log.
|
17496
|
+
this.log.debug('got ICE candidate from peer', Object.assign(Object.assign({}, this.logContext), {
|
17452
17497
|
candidate,
|
17453
17498
|
target
|
17454
17499
|
}));
|
@@ -20295,9 +20340,27 @@ class LocalParticipant extends Participant {
|
|
20295
20340
|
}();
|
20296
20341
|
});
|
20297
20342
|
}
|
20343
|
+
hasPermissionsToPublish(track) {
|
20344
|
+
if (!this.permissions) {
|
20345
|
+
this.log.warn('no permissions present for publishing track', Object.assign(Object.assign({}, this.logContext), getLogContextFromTrack(track)));
|
20346
|
+
return false;
|
20347
|
+
}
|
20348
|
+
const {
|
20349
|
+
canPublish,
|
20350
|
+
canPublishSources
|
20351
|
+
} = this.permissions;
|
20352
|
+
if (canPublish && (canPublishSources.length === 0 || canPublishSources.map(source => getTrackSourceFromProto(source)).includes(track.source))) {
|
20353
|
+
return true;
|
20354
|
+
}
|
20355
|
+
this.log.warn('insufficient permissions to publish', Object.assign(Object.assign({}, this.logContext), getLogContextFromTrack(track)));
|
20356
|
+
return false;
|
20357
|
+
}
|
20298
20358
|
publish(track, opts, isStereo) {
|
20299
20359
|
return __awaiter(this, void 0, void 0, function* () {
|
20300
20360
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
20361
|
+
if (!this.hasPermissionsToPublish(track)) {
|
20362
|
+
throw new PublishTrackError('failed to publish track, insufficient permissions', 403);
|
20363
|
+
}
|
20301
20364
|
const existingTrackOfSource = Array.from(this.trackPublications.values()).find(publishedTrack => isLocalTrack(track) && publishedTrack.source === track.source);
|
20302
20365
|
if (existingTrackOfSource && track.source !== Track.Source.Unknown) {
|
20303
20366
|
this.log.info("publishing a second track with the same source: ".concat(track.source), Object.assign(Object.assign({}, this.logContext), getLogContextFromTrack(track)));
|
@@ -23323,7 +23386,7 @@ class Room extends eventsExports.EventEmitter {
|
|
23323
23386
|
if (textBuffer) {
|
23324
23387
|
textBuffer.info.attributes = Object.assign(Object.assign({}, textBuffer.info.attributes), trailer.attributes);
|
23325
23388
|
textBuffer.controller.close();
|
23326
|
-
this.
|
23389
|
+
this.textStreamControllers.delete(trailer.streamId);
|
23327
23390
|
}
|
23328
23391
|
const fileBuffer = this.byteStreamControllers.get(trailer.streamId);
|
23329
23392
|
if (fileBuffer) {
|
@@ -24625,5 +24688,5 @@ function isFacingModeValue(item) {
|
|
24625
24688
|
return item === undefined || allowedValues.includes(item);
|
24626
24689
|
}
|
24627
24690
|
|
24628
|
-
export { AudioPresets, BackupCodecPolicy, BaseKeyProvider, CheckStatus, Checker, ConnectionCheck, ConnectionError, ConnectionErrorReason, ConnectionQuality, ConnectionState, CriticalTimers, CryptorError, CryptorErrorReason, CryptorEvent, DataPacket_Kind, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, EngineEvent, ExternalE2EEKeyProvider, KeyHandlerEvent, KeyProviderEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, LoggerNames, MediaDeviceFailure, _ as Mutex, NegotiationError, Participant, ParticipantEvent, ParticipantInfo_Kind as ParticipantKind, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RpcError, ScreenSharePresets, SignalRequestError, SubscriptionError, Track, TrackEvent, TrackInvalidError, TrackPublication, TrackType, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, compareVersions, createAudioAnalyser, createE2EEKey, createKeyMaterialFromBuffer, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getBrowser, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, getLogger, importKey, isAudioTrack, isBackupCodec, isBrowserSupported, isE2EESupported, isInsertableStreamSupported, isLocalParticipant, isLocalTrack, isRemoteParticipant, isRemoteTrack, isScriptTransformSupported, isVideoFrame, isVideoTrack, needsRbspUnescaping, parseRbsp, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs, writeRbsp };
|
24691
|
+
export { AudioPresets, BackupCodecPolicy, BaseKeyProvider, CheckStatus, Checker, ConnectionCheck, ConnectionError, ConnectionErrorReason, ConnectionQuality, ConnectionState, CriticalTimers, CryptorError, CryptorErrorReason, CryptorEvent, DataPacket_Kind, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, EngineEvent, ExternalE2EEKeyProvider, KeyHandlerEvent, KeyProviderEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, LoggerNames, MediaDeviceFailure, _ as Mutex, NegotiationError, Participant, ParticipantEvent, ParticipantInfo_Kind as ParticipantKind, PublishDataError, PublishTrackError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RpcError, ScreenSharePresets, SignalRequestError, SubscriptionError, Track, TrackEvent, TrackInvalidError, TrackPublication, TrackType, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, compareVersions, createAudioAnalyser, createE2EEKey, createKeyMaterialFromBuffer, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getBrowser, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, getLogger, importKey, isAudioTrack, isBackupCodec, isBrowserSupported, isE2EESupported, isInsertableStreamSupported, isLocalParticipant, isLocalTrack, isRemoteParticipant, isRemoteTrack, isScriptTransformSupported, isVideoFrame, isVideoTrack, needsRbspUnescaping, parseRbsp, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs, writeRbsp };
|
24629
24692
|
//# sourceMappingURL=livekit-client.esm.mjs.map
|