livekit-client 2.5.8 → 2.5.10

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.
Files changed (45) hide show
  1. package/dist/livekit-client.e2ee.worker.js +1 -1
  2. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  3. package/dist/livekit-client.e2ee.worker.mjs +543 -5128
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +104 -98
  6. package/dist/livekit-client.esm.mjs.map +1 -1
  7. package/dist/livekit-client.umd.js +1 -1
  8. package/dist/livekit-client.umd.js.map +1 -1
  9. package/dist/src/api/SignalClient.d.ts.map +1 -1
  10. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  11. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +25 -5
  12. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
  13. package/dist/src/index.d.ts +2 -1
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  16. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  17. package/dist/src/room/Room.d.ts.map +1 -1
  18. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  19. package/dist/src/room/track/LocalTrack.d.ts +1 -1
  20. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  21. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  22. package/dist/src/room/utils.d.ts +0 -10
  23. package/dist/src/room/utils.d.ts.map +1 -1
  24. package/dist/ts4.2/src/e2ee/worker/ParticipantKeyHandler.d.ts +25 -5
  25. package/dist/ts4.2/src/index.d.ts +2 -1
  26. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +1 -1
  27. package/dist/ts4.2/src/room/utils.d.ts +0 -10
  28. package/package.json +3 -2
  29. package/src/api/SignalClient.ts +2 -1
  30. package/src/e2ee/worker/FrameCryptor.test.ts +311 -113
  31. package/src/e2ee/worker/FrameCryptor.ts +10 -5
  32. package/src/e2ee/worker/ParticipantKeyHandler.test.ts +169 -5
  33. package/src/e2ee/worker/ParticipantKeyHandler.ts +50 -20
  34. package/src/e2ee/worker/__snapshots__/ParticipantKeyHandler.test.ts.snap +356 -0
  35. package/src/index.ts +1 -1
  36. package/src/room/PCTransportManager.ts +2 -1
  37. package/src/room/RTCEngine.ts +3 -1
  38. package/src/room/Room.ts +1 -1
  39. package/src/room/participant/LocalParticipant.ts +4 -1
  40. package/src/room/track/LocalTrack.ts +2 -1
  41. package/src/room/track/LocalVideoTrack.ts +2 -1
  42. package/src/room/track/options.ts +5 -5
  43. package/src/room/utils.ts +0 -38
  44. package/src/utils/AsyncQueue.test.ts +2 -2
  45. package/src/utils/AsyncQueue.ts +1 -1
@@ -1,3 +1,4 @@
1
+ import { Mutex } from '@livekit/mutex';
1
2
  import { SignalTarget } from '@livekit/protocol';
2
3
  import log, { LoggerNames, getLogger } from '../logger';
3
4
  import PCTransport, { PCEvents } from './PCTransport';
@@ -5,7 +6,7 @@ import { roomConnectOptionDefaults } from './defaults';
5
6
  import { ConnectionError, ConnectionErrorReason } from './errors';
6
7
  import CriticalTimers from './timers';
7
8
  import type { LoggerOptions } from './types';
8
- import { Mutex, sleep } from './utils';
9
+ import { sleep } from './utils';
9
10
 
10
11
  export enum PCTransportState {
11
12
  NEW,
@@ -1,3 +1,4 @@
1
+ import { Mutex } from '@livekit/mutex';
1
2
  import {
2
3
  type AddTrackRequest,
3
4
  ClientConfigSetting,
@@ -63,7 +64,7 @@ import type { Track } from './track/Track';
63
64
  import type { TrackPublishOptions, VideoCodec } from './track/options';
64
65
  import { getTrackPublicationInfo } from './track/utils';
65
66
  import type { LoggerOptions } from './types';
66
- import { Mutex, isVideoCodec, isWeb, sleep, supportsAddTrack, supportsTransceiver } from './utils';
67
+ import { isVideoCodec, isWeb, sleep, supportsAddTrack, supportsTransceiver } from './utils';
67
68
 
68
69
  const lossyDataChannel = '_lossy';
69
70
  const reliableDataChannel = '_reliable';
@@ -262,6 +263,7 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
262
263
  }
263
264
  try {
264
265
  this._isClosed = true;
266
+ this.joinAttempts = 0;
265
267
  this.emit(EngineEvent.Closing);
266
268
  this.removeAllListeners();
267
269
  this.deregisterOnLineListener();
package/src/room/Room.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Mutex } from '@livekit/mutex';
1
2
  import {
2
3
  ChatMessage as ChatMessageModel,
3
4
  ConnectionQualityUpdate,
@@ -77,7 +78,6 @@ import type {
77
78
  } from './types';
78
79
  import {
79
80
  Future,
80
- Mutex,
81
81
  createDummyVideoStreamTrack,
82
82
  extractChatMessage,
83
83
  extractTranscriptionSegments,
@@ -282,7 +282,10 @@ export default class LocalParticipant extends Participant {
282
282
  (!name || this.name === name) &&
283
283
  (!metadata || this.metadata === metadata) &&
284
284
  (!attributes ||
285
- Object.entries(attributes).every(([key, value]) => this.attributes[key] === value))
285
+ Object.entries(attributes).every(
286
+ ([key, value]) =>
287
+ this.attributes[key] === value || (value === '' && !this.attributes[key]),
288
+ ))
286
289
  ) {
287
290
  this.pendingSignalRequests.delete(requestId);
288
291
  resolve();
@@ -1,10 +1,11 @@
1
+ import { Mutex } from '@livekit/mutex';
1
2
  import { debounce } from 'ts-debounce';
2
3
  import { getBrowser } from '../../utils/browserParser';
3
4
  import DeviceManager from '../DeviceManager';
4
5
  import { DeviceUnsupportedError, TrackInvalidError } from '../errors';
5
6
  import { TrackEvent } from '../events';
6
7
  import type { LoggerOptions } from '../types';
7
- import { Mutex, compareVersions, isMobile, sleep } from '../utils';
8
+ import { compareVersions, isMobile, sleep } from '../utils';
8
9
  import { Track, attachToElement, detachTrack } from './Track';
9
10
  import type { VideoCodec } from './options';
10
11
  import type { TrackProcessor } from './processor/types';
@@ -1,3 +1,4 @@
1
+ import { Mutex } from '@livekit/mutex';
1
2
  import {
2
3
  VideoQuality as ProtoVideoQuality,
3
4
  SubscribedCodec,
@@ -10,7 +11,7 @@ import { ScalabilityMode } from '../participant/publishUtils';
10
11
  import type { VideoSenderStats } from '../stats';
11
12
  import { computeBitrate, monitorFrequency } from '../stats';
12
13
  import type { LoggerOptions } from '../types';
13
- import { Mutex, isFireFox, isMobile, isWeb, unwrapConstraint } from '../utils';
14
+ import { isFireFox, isMobile, isWeb, unwrapConstraint } from '../utils';
14
15
  import LocalTrack from './LocalTrack';
15
16
  import { Track, VideoQuality } from './Track';
16
17
  import type { VideoCaptureOptions, VideoCodec } from './options';
@@ -398,19 +398,19 @@ export namespace AudioPresets {
398
398
  maxBitrate: 12_000,
399
399
  };
400
400
  export const speech: AudioPreset = {
401
- maxBitrate: 20_000,
401
+ maxBitrate: 24_000,
402
402
  };
403
403
  export const music: AudioPreset = {
404
- maxBitrate: 32_000,
404
+ maxBitrate: 48_000,
405
405
  };
406
406
  export const musicStereo: AudioPreset = {
407
- maxBitrate: 48_000,
407
+ maxBitrate: 64_000,
408
408
  };
409
409
  export const musicHighQuality: AudioPreset = {
410
- maxBitrate: 64_000,
410
+ maxBitrate: 96_000,
411
411
  };
412
412
  export const musicHighQualityStereo: AudioPreset = {
413
- maxBitrate: 96_000,
413
+ maxBitrate: 128_000,
414
414
  };
415
415
  }
416
416
 
package/src/room/utils.ts CHANGED
@@ -454,44 +454,6 @@ export function createAudioAnalyser(
454
454
  return { calculateVolume, analyser, cleanup };
455
455
  }
456
456
 
457
- /**
458
- * @internal
459
- */
460
- export class Mutex {
461
- private _locking: Promise<void>;
462
-
463
- private _locks: number;
464
-
465
- constructor() {
466
- this._locking = Promise.resolve();
467
- this._locks = 0;
468
- }
469
-
470
- isLocked() {
471
- return this._locks > 0;
472
- }
473
-
474
- lock() {
475
- this._locks += 1;
476
-
477
- let unlockNext: () => void;
478
-
479
- const willLock = new Promise<void>(
480
- (resolve) =>
481
- (unlockNext = () => {
482
- this._locks -= 1;
483
- resolve();
484
- }),
485
- );
486
-
487
- const willUnlock = this._locking.then(() => unlockNext);
488
-
489
- this._locking = this._locking.then(() => willLock);
490
-
491
- return willUnlock;
492
- }
493
- }
494
-
495
457
  export function isVideoCodec(maybeCodec: string): maybeCodec is VideoCodec {
496
458
  return videoCodecs.includes(maybeCodec as VideoCodec);
497
459
  }
@@ -1,4 +1,4 @@
1
- import { describe, expect, it } from 'vitest';
1
+ import { assert, describe, expect, it } from 'vitest';
2
2
  import { sleep } from '../room/utils';
3
3
  import { AsyncQueue } from './AsyncQueue';
4
4
 
@@ -49,7 +49,7 @@ describe('asyncQueue', () => {
49
49
  task2Executed = true;
50
50
  })
51
51
  .catch(() => {
52
- fail('task 2 should not have thrown');
52
+ assert.fail('task 2 should not have thrown');
53
53
  });
54
54
 
55
55
  expect(task1threw).toBeTruthy();
@@ -1,4 +1,4 @@
1
- import { Mutex } from '../room/utils';
1
+ import { Mutex } from '@livekit/mutex';
2
2
 
3
3
  type QueueTask<T> = () => PromiseLike<T>;
4
4