livekit-client 2.18.8 → 2.18.9

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.
@@ -11773,7 +11773,7 @@ function getMatch(exp, ua) {
11773
11773
  }
11774
11774
  function getOSVersion(ua) {
11775
11775
  return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
11776
- }var version$1 = "2.18.8";const version = version$1;
11776
+ }var version$1 = "2.18.9";const version = version$1;
11777
11777
  const protocolVersion = 16;/** Base error that all LiveKit specific custom errors inherit from. */
11778
11778
  class LivekitError extends Error {
11779
11779
  constructor(code, message, options) {
@@ -24457,23 +24457,28 @@ class DataTrackOutgoingPipelineError extends LivekitReasonedError {
24457
24457
  this.log = livekitLogger;
24458
24458
  /** Resolves once the data track has sent all pending packets the rtc data channel buffer. */
24459
24459
  this.flushedFuture = new Future();
24460
+ this.isFlushed = true;
24460
24461
  this.handleManagerReset = () => {
24462
+ var _a, _b;
24461
24463
  // When the associated manager resets, mark any in flight flushes as complete
24462
24464
  // There's nothing actionable a user can do to get these to complete so no
24463
24465
  // error is being thrown.
24464
- this.handleManagerPacketsFlushed();
24465
- this.manager.off('packetsFlushed', this.handleManagerReset);
24466
+ (_b = (_a = this.flushedFuture).resolve) === null || _b === void 0 ? void 0 : _b.call(_a);
24467
+ this.manager.off('packetsFlushedChange', this.handleManagerPacketsFlushedChange);
24466
24468
  this.manager.off('reset', this.handleManagerReset);
24467
24469
  };
24468
- this.handleManagerPacketsFlushed = () => {
24470
+ this.handleManagerPacketsFlushedChange = event => {
24469
24471
  var _a, _b;
24470
- (_b = (_a = this.flushedFuture).resolve) === null || _b === void 0 ? void 0 : _b.call(_a);
24471
- this.flushedFuture = new Future();
24472
+ this.isFlushed = event.isFlushed;
24473
+ if (event.isFlushed) {
24474
+ (_b = (_a = this.flushedFuture).resolve) === null || _b === void 0 ? void 0 : _b.call(_a);
24475
+ this.flushedFuture = new Future();
24476
+ }
24472
24477
  };
24473
24478
  this.options = options;
24474
24479
  this.manager = manager;
24475
24480
  this.log = getLogger(LoggerNames.DataTracks);
24476
- this.manager.on('packetsFlushed', this.handleManagerPacketsFlushed);
24481
+ this.manager.on('packetsFlushedChange', this.handleManagerPacketsFlushedChange);
24477
24482
  this.manager.on('reset', this.handleManagerReset);
24478
24483
  }
24479
24484
  /** @internal */
@@ -24562,6 +24567,9 @@ class DataTrackOutgoingPipelineError extends LivekitReasonedError {
24562
24567
  **/
24563
24568
  flush() {
24564
24569
  return __awaiter(this, void 0, void 0, function* () {
24570
+ if (this.isFlushed) {
24571
+ return;
24572
+ }
24565
24573
  return this.flushedFuture.promise;
24566
24574
  });
24567
24575
  }
@@ -24707,6 +24715,14 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
24707
24715
  const packet = _c;
24708
24716
  const prev = (_d = this.inFlightPacketCounter.get(handle)) !== null && _d !== void 0 ? _d : 0;
24709
24717
  this.inFlightPacketCounter.set(handle, prev + 1);
24718
+ if (prev === 0) {
24719
+ // A new packet has been sent, so there are now packets in the rtc data channel buffer for
24720
+ // this data track frame
24721
+ this.emit('packetsFlushedChange', {
24722
+ handle,
24723
+ isFlushed: false
24724
+ });
24725
+ }
24710
24726
  this.emit('packetAvailable', {
24711
24727
  handle,
24712
24728
  bytes: packet.toBinary()
@@ -24744,8 +24760,9 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
24744
24760
  }
24745
24761
  this.inFlightPacketCounter.set(handle, counter);
24746
24762
  if (counter === 0) {
24747
- this.emit('packetsFlushed', {
24748
- handle
24763
+ this.emit('packetsFlushedChange', {
24764
+ handle,
24765
+ isFlushed: true
24749
24766
  });
24750
24767
  }
24751
24768
  }