livekit-client 1.14.1 → 1.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) 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 +25 -44
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +399 -196
  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/e2ee/E2eeManager.d.ts.map +1 -1
  10. package/dist/src/e2ee/utils.d.ts +0 -1
  11. package/dist/src/e2ee/utils.d.ts.map +1 -1
  12. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  13. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
  14. package/dist/src/proto/livekit_models_pb.d.ts +87 -11
  15. package/dist/src/proto/livekit_models_pb.d.ts.map +1 -1
  16. package/dist/src/proto/livekit_rtc_pb.d.ts +0 -4
  17. package/dist/src/proto/livekit_rtc_pb.d.ts.map +1 -1
  18. package/dist/src/room/PCTransport.d.ts +20 -1
  19. package/dist/src/room/PCTransport.d.ts.map +1 -1
  20. package/dist/src/room/RTCEngine.d.ts +1 -1
  21. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  22. package/dist/src/room/Room.d.ts.map +1 -1
  23. package/dist/src/room/defaults.d.ts +1 -0
  24. package/dist/src/room/defaults.d.ts.map +1 -1
  25. package/dist/src/room/events.d.ts +1 -1
  26. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  27. package/dist/src/room/timers.d.ts +1 -1
  28. package/dist/src/room/timers.d.ts.map +1 -1
  29. package/dist/src/room/track/LocalAudioTrack.d.ts +1 -1
  30. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  31. package/dist/src/room/track/LocalTrack.d.ts +3 -3
  32. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  33. package/dist/src/room/track/LocalVideoTrack.d.ts +2 -1
  34. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  35. package/dist/src/room/track/options.d.ts +0 -1
  36. package/dist/src/room/track/options.d.ts.map +1 -1
  37. package/dist/src/room/track/utils.d.ts +2 -1
  38. package/dist/src/room/track/utils.d.ts.map +1 -1
  39. package/dist/src/utils/cloneDeep.d.ts +2 -0
  40. package/dist/src/utils/cloneDeep.d.ts.map +1 -0
  41. package/dist/ts4.2/src/e2ee/utils.d.ts +0 -1
  42. package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +87 -11
  43. package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +0 -4
  44. package/dist/ts4.2/src/room/PCTransport.d.ts +20 -1
  45. package/dist/ts4.2/src/room/RTCEngine.d.ts +1 -1
  46. package/dist/ts4.2/src/room/defaults.d.ts +1 -0
  47. package/dist/ts4.2/src/room/events.d.ts +1 -1
  48. package/dist/ts4.2/src/room/timers.d.ts +1 -1
  49. package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +1 -1
  50. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +3 -3
  51. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +2 -1
  52. package/dist/ts4.2/src/room/track/options.d.ts +0 -1
  53. package/dist/ts4.2/src/room/track/utils.d.ts +1 -0
  54. package/dist/ts4.2/src/utils/cloneDeep.d.ts +2 -0
  55. package/package.json +14 -14
  56. package/src/connectionHelper/checks/webrtc.ts +1 -1
  57. package/src/e2ee/E2eeManager.ts +2 -1
  58. package/src/e2ee/utils.ts +0 -10
  59. package/src/e2ee/worker/FrameCryptor.ts +13 -14
  60. package/src/e2ee/worker/ParticipantKeyHandler.ts +4 -5
  61. package/src/e2ee/worker/e2ee.worker.ts +3 -1
  62. package/src/proto/livekit_models_pb.ts +140 -15
  63. package/src/proto/livekit_rtc_pb.ts +1 -7
  64. package/src/room/PCTransport.ts +116 -1
  65. package/src/room/RTCEngine.ts +49 -85
  66. package/src/room/Room.ts +10 -9
  67. package/src/room/defaults.ts +4 -2
  68. package/src/room/events.ts +1 -1
  69. package/src/room/participant/LocalParticipant.ts +44 -56
  70. package/src/room/track/LocalAudioTrack.ts +1 -1
  71. package/src/room/track/LocalTrack.ts +8 -5
  72. package/src/room/track/LocalVideoTrack.ts +2 -1
  73. package/src/room/track/options.ts +0 -7
  74. package/src/room/track/utils.ts +17 -8
  75. package/src/utils/cloneDeep.test.ts +54 -0
  76. package/src/utils/cloneDeep.ts +11 -0
@@ -284,7 +284,8 @@ export default class LocalVideoTrack extends LocalTrack {
284
284
 
285
285
  /**
286
286
  * @internal
287
- * Sets codecs that should be publishing
287
+ * Sets codecs that should be publishing, returns new codecs that have not yet
288
+ * been published
288
289
  */
289
290
  async setPublishingCodecs(codecs: SubscribedCodec[]): Promise<VideoCodec[]> {
290
291
  log.debug('setting publishing codecs', {
@@ -301,13 +301,6 @@ export function isBackupCodec(codec: string): codec is BackupVideoCodec {
301
301
  return !!backupCodecs.find((backup) => backup === codec);
302
302
  }
303
303
 
304
- export function isCodecEqual(c1: string | undefined, c2: string | undefined): boolean {
305
- return (
306
- c1?.toLowerCase().replace(/audio\/|video\//y, '') ===
307
- c2?.toLowerCase().replace(/audio\/|video\//y, '')
308
- );
309
- }
310
-
311
304
  /**
312
305
  * scalability modes for svc.
313
306
  */
@@ -1,10 +1,13 @@
1
+ import { cloneDeep } from '../../utils/cloneDeep';
1
2
  import { isSafari, sleep } from '../utils';
2
3
  import { Track } from './Track';
3
- import type {
4
- AudioCaptureOptions,
5
- CreateLocalTracksOptions,
6
- ScreenShareCaptureOptions,
7
- VideoCaptureOptions,
4
+ import {
5
+ type AudioCaptureOptions,
6
+ type CreateLocalTracksOptions,
7
+ type ScreenShareCaptureOptions,
8
+ type VideoCaptureOptions,
9
+ VideoCodec,
10
+ videoCodecs,
8
11
  } from './options';
9
12
  import type { AudioTrack } from './types';
10
13
 
@@ -13,9 +16,7 @@ export function mergeDefaultOptions(
13
16
  audioDefaults?: AudioCaptureOptions,
14
17
  videoDefaults?: VideoCaptureOptions,
15
18
  ): CreateLocalTracksOptions {
16
- const opts: CreateLocalTracksOptions = {
17
- ...options,
18
- };
19
+ const opts: CreateLocalTracksOptions = cloneDeep(options) ?? {};
19
20
  if (opts.audio === true) opts.audio = {};
20
21
  if (opts.video === true) opts.video = {};
21
22
 
@@ -181,3 +182,11 @@ export function screenCaptureToDisplayMediaStreamOptions(
181
182
  systemAudio: options.systemAudio,
182
183
  };
183
184
  }
185
+
186
+ export function mimeTypeToVideoCodecString(mimeType: string) {
187
+ const codec = mimeType.split('/')[1].toLowerCase() as VideoCodec;
188
+ if (!videoCodecs.includes(codec)) {
189
+ throw Error(`Video codec not supported: ${codec}`);
190
+ }
191
+ return codec;
192
+ }
@@ -0,0 +1,54 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import { cloneDeep } from './cloneDeep';
3
+
4
+ describe('cloneDeep', () => {
5
+ beforeEach(() => {
6
+ global.structuredClone = vi.fn((val) => {
7
+ return JSON.parse(JSON.stringify(val));
8
+ });
9
+ });
10
+
11
+ afterEach(() => {
12
+ vi.restoreAllMocks();
13
+ });
14
+
15
+ it('should clone a simple object', () => {
16
+ const structuredCloneSpy = vi.spyOn(global, 'structuredClone');
17
+
18
+ const original = { name: 'John', age: 30 };
19
+ const cloned = cloneDeep(original);
20
+
21
+ expect(cloned).toEqual(original);
22
+ expect(cloned).not.toBe(original);
23
+ expect(structuredCloneSpy).toHaveBeenCalledTimes(1);
24
+ });
25
+
26
+ it('should clone an object with nested properties', () => {
27
+ const structuredCloneSpy = vi.spyOn(global, 'structuredClone');
28
+
29
+ const original = { name: 'John', age: 30, children: [{ name: 'Mark', age: 7 }] };
30
+ const cloned = cloneDeep(original);
31
+
32
+ expect(cloned).toEqual(original);
33
+ expect(cloned).not.toBe(original);
34
+ expect(cloned?.children).not.toBe(original.children);
35
+ expect(structuredCloneSpy).toHaveBeenCalledTimes(1);
36
+ });
37
+
38
+ it('should use JSON namespace as a fallback', () => {
39
+ const structuredCloneSpy = vi.spyOn(global, 'structuredClone');
40
+ const serializeSpy = vi.spyOn(JSON, 'stringify');
41
+ const deserializeSpy = vi.spyOn(JSON, 'parse');
42
+
43
+ global.structuredClone = undefined as any;
44
+
45
+ const original = { name: 'John', age: 30 };
46
+ const cloned = cloneDeep(original);
47
+
48
+ expect(cloned).toEqual(original);
49
+ expect(cloned).not.toBe(original);
50
+ expect(structuredCloneSpy).not.toHaveBeenCalled();
51
+ expect(serializeSpy).toHaveBeenCalledTimes(1);
52
+ expect(deserializeSpy).toHaveBeenCalledTimes(1);
53
+ });
54
+ });
@@ -0,0 +1,11 @@
1
+ export function cloneDeep<T>(value: T) {
2
+ if (typeof value === 'undefined') {
3
+ return;
4
+ }
5
+
6
+ if (typeof structuredClone === 'function') {
7
+ return structuredClone(value);
8
+ } else {
9
+ return JSON.parse(JSON.stringify(value)) as T;
10
+ }
11
+ }