livekit-client 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -11,7 +11,9 @@
11
11
  # JavaScript/TypeScript client SDK for LiveKit
12
12
 
13
13
  <!--BEGIN_DESCRIPTION-->
14
+
14
15
  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
+
15
17
  <!--END_DESCRIPTION-->
16
18
 
17
19
  ## Docs
@@ -20,6 +22,10 @@ Docs and guides at [https://docs.livekit.io](https://docs.livekit.io)
20
22
 
21
23
  [SDK reference](https://docs.livekit.io/client-sdk-js/)
22
24
 
25
+ > [!NOTE]
26
+ > This is v2 of `livekit-client`. When migrating from v1.x to v2.x you might encounter a small set of breaking changes.
27
+ > Read the [migration guide](https://docs.livekit.io/guides/migrate-from-v1/) for a detailed overview of what has changed.
28
+
23
29
  ## Installation
24
30
 
25
31
  ### Yarn
@@ -323,7 +329,9 @@ If you are targeting legacy browsers, but still want adaptiveStream functionalit
323
329
  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.
324
330
 
325
331
  <!--BEGIN_REPO_NAV-->
332
+
326
333
  <br/><table>
334
+
327
335
  <thead><tr><th colspan="2">LiveKit Ecosystem</th></tr></thead>
328
336
  <tbody>
329
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>
@@ -3874,6 +3874,14 @@ var DisconnectReason;
3874
3874
  * @generated from enum value: JOIN_FAILURE = 7;
3875
3875
  */
3876
3876
  DisconnectReason[DisconnectReason["JOIN_FAILURE"] = 7] = "JOIN_FAILURE";
3877
+ /**
3878
+ * @generated from enum value: MIGRATION = 8;
3879
+ */
3880
+ DisconnectReason[DisconnectReason["MIGRATION"] = 8] = "MIGRATION";
3881
+ /**
3882
+ * @generated from enum value: SIGNAL_CLOSE = 9;
3883
+ */
3884
+ DisconnectReason[DisconnectReason["SIGNAL_CLOSE"] = 9] = "SIGNAL_CLOSE";
3877
3885
  })(DisconnectReason || (DisconnectReason = {}));
3878
3886
  // Retrieve enum metadata with: proto3.getEnumType(DisconnectReason)
3879
3887
  proto3.util.setEnumType(DisconnectReason, "livekit.DisconnectReason", [{
@@ -3900,6 +3908,12 @@ proto3.util.setEnumType(DisconnectReason, "livekit.DisconnectReason", [{
3900
3908
  }, {
3901
3909
  no: 7,
3902
3910
  name: "JOIN_FAILURE"
3911
+ }, {
3912
+ no: 8,
3913
+ name: "MIGRATION"
3914
+ }, {
3915
+ no: 9,
3916
+ name: "SIGNAL_CLOSE"
3903
3917
  }]);
3904
3918
  /**
3905
3919
  * @generated from enum livekit.ReconnectReason
@@ -10108,7 +10122,14 @@ var RoomEvent;
10108
10122
  RoomEvent["Reconnected"] = "reconnected";
10109
10123
  /**
10110
10124
  * When disconnected from room. This fires when room.disconnect() is called or
10111
- * when an unrecoverable connection issue had occured
10125
+ * when an unrecoverable connection issue had occured.
10126
+ *
10127
+ * DisconnectReason can be used to determine why the participant was disconnected. Notable reasons are
10128
+ * - DUPLICATE_IDENTITY: another client with the same identity has joined the room
10129
+ * - PARTICIPANT_REMOVED: participant was removed by RemoveParticipant API
10130
+ * - ROOM_DELETED: the room has ended via DeleteRoom API
10131
+ *
10132
+ * args: ([[DisconnectReason]])
10112
10133
  */
10113
10134
  RoomEvent["Disconnected"] = "disconnected";
10114
10135
  /**
@@ -10682,7 +10703,7 @@ function getMatch(exp, ua) {
10682
10703
  return match && match.length >= id && match[id] || '';
10683
10704
  }
10684
10705
 
10685
- var version$1 = "2.0.0";
10706
+ var version$1 = "2.0.1";
10686
10707
 
10687
10708
  const version = version$1;
10688
10709
  const protocolVersion = 12;
@@ -11943,6 +11964,7 @@ class LeaveRequest extends Message {
11943
11964
  /**
11944
11965
  * sent when server initiates the disconnect due to server-restart
11945
11966
  * indicates clients should attempt full-reconnect sequence
11967
+ * NOTE: `can_reconnect` obsoleted by `action` starting in protocol version 13
11946
11968
  *
11947
11969
  * @generated from field: bool can_reconnect = 1;
11948
11970
  */
@@ -11951,6 +11973,10 @@ class LeaveRequest extends Message {
11951
11973
  * @generated from field: livekit.DisconnectReason reason = 2;
11952
11974
  */
11953
11975
  this.reason = DisconnectReason.UNKNOWN_REASON;
11976
+ /**
11977
+ * @generated from field: livekit.LeaveRequest.Action action = 3;
11978
+ */
11979
+ this.action = LeaveRequest_Action.DISCONNECT;
11954
11980
  proto3.util.initPartial(data, this);
11955
11981
  }
11956
11982
  static fromBinary(bytes, options) {
@@ -11978,6 +12004,53 @@ LeaveRequest.fields = proto3.util.newFieldList(() => [{
11978
12004
  name: "reason",
11979
12005
  kind: "enum",
11980
12006
  T: proto3.getEnumType(DisconnectReason)
12007
+ }, {
12008
+ no: 3,
12009
+ name: "action",
12010
+ kind: "enum",
12011
+ T: proto3.getEnumType(LeaveRequest_Action)
12012
+ }, {
12013
+ no: 4,
12014
+ name: "regions",
12015
+ kind: "message",
12016
+ T: RegionSettings
12017
+ }]);
12018
+ /**
12019
+ * indicates action clients should take on receiving this message
12020
+ *
12021
+ * @generated from enum livekit.LeaveRequest.Action
12022
+ */
12023
+ var LeaveRequest_Action;
12024
+ (function (LeaveRequest_Action) {
12025
+ /**
12026
+ * should disconnect
12027
+ *
12028
+ * @generated from enum value: DISCONNECT = 0;
12029
+ */
12030
+ LeaveRequest_Action[LeaveRequest_Action["DISCONNECT"] = 0] = "DISCONNECT";
12031
+ /**
12032
+ * should attempt a resume with `reconnect=1` in join URL
12033
+ *
12034
+ * @generated from enum value: RESUME = 1;
12035
+ */
12036
+ LeaveRequest_Action[LeaveRequest_Action["RESUME"] = 1] = "RESUME";
12037
+ /**
12038
+ * should attempt a reconnect, i. e. no `reconnect=1`
12039
+ *
12040
+ * @generated from enum value: RECONNECT = 2;
12041
+ */
12042
+ LeaveRequest_Action[LeaveRequest_Action["RECONNECT"] = 2] = "RECONNECT";
12043
+ })(LeaveRequest_Action || (LeaveRequest_Action = {}));
12044
+ // Retrieve enum metadata with: proto3.getEnumType(LeaveRequest_Action)
12045
+ proto3.util.setEnumType(LeaveRequest_Action, "livekit.LeaveRequest.Action", [{
12046
+ no: 0,
12047
+ name: "DISCONNECT"
12048
+ }, {
12049
+ no: 1,
12050
+ name: "RESUME"
12051
+ }, {
12052
+ no: 2,
12053
+ name: "RECONNECT"
11981
12054
  }]);
11982
12055
  /**
11983
12056
  * message to indicate published video track dimensions are changing
@@ -12660,6 +12733,10 @@ class SyncState extends Message {
12660
12733
  * @generated from field: repeated livekit.DataChannelInfo data_channels = 4;
12661
12734
  */
12662
12735
  this.dataChannels = [];
12736
+ /**
12737
+ * @generated from field: repeated string track_sids_disabled = 6;
12738
+ */
12739
+ this.trackSidsDisabled = [];
12663
12740
  proto3.util.initPartial(data, this);
12664
12741
  }
12665
12742
  static fromBinary(bytes, options) {
@@ -12704,6 +12781,12 @@ SyncState.fields = proto3.util.newFieldList(() => [{
12704
12781
  name: "offer",
12705
12782
  kind: "message",
12706
12783
  T: SessionDescription
12784
+ }, {
12785
+ no: 6,
12786
+ name: "track_sids_disabled",
12787
+ kind: "scalar",
12788
+ T: 9 /* ScalarType.STRING */,
12789
+ repeated: true
12707
12790
  }]);
12708
12791
  /**
12709
12792
  * @generated from message livekit.DataChannelInfo
@@ -13731,10 +13814,6 @@ function isFireFox() {
13731
13814
  var _a;
13732
13815
  return ((_a = getBrowser()) === null || _a === void 0 ? void 0 : _a.name) === 'Firefox';
13733
13816
  }
13734
- function isChromiumBased() {
13735
- var _a;
13736
- return ((_a = getBrowser()) === null || _a === void 0 ? void 0 : _a.name) === 'Chrome';
13737
- }
13738
13817
  function isSafari() {
13739
13818
  var _a;
13740
13819
  return ((_a = getBrowser()) === null || _a === void 0 ? void 0 : _a.name) === 'Safari';
@@ -16218,8 +16297,7 @@ class PCTransport extends eventsExports.EventEmitter {
16218
16297
  return this._pc;
16219
16298
  }
16220
16299
  constructor(config) {
16221
- let mediaConstraints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16222
- let loggerOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
16300
+ let loggerOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16223
16301
  var _a;
16224
16302
  super();
16225
16303
  this.log = livekitLogger;
@@ -16263,13 +16341,10 @@ class PCTransport extends eventsExports.EventEmitter {
16263
16341
  this.log = getLogger((_a = loggerOptions.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.PCTransport);
16264
16342
  this.loggerOptions = loggerOptions;
16265
16343
  this.config = config;
16266
- this.mediaConstraints = mediaConstraints;
16267
16344
  this._pc = this.createPC();
16268
16345
  }
16269
16346
  createPC() {
16270
- const pc = isChromiumBased() ?
16271
- // @ts-expect-error chrome allows additional media constraints to be passed into the RTCPeerConnection constructor
16272
- new RTCPeerConnection(this.config, this.mediaConstraints) : new RTCPeerConnection(this.config);
16347
+ const pc = new RTCPeerConnection(this.config);
16273
16348
  pc.onicecandidate = ev => {
16274
16349
  var _a;
16275
16350
  if (!ev.candidate) return;
@@ -16812,12 +16887,7 @@ class PCTransportManager {
16812
16887
  this.loggerOptions = loggerOptions;
16813
16888
  this.isPublisherConnectionRequired = !subscriberPrimary;
16814
16889
  this.isSubscriberConnectionRequired = subscriberPrimary;
16815
- const googConstraints = {
16816
- optional: [{
16817
- googDscp: true
16818
- }]
16819
- };
16820
- this.publisher = new PCTransport(rtcConfig, googConstraints, loggerOptions);
16890
+ this.publisher = new PCTransport(rtcConfig, loggerOptions);
16821
16891
  this.subscriber = new PCTransport(rtcConfig, loggerOptions);
16822
16892
  this.publisher.onConnectionStateChange = this.updateState;
16823
16893
  this.subscriber.onConnectionStateChange = this.updateState;
@@ -18056,10 +18126,14 @@ class RTCEngine extends eventsExports.EventEmitter {
18056
18126
  */
18057
18127
  const autoSubscribe = (_b = (_a = this.signalOpts) === null || _a === void 0 ? void 0 : _a.autoSubscribe) !== null && _b !== void 0 ? _b : true;
18058
18128
  const trackSids = new Array();
18129
+ const trackSidsDisabled = new Array();
18059
18130
  remoteTracks.forEach(track => {
18060
18131
  if (track.isDesired !== autoSubscribe) {
18061
18132
  trackSids.push(track.trackSid);
18062
18133
  }
18134
+ if (!track.isEnabled) {
18135
+ trackSidsDisabled.push(track.trackSid);
18136
+ }
18063
18137
  });
18064
18138
  this.client.sendSyncState(new SyncState({
18065
18139
  answer: previousAnswer ? toProtoSessionDescription({
@@ -18076,7 +18150,8 @@ class RTCEngine extends eventsExports.EventEmitter {
18076
18150
  participantTracks: []
18077
18151
  }),
18078
18152
  publishTracks: getTrackPublicationInfo(localTracks),
18079
- dataChannels: this.dataChannelsInfo()
18153
+ dataChannels: this.dataChannelsInfo(),
18154
+ trackSidsDisabled
18080
18155
  }));
18081
18156
  }
18082
18157
  /* @internal */