livekit-client 2.0.10 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) 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 +203 -140
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +12826 -15828
  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 +2 -1
  10. package/dist/src/api/SignalClient.d.ts.map +1 -1
  11. package/dist/src/connectionHelper/ConnectionCheck.d.ts +3 -2
  12. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -1
  13. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  14. package/dist/src/index.d.ts +3 -2
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/room/PCTransport.d.ts.map +1 -1
  17. package/dist/src/room/RTCEngine.d.ts +3 -3
  18. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  19. package/dist/src/room/events.d.ts +5 -1
  20. package/dist/src/room/events.d.ts.map +1 -1
  21. package/dist/src/room/participant/LocalParticipant.d.ts +1 -0
  22. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  23. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  24. package/dist/src/room/track/LocalAudioTrack.d.ts +7 -0
  25. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  26. package/dist/src/room/track/LocalTrackPublication.d.ts +3 -2
  27. package/dist/src/room/track/LocalTrackPublication.d.ts.map +1 -1
  28. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  29. package/dist/src/room/track/Track.d.ts +2 -1
  30. package/dist/src/room/track/Track.d.ts.map +1 -1
  31. package/dist/src/room/track/options.d.ts +1 -1
  32. package/dist/src/room/track/options.d.ts.map +1 -1
  33. package/dist/src/room/utils.d.ts +4 -1
  34. package/dist/src/room/utils.d.ts.map +1 -1
  35. package/dist/src/utils/browserParser.d.ts +1 -0
  36. package/dist/src/utils/browserParser.d.ts.map +1 -1
  37. package/dist/ts4.2/src/api/SignalClient.d.ts +2 -1
  38. package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +3 -2
  39. package/dist/ts4.2/src/index.d.ts +3 -2
  40. package/dist/ts4.2/src/room/RTCEngine.d.ts +3 -3
  41. package/dist/ts4.2/src/room/events.d.ts +5 -1
  42. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -0
  43. package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +7 -0
  44. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +3 -2
  45. package/dist/ts4.2/src/room/track/Track.d.ts +2 -1
  46. package/dist/ts4.2/src/room/track/options.d.ts +1 -1
  47. package/dist/ts4.2/src/room/utils.d.ts +4 -1
  48. package/dist/ts4.2/src/utils/browserParser.d.ts +1 -0
  49. package/package.json +10 -10
  50. package/src/api/SignalClient.ts +9 -0
  51. package/src/connectionHelper/ConnectionCheck.ts +6 -3
  52. package/src/e2ee/worker/FrameCryptor.ts +0 -1
  53. package/src/e2ee/worker/e2ee.worker.ts +3 -1
  54. package/src/index.ts +3 -0
  55. package/src/room/PCTransport.ts +0 -2
  56. package/src/room/RTCEngine.ts +18 -62
  57. package/src/room/events.ts +5 -0
  58. package/src/room/participant/LocalParticipant.ts +17 -5
  59. package/src/room/participant/publishUtils.ts +2 -1
  60. package/src/room/track/LocalAudioTrack.ts +40 -0
  61. package/src/room/track/LocalTrackPublication.ts +28 -2
  62. package/src/room/track/LocalVideoTrack.ts +7 -3
  63. package/src/room/track/Track.ts +13 -0
  64. package/src/room/track/options.ts +22 -1
  65. package/src/room/utils.ts +32 -27
  66. package/src/utils/browserParser.test.ts +4 -0
  67. package/src/utils/browserParser.ts +11 -1
@@ -350,7 +350,28 @@ export function isBackupCodec(codec: string): codec is BackupVideoCodec {
350
350
  /**
351
351
  * scalability modes for svc.
352
352
  */
353
- export type ScalabilityMode = 'L1T3' | 'L2T3' | 'L2T3_KEY' | 'L3T3' | 'L3T3_KEY';
353
+ export type ScalabilityMode =
354
+ | 'L1T1'
355
+ | 'L1T2'
356
+ | 'L1T3'
357
+ | 'L2T1'
358
+ | 'L2T1h'
359
+ | 'L2T1_KEY'
360
+ | 'L2T2'
361
+ | 'L2T2h'
362
+ | 'L2T2_KEY'
363
+ | 'L2T3'
364
+ | 'L2T3h'
365
+ | 'L2T3_KEY'
366
+ | 'L3T1'
367
+ | 'L3T1h'
368
+ | 'L3T1_KEY'
369
+ | 'L3T2'
370
+ | 'L3T2h'
371
+ | 'L3T2_KEY'
372
+ | 'L3T3'
373
+ | 'L3T3h'
374
+ | 'L3T3_KEY';
354
375
 
355
376
  export namespace AudioPresets {
356
377
  export const telephone: AudioPreset = {
package/src/room/utils.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ClientInfo, ClientInfo_SDK } from '@livekit/protocol';
2
- import type { DetectableBrowser } from '../utils/browserParser';
3
2
  import { getBrowser } from '../utils/browserParser';
4
3
  import { protocolVersion, version } from '../version';
5
4
  import CriticalTimers from './timers';
@@ -107,31 +106,6 @@ export function supportsSetSinkId(elm?: HTMLMediaElement): boolean {
107
106
  return 'setSinkId' in elm;
108
107
  }
109
108
 
110
- const setCodecPreferencesVersions: Record<DetectableBrowser, string> = {
111
- Chrome: '100',
112
- Safari: '15',
113
- Firefox: '100',
114
- };
115
-
116
- export function supportsSetCodecPreferences(transceiver: RTCRtpTransceiver): boolean {
117
- if (!isWeb()) {
118
- return false;
119
- }
120
- if (!('setCodecPreferences' in transceiver)) {
121
- return false;
122
- }
123
- const browser = getBrowser();
124
- if (!browser?.name || !browser.version) {
125
- // version is required
126
- return false;
127
- }
128
- const v = setCodecPreferencesVersions[browser.name];
129
- if (v) {
130
- return compareVersions(browser.version, v) >= 0;
131
- }
132
- return false;
133
- }
134
-
135
109
  export function isBrowserSupported() {
136
110
  if (typeof RTCPeerConnection === 'undefined') {
137
111
  return false;
@@ -158,7 +132,35 @@ export function isSafari17(): boolean {
158
132
 
159
133
  export function isMobile(): boolean {
160
134
  if (!isWeb()) return false;
161
- return /Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent);
135
+
136
+ return (
137
+ // @ts-expect-error `userAgentData` is not yet part of typescript
138
+ navigator.userAgentData?.mobile ??
139
+ /Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent)
140
+ );
141
+ }
142
+
143
+ export function isE2EESimulcastSupported() {
144
+ const browser = getBrowser();
145
+ const supportedSafariVersion = '17.2'; // see https://bugs.webkit.org/show_bug.cgi?id=257803
146
+ if (browser) {
147
+ if (browser.name !== 'Safari' && browser.os !== 'iOS') {
148
+ return true;
149
+ } else if (
150
+ browser.os === 'iOS' &&
151
+ browser.osVersion &&
152
+ compareVersions(supportedSafariVersion, browser.osVersion) >= 0
153
+ ) {
154
+ return true;
155
+ } else if (
156
+ browser.name === 'Safari' &&
157
+ compareVersions(supportedSafariVersion, browser.version) >= 0
158
+ ) {
159
+ return true;
160
+ } else {
161
+ return false;
162
+ }
163
+ }
162
164
  }
163
165
 
164
166
  export function isWeb(): boolean {
@@ -447,6 +449,9 @@ export function createAudioAnalyser(
447
449
  return { calculateVolume, analyser, cleanup };
448
450
  }
449
451
 
452
+ /**
453
+ * @internal
454
+ */
450
455
  export class Mutex {
451
456
  private _locking: Promise<void>;
452
457
 
@@ -29,12 +29,14 @@ describe('browser parser', () => {
29
29
  expect(details?.name).toBe('Safari');
30
30
  expect(details?.version).toBe('16.3');
31
31
  expect(details?.os).toBe('macOS');
32
+ expect(details?.osVersion).toBe('10.15.7');
32
33
  });
33
34
  it('parses Safari iOS correctly', () => {
34
35
  const details = getBrowser(iOSSafariUA, true);
35
36
  expect(details?.name).toBe('Safari');
36
37
  expect(details?.version).toBe('16.5');
37
38
  expect(details?.os).toBe('iOS');
39
+ expect(details?.osVersion).toBe('16.5.1');
38
40
  });
39
41
  it('parses Firefox correctly', () => {
40
42
  const details = getBrowser(firefoxUA, true);
@@ -46,6 +48,7 @@ describe('browser parser', () => {
46
48
  expect(details?.name).toBe('Firefox');
47
49
  expect(details?.version).toBe('115.0');
48
50
  expect(details?.os).toBe('iOS');
51
+ expect(details?.osVersion).toBe('13.4.1');
49
52
  });
50
53
  it('parses Chrome correctly', () => {
51
54
  const details = getBrowser(chromeUA, true);
@@ -57,6 +60,7 @@ describe('browser parser', () => {
57
60
  expect(details?.name).toBe('Chrome');
58
61
  expect(details?.version).toBe('115.0.5790.130');
59
62
  expect(details?.os).toBe('iOS');
63
+ expect(details?.osVersion).toBe('16.5');
60
64
  });
61
65
  it('detects brave as chromium based', () => {
62
66
  const details = getBrowser(braveUA, true);
@@ -10,6 +10,7 @@ export type BrowserDetails = {
10
10
  name: DetectableBrowser;
11
11
  version: string;
12
12
  os?: DetectableOS;
13
+ osVersion?: string;
13
14
  };
14
15
 
15
16
  let browserDetails: BrowserDetails | undefined;
@@ -17,7 +18,7 @@ let browserDetails: BrowserDetails | undefined;
17
18
  /**
18
19
  * @internal
19
20
  */
20
- export function getBrowser(userAgent?: string, force = true) {
21
+ export function getBrowser(userAgent?: string, force = true): BrowserDetails | undefined {
21
22
  if (typeof userAgent === 'undefined' && typeof navigator === 'undefined') {
22
23
  return;
23
24
  }
@@ -37,6 +38,7 @@ const browsersList = [
37
38
  name: 'Firefox',
38
39
  version: getMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua),
39
40
  os: ua.toLowerCase().includes('fxios') ? 'iOS' : undefined,
41
+ osVersion: getOSVersion(ua),
40
42
  };
41
43
  return browser;
42
44
  },
@@ -48,6 +50,7 @@ const browsersList = [
48
50
  name: 'Chrome',
49
51
  version: getMatch(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua),
50
52
  os: ua.toLowerCase().includes('crios') ? 'iOS' : undefined,
53
+ osVersion: getOSVersion(ua),
51
54
  };
52
55
 
53
56
  return browser;
@@ -61,6 +64,7 @@ const browsersList = [
61
64
  name: 'Safari',
62
65
  version: getMatch(commonVersionIdentifier, ua),
63
66
  os: ua.includes('mobile/') ? 'iOS' : 'macOS',
67
+ osVersion: getOSVersion(ua),
64
68
  };
65
69
 
66
70
  return browser;
@@ -72,3 +76,9 @@ function getMatch(exp: RegExp, ua: string, id = 1) {
72
76
  const match = ua.match(exp);
73
77
  return (match && match.length >= id && match[id]) || '';
74
78
  }
79
+
80
+ function getOSVersion(ua: string) {
81
+ return ua.includes('mac os')
82
+ ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.')
83
+ : undefined;
84
+ }