livekit-client 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -11,9 +11,7 @@
11
11
  # JavaScript/TypeScript client SDK for LiveKit
12
12
 
13
13
  <!--BEGIN_DESCRIPTION-->
14
-
15
14
  Use this SDK to add real-time video, audio and data features to your JavaScript/TypeScript app. By connecting to a self- or cloud-hosted <a href="https://livekit.io/">LiveKit</a> server, you can quickly build applications like interactive live streaming or video calls with just a few lines of code.
16
-
17
15
  <!--END_DESCRIPTION-->
18
16
 
19
17
  ## Docs
@@ -329,13 +327,11 @@ If you are targeting legacy browsers, but still want adaptiveStream functionalit
329
327
  Also when targeting legacy browsers, older than the ones specified in our browserslist target, make sure to transpile the library code to your desired target and include required polyfills with babel and/or corejs.
330
328
 
331
329
  <!--BEGIN_REPO_NAV-->
332
-
333
330
  <br/><table>
334
-
335
331
  <thead><tr><th colspan="2">LiveKit Ecosystem</th></tr></thead>
336
332
  <tbody>
337
- <tr><td>Real-time SDKs</td><td><a href="https://github.com/livekit/components-js">React Components</a> · <b>JavaScript</b> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <a href="https://github.com/livekit/client-sdk-react-native">React Native</a> · <a href="https://github.com/livekit/client-sdk-rust">Rust</a> · <a href="https://github.com/livekit/client-sdk-python">Python</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <a href="https://github.com/livekit/client-sdk-unity">Unity (beta)</a></td></tr><tr></tr>
338
- <tr><td>Server APIs</td><td><a href="https://github.com/livekit/server-sdk-js">Node.js</a> · <a href="https://github.com/livekit/server-sdk-go">Golang</a> · <a href="https://github.com/livekit/server-sdk-ruby">Ruby</a> · <a href="https://github.com/livekit/server-sdk-kotlin">Java/Kotlin</a> · <a href="https://github.com/livekit/client-sdk-python">Python</a> · <a href="https://github.com/livekit/client-sdk-rust">Rust</a> · <a href="https://github.com/agence104/livekit-server-sdk-php">PHP (community)</a></td></tr><tr></tr>
333
+ <tr><td>Real-time SDKs</td><td><a href="https://github.com/livekit/components-js">React Components</a> · <b>Browser</b> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <a href="https://github.com/livekit/client-sdk-react-native">React Native</a> · <a href="https://github.com/livekit/rust-sdks">Rust</a> · <a href="https://github.com/livekit/node-sdks">Node.js</a> · <a href="https://github.com/livekit/python-sdks">Python</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <a href="https://github.com/livekit/client-sdk-unity">Unity (beta)</a></td></tr><tr></tr>
334
+ <tr><td>Server APIs</td><td><a href="https://github.com/livekit/node-sdks">Node.js</a> · <a href="https://github.com/livekit/server-sdk-go">Golang</a> · <a href="https://github.com/livekit/server-sdk-ruby">Ruby</a> · <a href="https://github.com/livekit/server-sdk-kotlin">Java/Kotlin</a> · <a href="https://github.com/livekit/python-sdks">Python</a> · <a href="https://github.com/livekit/rust-sdks">Rust</a> · <a href="https://github.com/agence104/livekit-server-sdk-php">PHP (community)</a></td></tr><tr></tr>
339
335
  <tr><td>Agents Frameworks</td><td><a href="https://github.com/livekit/agents">Python</a> · <a href="https://github.com/livekit/agent-playground">Playground</a></td></tr><tr></tr>
340
336
  <tr><td>Services</td><td><a href="https://github.com/livekit/livekit">Livekit server</a> · <a href="https://github.com/livekit/egress">Egress</a> · <a href="https://github.com/livekit/ingress">Ingress</a> · <a href="https://github.com/livekit/sip">SIP</a></td></tr><tr></tr>
341
337
  <tr><td>Resources</td><td><a href="https://docs.livekit.io">Docs</a> · <a href="https://github.com/livekit-examples">Example apps</a> · <a href="https://livekit.io/cloud">Cloud</a> · <a href="https://docs.livekit.io/oss/deployment">Self-hosting</a> · <a href="https://github.com/livekit/livekit-cli">CLI</a></td></tr>
@@ -9891,6 +9891,12 @@ var RoomEvent;
9891
9891
  * to reconnect.
9892
9892
  */
9893
9893
  RoomEvent["Reconnecting"] = "reconnecting";
9894
+ /**
9895
+ * When the signal connection to the server has been interrupted. This isn't noticeable to users most of the time.
9896
+ * It will resolve with a `RoomEvent.Reconnected` once the signal connection has been re-established.
9897
+ * If media fails additionally it an additional `RoomEvent.Reconnecting` will be emitted.
9898
+ */
9899
+ RoomEvent["SignalReconnecting"] = "signalReconnecting";
9894
9900
  /**
9895
9901
  * Fires when a reconnection has been successful.
9896
9902
  */
@@ -10523,7 +10529,7 @@ function getOSVersion(ua) {
10523
10529
  return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
10524
10530
  }
10525
10531
 
10526
- var version$1 = "2.2.0";
10532
+ var version$1 = "2.3.0";
10527
10533
 
10528
10534
  const version = version$1;
10529
10535
  const protocolVersion = 13;
@@ -11717,16 +11723,16 @@ class DeviceManager {
11717
11723
  // resolve actual device id if it's 'default': Chrome returns it when no
11718
11724
  // device has been chosen
11719
11725
  const devices = yield this.getDevices(kind);
11720
- // `default` devices will have the same groupId as the entry with the actual device id so we store the counts for each group id
11721
- const groupIdCounts = new Map(devices.map(d => [d.groupId, 0]));
11722
- devices.forEach(d => {
11723
- var _a;
11724
- return groupIdCounts.set(d.groupId, ((_a = groupIdCounts.get(d.groupId)) !== null && _a !== void 0 ? _a : 0) + 1);
11725
- });
11726
- const device = devices.find(d => {
11727
- var _a;
11728
- return (groupId === d.groupId || ((_a = groupIdCounts.get(d.groupId)) !== null && _a !== void 0 ? _a : 0) > 1) && d.deviceId !== defaultId;
11729
- });
11726
+ const defaultDevice = devices.find(d => d.deviceId === defaultId);
11727
+ if (!defaultDevice) {
11728
+ livekitLogger.warn('could not reliably determine default device');
11729
+ return undefined;
11730
+ }
11731
+ const device = devices.find(d => d.deviceId !== defaultId && d.groupId === (groupId !== null && groupId !== void 0 ? groupId : defaultDevice.groupId));
11732
+ if (!device) {
11733
+ livekitLogger.warn('could not reliably determine default device');
11734
+ return undefined;
11735
+ }
11730
11736
  return device === null || device === void 0 ? void 0 : device.deviceId;
11731
11737
  });
11732
11738
  }
@@ -12101,7 +12107,7 @@ class LocalTrack extends Track {
12101
12107
  this._isUpstreamPaused = false;
12102
12108
  this.emit(TrackEvent.UpstreamResumed, this);
12103
12109
  // this operation is noop if mediastreamtrack is already being sent
12104
- yield this.sender.replaceTrack(this._mediaStreamTrack);
12110
+ yield this.sender.replaceTrack(this.mediaStreamTrack);
12105
12111
  } finally {
12106
12112
  unlock();
12107
12113
  }
@@ -14467,7 +14473,7 @@ const roomOptionDefaults = {
14467
14473
  stopLocalTrackOnUnpublish: true,
14468
14474
  reconnectPolicy: new DefaultReconnectPolicy(),
14469
14475
  disconnectOnPageLeave: true,
14470
- webAudioMix: true
14476
+ webAudioMix: false
14471
14477
  };
14472
14478
  const roomConnectOptionDefaults = {
14473
14479
  autoSubscribe: true,
@@ -19755,8 +19761,9 @@ var ConnectionState;
19755
19761
  ConnectionState["Connecting"] = "connecting";
19756
19762
  ConnectionState["Connected"] = "connected";
19757
19763
  ConnectionState["Reconnecting"] = "reconnecting";
19764
+ ConnectionState["SignalReconnecting"] = "signalReconnecting";
19758
19765
  })(ConnectionState || (ConnectionState = {}));
19759
- const connectionReconcileFrequency = 2 * 1000;
19766
+ const connectionReconcileFrequency = 4 * 1000;
19760
19767
  /**
19761
19768
  * In LiveKit, a room is the logical grouping for a list of participants.
19762
19769
  * Participants in a room can publish tracks, and subscribe to others' tracks.
@@ -20558,12 +20565,18 @@ class Room extends eventsExports.EventEmitter {
20558
20565
  this.clearConnectionReconcile();
20559
20566
  this.isResuming = true;
20560
20567
  this.log.info('Resuming signal connection', this.logContext);
20568
+ if (this.setAndEmitConnectionState(ConnectionState.SignalReconnecting)) {
20569
+ this.emit(RoomEvent.SignalReconnecting);
20570
+ }
20561
20571
  }).on(EngineEvent.Resumed, () => {
20562
20572
  this.registerConnectionReconcile();
20563
20573
  this.isResuming = false;
20564
20574
  this.log.info('Resumed signal connection', this.logContext);
20565
20575
  this.updateSubscriptions();
20566
20576
  this.emitBufferedEvents();
20577
+ if (this.setAndEmitConnectionState(ConnectionState.Connected)) {
20578
+ this.emit(RoomEvent.Reconnected);
20579
+ }
20567
20580
  }).on(EngineEvent.SignalResumed, () => {
20568
20581
  this.bufferedEvents = [];
20569
20582
  if (this.state === ConnectionState.Reconnecting || this.isResuming) {