livekit-client 2.1.1 → 2.1.2

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.esm.mjs +159 -7
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/index.d.ts +1 -1
  6. package/dist/src/index.d.ts.map +1 -1
  7. package/dist/src/room/RTCEngine.d.ts +2 -1
  8. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  9. package/dist/src/room/Room.d.ts +5 -2
  10. package/dist/src/room/Room.d.ts.map +1 -1
  11. package/dist/src/room/events.d.ts +20 -1
  12. package/dist/src/room/events.d.ts.map +1 -1
  13. package/dist/src/room/participant/Participant.d.ts +2 -1
  14. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  15. package/dist/src/room/track/RemoteTrack.d.ts +1 -0
  16. package/dist/src/room/track/RemoteTrack.d.ts.map +1 -1
  17. package/dist/src/room/track/Track.d.ts +4 -0
  18. package/dist/src/room/track/Track.d.ts.map +1 -1
  19. package/dist/src/room/track/TrackPublication.d.ts +3 -1
  20. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  21. package/dist/src/room/types.d.ts +8 -0
  22. package/dist/src/room/types.d.ts.map +1 -1
  23. package/dist/src/room/utils.d.ts +3 -1
  24. package/dist/src/room/utils.d.ts.map +1 -1
  25. package/dist/ts4.2/src/index.d.ts +1 -1
  26. package/dist/ts4.2/src/room/RTCEngine.d.ts +2 -1
  27. package/dist/ts4.2/src/room/Room.d.ts +5 -2
  28. package/dist/ts4.2/src/room/events.d.ts +20 -1
  29. package/dist/ts4.2/src/room/participant/Participant.d.ts +2 -1
  30. package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +1 -0
  31. package/dist/ts4.2/src/room/track/Track.d.ts +4 -0
  32. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +3 -1
  33. package/dist/ts4.2/src/room/types.d.ts +8 -0
  34. package/dist/ts4.2/src/room/utils.d.ts +3 -1
  35. package/package.json +8 -8
  36. package/src/index.ts +1 -1
  37. package/src/room/RTCEngine.ts +4 -0
  38. package/src/room/Room.ts +27 -1
  39. package/src/room/events.ts +23 -0
  40. package/src/room/participant/Participant.ts +5 -1
  41. package/src/room/track/RemoteTrack.ts +13 -0
  42. package/src/room/track/Track.ts +9 -0
  43. package/src/room/track/TrackPublication.ts +3 -1
  44. package/src/room/types.ts +9 -0
  45. package/src/room/utils.ts +17 -2
@@ -3321,10 +3321,8 @@ function normalizeFieldInfos(fieldInfos, packedByDefault) {
3321
3321
  f.req = (_e = field.req) !== null && _e !== void 0 ? _e : false;
3322
3322
  f.opt = (_f = field.opt) !== null && _f !== void 0 ? _f : false;
3323
3323
  if (field.packed === undefined) {
3324
- if (packedByDefault) {
3324
+ {
3325
3325
  f.packed = field.kind == "enum" || field.kind == "scalar" && field.T != ScalarType.BYTES && field.T != ScalarType.STRING;
3326
- } else {
3327
- f.packed = false;
3328
3326
  }
3329
3327
  }
3330
3328
  // We do not surface options at this time
@@ -3359,7 +3357,7 @@ function normalizeFieldInfos(fieldInfos, packedByDefault) {
3359
3357
  * Provides functionality for messages defined with the proto3 syntax.
3360
3358
  */
3361
3359
  const proto3 = makeProtoRuntime("proto3", fields => {
3362
- return new InternalFieldList(fields, source => normalizeFieldInfos(source, true));
3360
+ return new InternalFieldList(fields, source => normalizeFieldInfos(source));
3363
3361
  },
3364
3362
  // TODO merge with proto2 and initExtensionField, also see initPartial, equals, clone
3365
3363
  target => {
@@ -3951,6 +3949,12 @@ const TrackInfo = /*@__PURE__*/proto3.makeMessageType("livekit.TrackInfo", () =>
3951
3949
  name: "version",
3952
3950
  kind: "message",
3953
3951
  T: TimedVersion
3952
+ }, {
3953
+ no: 19,
3954
+ name: "audio_features",
3955
+ kind: "enum",
3956
+ T: proto3.getEnumType(AudioTrackFeature),
3957
+ repeated: true
3954
3958
  }]);
3955
3959
 
3956
3960
  /**
@@ -4024,6 +4028,12 @@ const DataPacket = /*@__PURE__*/proto3.makeMessageType("livekit.DataPacket", ()
4024
4028
  kind: "message",
4025
4029
  T: SipDTMF,
4026
4030
  oneof: "value"
4031
+ }, {
4032
+ no: 7,
4033
+ name: "transcription",
4034
+ kind: "message",
4035
+ T: Transcription,
4036
+ oneof: "value"
4027
4037
  }]);
4028
4038
 
4029
4039
  /**
@@ -4104,6 +4114,24 @@ const UserPacket = /*@__PURE__*/proto3.makeMessageType("livekit.UserPacket", ()
4104
4114
  kind: "scalar",
4105
4115
  T: 9 /* ScalarType.STRING */,
4106
4116
  opt: true
4117
+ }, {
4118
+ no: 8,
4119
+ name: "id",
4120
+ kind: "scalar",
4121
+ T: 9 /* ScalarType.STRING */,
4122
+ opt: true
4123
+ }, {
4124
+ no: 9,
4125
+ name: "start_time",
4126
+ kind: "scalar",
4127
+ T: 4 /* ScalarType.UINT64 */,
4128
+ opt: true
4129
+ }, {
4130
+ no: 10,
4131
+ name: "end_time",
4132
+ kind: "scalar",
4133
+ T: 4 /* ScalarType.UINT64 */,
4134
+ opt: true
4107
4135
  }]);
4108
4136
 
4109
4137
  /**
@@ -4121,6 +4149,62 @@ const SipDTMF = /*@__PURE__*/proto3.makeMessageType("livekit.SipDTMF", () => [{
4121
4149
  T: 9 /* ScalarType.STRING */
4122
4150
  }]);
4123
4151
 
4152
+ /**
4153
+ * @generated from message livekit.Transcription
4154
+ */
4155
+ const Transcription = /*@__PURE__*/proto3.makeMessageType("livekit.Transcription", () => [{
4156
+ no: 2,
4157
+ name: "participant_identity",
4158
+ kind: "scalar",
4159
+ T: 9 /* ScalarType.STRING */
4160
+ }, {
4161
+ no: 3,
4162
+ name: "track_id",
4163
+ kind: "scalar",
4164
+ T: 9 /* ScalarType.STRING */
4165
+ }, {
4166
+ no: 4,
4167
+ name: "segments",
4168
+ kind: "message",
4169
+ T: TranscriptionSegment,
4170
+ repeated: true
4171
+ }]);
4172
+
4173
+ /**
4174
+ * @generated from message livekit.TranscriptionSegment
4175
+ */
4176
+ const TranscriptionSegment = /*@__PURE__*/proto3.makeMessageType("livekit.TranscriptionSegment", () => [{
4177
+ no: 1,
4178
+ name: "id",
4179
+ kind: "scalar",
4180
+ T: 9 /* ScalarType.STRING */
4181
+ }, {
4182
+ no: 2,
4183
+ name: "text",
4184
+ kind: "scalar",
4185
+ T: 9 /* ScalarType.STRING */
4186
+ }, {
4187
+ no: 3,
4188
+ name: "start_time",
4189
+ kind: "scalar",
4190
+ T: 4 /* ScalarType.UINT64 */
4191
+ }, {
4192
+ no: 4,
4193
+ name: "end_time",
4194
+ kind: "scalar",
4195
+ T: 4 /* ScalarType.UINT64 */
4196
+ }, {
4197
+ no: 5,
4198
+ name: "final",
4199
+ kind: "scalar",
4200
+ T: 8 /* ScalarType.BOOL */
4201
+ }, {
4202
+ no: 6,
4203
+ name: "language",
4204
+ kind: "scalar",
4205
+ T: 9 /* ScalarType.STRING */
4206
+ }]);
4207
+
4124
4208
  /**
4125
4209
  * @generated from message livekit.ParticipantTracks
4126
4210
  */
@@ -5052,6 +5136,7 @@ const LeaveRequest_Action = /*@__PURE__*/proto3.makeEnum("livekit.LeaveRequest.A
5052
5136
  * message to indicate published video track dimensions are changing
5053
5137
  *
5054
5138
  * @generated from message livekit.UpdateVideoLayers
5139
+ * @deprecated
5055
5140
  */
5056
5141
  const UpdateVideoLayers = /*@__PURE__*/proto3.makeMessageType("livekit.UpdateVideoLayers", () => [{
5057
5142
  no: 1,
@@ -9949,6 +10034,11 @@ var RoomEvent;
9949
10034
  * args: (payload: Uint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]], topic?: string)
9950
10035
  */
9951
10036
  RoomEvent["DataReceived"] = "dataReceived";
10037
+ /**
10038
+ * Transcription received from a participant's track.
10039
+ * @beta
10040
+ */
10041
+ RoomEvent["TranscriptionReceived"] = "transcriptionReceived";
9952
10042
  /**
9953
10043
  * Connection quality was changed for a Participant. It'll receive updates
9954
10044
  * from the local participant, as well as any [[RemoteParticipant]]s that we are
@@ -10130,6 +10220,11 @@ var ParticipantEvent;
10130
10220
  * args: (payload: Uint8Array, kind: [[DataPacket_Kind]])
10131
10221
  */
10132
10222
  ParticipantEvent["DataReceived"] = "dataReceived";
10223
+ /**
10224
+ * Transcription received from this participant as data source.
10225
+ * @beta
10226
+ */
10227
+ ParticipantEvent["TranscriptionReceived"] = "transcriptionReceived";
10133
10228
  /**
10134
10229
  * Has speaking status changed for the current participant
10135
10230
  *
@@ -10199,6 +10294,7 @@ var EngineEvent;
10199
10294
  EngineEvent["MediaTrackAdded"] = "mediaTrackAdded";
10200
10295
  EngineEvent["ActiveSpeakersUpdate"] = "activeSpeakersUpdate";
10201
10296
  EngineEvent["DataPacketReceived"] = "dataPacketReceived";
10297
+ EngineEvent["TranscriptionReceived"] = "transcriptionReceived";
10202
10298
  EngineEvent["RTPVideoMapUpdate"] = "rtpVideoMapUpdate";
10203
10299
  EngineEvent["DCBufferStatusChanged"] = "dcBufferStatusChanged";
10204
10300
  EngineEvent["ParticipantUpdate"] = "participantUpdate";
@@ -10281,6 +10377,14 @@ var TrackEvent;
10281
10377
  * @internal
10282
10378
  */
10283
10379
  TrackEvent["AudioTrackFeatureUpdate"] = "audioTrackFeatureUpdate";
10380
+ /**
10381
+ * @beta
10382
+ */
10383
+ TrackEvent["TranscriptionReceived"] = "transcriptionReceived";
10384
+ /**
10385
+ * @experimental
10386
+ */
10387
+ TrackEvent["TimeSyncUpdate"] = "timeSyncUpdate";
10284
10388
  })(TrackEvent || (TrackEvent = {}));
10285
10389
 
10286
10390
  function r(r, e, n) {
@@ -10395,7 +10499,7 @@ function getOSVersion(ua) {
10395
10499
  return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
10396
10500
  }
10397
10501
 
10398
- var version$1 = "2.1.1";
10502
+ var version$1 = "2.1.2";
10399
10503
 
10400
10504
  const version = version$1;
10401
10505
  const protocolVersion = 12;
@@ -10696,6 +10800,9 @@ class Track extends eventsExports.EventEmitter {
10696
10800
  if (this.monitorInterval) {
10697
10801
  clearInterval(this.monitorInterval);
10698
10802
  }
10803
+ if (this.timeSyncHandle) {
10804
+ cancelAnimationFrame(this.timeSyncHandle);
10805
+ }
10699
10806
  }
10700
10807
  /** @internal */
10701
10808
  updateLoggerOptions(loggerOptions) {
@@ -11500,6 +11607,26 @@ function toHttpUrl(url) {
11500
11607
  }
11501
11608
  return url;
11502
11609
  }
11610
+ function extractTranscriptionSegments(transcription) {
11611
+ return transcription.segments.map(_ref => {
11612
+ let {
11613
+ id,
11614
+ text,
11615
+ language,
11616
+ startTime,
11617
+ endTime,
11618
+ final
11619
+ } = _ref;
11620
+ return {
11621
+ id,
11622
+ text,
11623
+ startTime: Number.parseInt(startTime.toString()),
11624
+ endTime: Number.parseInt(endTime.toString()),
11625
+ final,
11626
+ language
11627
+ };
11628
+ });
11629
+ }
11503
11630
 
11504
11631
  const defaultId = 'default';
11505
11632
  class DeviceManager {
@@ -15788,7 +15915,7 @@ class RTCEngine extends eventsExports.EventEmitter {
15788
15915
  }();
15789
15916
  });
15790
15917
  this.handleDataMessage = message => __awaiter(this, void 0, void 0, function* () {
15791
- var _c, _d;
15918
+ var _c, _d, _e;
15792
15919
  // make sure to respect incoming data message order by processing message events one after the other
15793
15920
  const unlock = yield this.dataProcessLock.lock();
15794
15921
  try {
@@ -15810,6 +15937,8 @@ class RTCEngine extends eventsExports.EventEmitter {
15810
15937
  this.emit(EngineEvent.ActiveSpeakersUpdate, dp.value.value.speakers);
15811
15938
  } else if (((_d = dp.value) === null || _d === void 0 ? void 0 : _d.case) === 'user') {
15812
15939
  this.emit(EngineEvent.DataPacketReceived, dp.value.value, dp.kind);
15940
+ } else if (((_e = dp.value) === null || _e === void 0 ? void 0 : _e.case) === 'transcription') {
15941
+ this.emit(EngineEvent.TranscriptionReceived, dp.value.value);
15813
15942
  }
15814
15943
  } finally {
15815
15944
  unlock();
@@ -16915,6 +17044,19 @@ class RemoteTrack extends Track {
16915
17044
  if (!this.monitorInterval) {
16916
17045
  this.monitorInterval = setInterval(() => this.monitorReceiver(), monitorFrequency);
16917
17046
  }
17047
+ this.registerTimeSyncUpdate();
17048
+ }
17049
+ registerTimeSyncUpdate() {
17050
+ const loop = () => {
17051
+ var _a, _b;
17052
+ this.timeSyncHandle = requestAnimationFrame(() => loop());
17053
+ const newTime = (_b = (_a = this.receiver) === null || _a === void 0 ? void 0 : _a.getSynchronizationSources()[0]) === null || _b === void 0 ? void 0 : _b.rtpTimestamp;
17054
+ if (newTime && this.rtpTimestamp !== newTime) {
17055
+ this.emit(TrackEvent.TimeSyncUpdate, newTime);
17056
+ this.rtpTimestamp = newTime;
17057
+ }
17058
+ };
17059
+ loop();
16918
17060
  }
16919
17061
  }
16920
17062
 
@@ -20006,6 +20148,16 @@ class Room extends eventsExports.EventEmitter {
20006
20148
  // also emit on the participant
20007
20149
  participant === null || participant === void 0 ? void 0 : participant.emit(ParticipantEvent.DataReceived, userPacket.payload, kind);
20008
20150
  };
20151
+ this.bufferedSegments = new Map();
20152
+ this.handleTranscription = transcription => {
20153
+ // find the participant
20154
+ const participant = transcription.participantIdentity === this.localParticipant.identity ? this.localParticipant : this.remoteParticipants.get(transcription.participantIdentity);
20155
+ const publication = participant === null || participant === void 0 ? void 0 : participant.trackPublications.get(transcription.trackId);
20156
+ const segments = extractTranscriptionSegments(transcription);
20157
+ publication === null || publication === void 0 ? void 0 : publication.emit(TrackEvent.TranscriptionReceived, segments);
20158
+ participant === null || participant === void 0 ? void 0 : participant.emit(ParticipantEvent.TranscriptionReceived, segments, publication);
20159
+ this.emit(RoomEvent.TranscriptionReceived, segments, participant, publication);
20160
+ };
20009
20161
  this.handleAudioPlaybackStarted = () => {
20010
20162
  if (this.canPlaybackAudio) {
20011
20163
  return;
@@ -20231,7 +20383,7 @@ class Room extends eventsExports.EventEmitter {
20231
20383
  this.onTrackAdded(mediaTrack, stream, receiver);
20232
20384
  }).on(EngineEvent.Disconnected, reason => {
20233
20385
  this.handleDisconnect(this.options.stopLocalTrackOnUnpublish, reason);
20234
- }).on(EngineEvent.ActiveSpeakersUpdate, this.handleActiveSpeakersUpdate).on(EngineEvent.DataPacketReceived, this.handleDataPacket).on(EngineEvent.Resuming, () => {
20386
+ }).on(EngineEvent.ActiveSpeakersUpdate, this.handleActiveSpeakersUpdate).on(EngineEvent.DataPacketReceived, this.handleDataPacket).on(EngineEvent.TranscriptionReceived, this.handleTranscription).on(EngineEvent.Resuming, () => {
20235
20387
  this.clearConnectionReconcile();
20236
20388
  this.isResuming = true;
20237
20389
  this.log.info('Resuming signal connection', this.logContext);