@webex/web-client-media-engine 3.33.3 → 3.33.4

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.
package/dist/esm/index.js CHANGED
@@ -30,7 +30,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
30
  PERFORMANCE OF THIS SOFTWARE.
31
31
  ***************************************************************************** */
32
32
 
33
- function __awaiter$2(thisArg, _arguments, P, generator) {
33
+ function __awaiter$1(thisArg, _arguments, P, generator) {
34
34
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
35
35
  return new (P || (P = Promise))(function (resolve, reject) {
36
36
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -352,7 +352,7 @@ var DeviceKind$1;
352
352
  * media has successfully been obtained.
353
353
  */
354
354
  function getUserMedia(constraints) {
355
- return __awaiter$2(this, void 0, void 0, function* () {
355
+ return __awaiter$1(this, void 0, void 0, function* () {
356
356
  return navigator.mediaDevices.getUserMedia(constraints);
357
357
  });
358
358
  }
@@ -377,7 +377,7 @@ function getDisplayMedia(constraints) {
377
377
  * fulfilled.
378
378
  */
379
379
  function enumerateDevices() {
380
- return __awaiter$2(this, void 0, void 0, function* () {
380
+ return __awaiter$1(this, void 0, void 0, function* () {
381
381
  return navigator.mediaDevices.enumerateDevices();
382
382
  });
383
383
  }
@@ -399,7 +399,7 @@ function setOnDeviceChangeHandler$1(handler) {
399
399
  * @returns Array of Permission Status objects.
400
400
  */
401
401
  function checkNavigatorPermissions(deviceKinds) {
402
- return __awaiter$2(this, void 0, void 0, function* () {
402
+ return __awaiter$1(this, void 0, void 0, function* () {
403
403
  const permissionRequests = [];
404
404
  if (deviceKinds.includes(DeviceKind$1.VideoInput)) {
405
405
  permissionRequests.push(navigator.permissions.query({ name: 'camera' }));
@@ -417,7 +417,7 @@ function checkNavigatorPermissions(deviceKinds) {
417
417
  * @returns True if device permissions exist, false if otherwise.
418
418
  */
419
419
  function checkDevicePermissions(deviceKinds) {
420
- return __awaiter$2(this, void 0, void 0, function* () {
420
+ return __awaiter$1(this, void 0, void 0, function* () {
421
421
  try {
422
422
  const permissions = yield checkNavigatorPermissions(deviceKinds);
423
423
  if (permissions.every((permission) => permission.state === 'granted')) {
@@ -447,7 +447,7 @@ function checkDevicePermissions(deviceKinds) {
447
447
  * @returns The callback's response.
448
448
  */
449
449
  function ensureDevicePermissions(deviceKinds, callback) {
450
- return __awaiter$2(this, void 0, void 0, function* () {
450
+ return __awaiter$1(this, void 0, void 0, function* () {
451
451
  try {
452
452
  const hasDevicePermissions = yield checkDevicePermissions(deviceKinds);
453
453
  if (!hasDevicePermissions) {
@@ -516,7 +516,7 @@ class WebrtcCoreError {
516
516
  * @returns A LocalCameraStream object or an error.
517
517
  */
518
518
  function createCameraStream(cameraStreamConstructor, constraints) {
519
- return __awaiter$2(this, void 0, void 0, function* () {
519
+ return __awaiter$1(this, void 0, void 0, function* () {
520
520
  let stream;
521
521
  try {
522
522
  stream = yield getUserMedia({ video: Object.assign({}, constraints) });
@@ -536,7 +536,7 @@ function createCameraStream(cameraStreamConstructor, constraints) {
536
536
  * @returns A LocalMicrophoneStream object or an error.
537
537
  */
538
538
  function createMicrophoneStream(microphoneStreamConstructor, constraints) {
539
- return __awaiter$2(this, void 0, void 0, function* () {
539
+ return __awaiter$1(this, void 0, void 0, function* () {
540
540
  let stream;
541
541
  try {
542
542
  stream = yield getUserMedia({ audio: Object.assign({}, constraints) });
@@ -559,7 +559,7 @@ function createMicrophoneStream(microphoneStreamConstructor, constraints) {
559
559
  * @returns A Promise that resolves to a LocalCameraStream and a LocalMicrophoneStream or an error.
560
560
  */
561
561
  function createCameraAndMicrophoneStreams(cameraStreamConstructor, microphoneStreamConstructor, constraints) {
562
- return __awaiter$2(this, void 0, void 0, function* () {
562
+ return __awaiter$1(this, void 0, void 0, function* () {
563
563
  let stream;
564
564
  try {
565
565
  stream = yield getUserMedia({
@@ -604,7 +604,7 @@ function createCameraAndMicrophoneStreams(cameraStreamConstructor, microphoneStr
604
604
  * instead.
605
605
  */
606
606
  function createDisplayMedia(options) {
607
- return __awaiter$2(this, void 0, void 0, function* () {
607
+ return __awaiter$1(this, void 0, void 0, function* () {
608
608
  var _a, _b;
609
609
  let stream;
610
610
  const videoConstraints = options.video.constraints || true;
@@ -645,7 +645,7 @@ function createDisplayMedia(options) {
645
645
  * @returns A Promise that resolves to a LocalDisplayStream or an error.
646
646
  */
647
647
  function createDisplayStream(displayStreamConstructor, videoContentHint) {
648
- return __awaiter$2(this, void 0, void 0, function* () {
648
+ return __awaiter$1(this, void 0, void 0, function* () {
649
649
  const [localDisplayStream] = yield createDisplayMedia({
650
650
  video: { displayStreamConstructor, videoContentHint },
651
651
  });
@@ -663,7 +663,7 @@ function createDisplayStream(displayStreamConstructor, videoContentHint) {
663
663
  * instead.
664
664
  */
665
665
  function createDisplayStreamWithAudio(displayStreamConstructor, systemAudioStreamConstructor, videoContentHint) {
666
- return __awaiter$2(this, void 0, void 0, function* () {
666
+ return __awaiter$1(this, void 0, void 0, function* () {
667
667
  return createDisplayMedia({
668
668
  video: { displayStreamConstructor, videoContentHint },
669
669
  audio: { systemAudioStreamConstructor },
@@ -677,7 +677,7 @@ function createDisplayStreamWithAudio(displayStreamConstructor, systemAudioStrea
677
677
  * @returns List of media devices in an array of MediaDeviceInfo objects.
678
678
  */
679
679
  function getDevices(deviceKind) {
680
- return __awaiter$2(this, void 0, void 0, function* () {
680
+ return __awaiter$1(this, void 0, void 0, function* () {
681
681
  let devices;
682
682
  const deviceKinds = deviceKind
683
683
  ? [deviceKind]
@@ -697,7 +697,7 @@ function getDevices(deviceKind) {
697
697
  * @returns List of microphone devices in an array of MediaDeviceInfo objects.
698
698
  */
699
699
  function getAudioInputDevices() {
700
- return __awaiter$2(this, void 0, void 0, function* () {
700
+ return __awaiter$1(this, void 0, void 0, function* () {
701
701
  return getDevices(DeviceKind$1.AudioInput);
702
702
  });
703
703
  }
@@ -707,7 +707,7 @@ function getAudioInputDevices() {
707
707
  * @returns List of speaker devices in an array of MediaDeviceInfo objects.
708
708
  */
709
709
  function getAudioOutputDevices() {
710
- return __awaiter$2(this, void 0, void 0, function* () {
710
+ return __awaiter$1(this, void 0, void 0, function* () {
711
711
  return getDevices(DeviceKind$1.AudioOutput);
712
712
  });
713
713
  }
@@ -717,7 +717,7 @@ function getAudioOutputDevices() {
717
717
  * @returns List of camera devices in an array of MediaDeviceInfo objects.
718
718
  */
719
719
  function getVideoInputDevices() {
720
- return __awaiter$2(this, void 0, void 0, function* () {
720
+ return __awaiter$1(this, void 0, void 0, function* () {
721
721
  return getDevices(DeviceKind$1.VideoInput);
722
722
  });
723
723
  }
@@ -1496,7 +1496,7 @@ class _LocalStream extends Stream {
1496
1496
  * @param effect - The effect to add.
1497
1497
  */
1498
1498
  addEffect(effect) {
1499
- return __awaiter$2(this, void 0, void 0, function* () {
1499
+ return __awaiter$1(this, void 0, void 0, function* () {
1500
1500
  // Check if the effect has already been added.
1501
1501
  if (this.effects.some((e) => e.id === effect.id)) {
1502
1502
  return;
@@ -1633,7 +1633,7 @@ class _LocalStream extends Stream {
1633
1633
  * Cleanup the local effects.
1634
1634
  */
1635
1635
  disposeEffects() {
1636
- return __awaiter$2(this, void 0, void 0, function* () {
1636
+ return __awaiter$1(this, void 0, void 0, function* () {
1637
1637
  this.loadingEffects.clear();
1638
1638
  // Dispose of any effects currently in use
1639
1639
  if (this.effects.length > 0) {
@@ -1658,7 +1658,7 @@ class LocalAudioStream extends LocalStream {
1658
1658
  * @returns A promise which resolves when the constraints have been successfully applied.
1659
1659
  */
1660
1660
  applyConstraints(constraints) {
1661
- return __awaiter$2(this, void 0, void 0, function* () {
1661
+ return __awaiter$1(this, void 0, void 0, function* () {
1662
1662
  logger$3.log(`Applying constraints to local track:`, constraints);
1663
1663
  return this.inputTrack.applyConstraints(constraints).then(() => {
1664
1664
  this[LocalStreamEventNames.ConstraintsChange].emit();
@@ -1678,7 +1678,7 @@ class LocalVideoStream extends LocalStream {
1678
1678
  * @returns A promise which resolves when the constraints have been successfully applied.
1679
1679
  */
1680
1680
  applyConstraints(constraints) {
1681
- return __awaiter$2(this, void 0, void 0, function* () {
1681
+ return __awaiter$1(this, void 0, void 0, function* () {
1682
1682
  logger$3.log(`Applying constraints to local track:`, constraints);
1683
1683
  return this.inputTrack.applyConstraints(constraints).then(() => {
1684
1684
  this[LocalStreamEventNames.ConstraintsChange].emit();
@@ -6579,7 +6579,7 @@ class PeerConnection extends EventEmitter$4 {
6579
6579
  * other peer.
6580
6580
  */
6581
6581
  createAnswer(options) {
6582
- return __awaiter$2(this, void 0, void 0, function* () {
6582
+ return __awaiter$1(this, void 0, void 0, function* () {
6583
6583
  return this.pc.createAnswer(options).then((answer) => {
6584
6584
  this.emit(PeerConnection.Events.CreateAnswerOnSuccess, answer);
6585
6585
  return answer;
@@ -6597,7 +6597,7 @@ class PeerConnection extends EventEmitter$4 {
6597
6597
  * That received offer should be delivered through the signaling server to a remote peer.
6598
6598
  */
6599
6599
  createOffer(options) {
6600
- return __awaiter$2(this, void 0, void 0, function* () {
6600
+ return __awaiter$1(this, void 0, void 0, function* () {
6601
6601
  return this.pc.createOffer(options).then((offer) => {
6602
6602
  this.emit(PeerConnection.Events.CreateOfferOnSuccess, offer);
6603
6603
  return offer;
@@ -6613,7 +6613,7 @@ class PeerConnection extends EventEmitter$4 {
6613
6613
  * successfully changed or rejected if the change cannot be applied.
6614
6614
  */
6615
6615
  setLocalDescription(description) {
6616
- return __awaiter$2(this, void 0, void 0, function* () {
6616
+ return __awaiter$1(this, void 0, void 0, function* () {
6617
6617
  var _a;
6618
6618
  // In Firefox, setLocalDescription will not throw an error if an m-line has no codecs, even
6619
6619
  // though it violates https://datatracker.ietf.org/doc/html/rfc8866. See
@@ -6643,7 +6643,7 @@ class PeerConnection extends EventEmitter$4 {
6643
6643
  * specified description is incompatible with one or both of the peers on the connection).
6644
6644
  */
6645
6645
  setRemoteDescription(description) {
6646
- return __awaiter$2(this, void 0, void 0, function* () {
6646
+ return __awaiter$1(this, void 0, void 0, function* () {
6647
6647
  return this.pc.setRemoteDescription(description).then(() => {
6648
6648
  this.emit(PeerConnection.Events.SetRemoteDescriptionOnSuccess, description);
6649
6649
  });
@@ -6718,7 +6718,7 @@ class PeerConnection extends EventEmitter$4 {
6718
6718
  * @returns The connection type which would be `ConnectionType`.
6719
6719
  */
6720
6720
  getCurrentConnectionType() {
6721
- return __awaiter$2(this, void 0, void 0, function* () {
6721
+ return __awaiter$1(this, void 0, void 0, function* () {
6722
6722
  var _a;
6723
6723
  // make sure this method only can be called when the ice connection is established;
6724
6724
  const isIceConnected = this.pc.iceConnectionState === 'connected' || this.pc.iceConnectionState === 'completed';
@@ -8173,7 +8173,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
8173
8173
  PERFORMANCE OF THIS SOFTWARE.
8174
8174
  ***************************************************************************** */
8175
8175
 
8176
- function __awaiter$1(thisArg, _arguments, P, generator) {
8176
+ function __awaiter(thisArg, _arguments, P, generator) {
8177
8177
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8178
8178
  return new (P || (P = Promise))(function (resolve, reject) {
8179
8179
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -8183,53 +8183,15 @@ function __awaiter$1(thisArg, _arguments, P, generator) {
8183
8183
  });
8184
8184
  }
8185
8185
 
8186
- var rtcstats = {};
8187
-
8188
- var __awaiter = (commonjsGlobal$1 && commonjsGlobal$1.__awaiter) || function (thisArg, _arguments, P, generator) {
8189
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8190
- return new (P || (P = Promise))(function (resolve, reject) {
8191
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8192
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8193
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8194
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8195
- });
8196
- };
8197
- var __generator = (commonjsGlobal$1 && commonjsGlobal$1.__generator) || function (thisArg, body) {
8198
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
8199
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
8200
- function verb(n) { return function (v) { return step([n, v]); }; }
8201
- function step(op) {
8202
- if (f) throw new TypeError("Generator is already executing.");
8203
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
8204
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
8205
- if (y = 0, t) op = [op[0] & 2, t.value];
8206
- switch (op[0]) {
8207
- case 0: case 1: t = op; break;
8208
- case 4: _.label++; return { value: op[1], done: false };
8209
- case 5: _.label++; y = op[1]; op = [0]; continue;
8210
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
8211
- default:
8212
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
8213
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
8214
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
8215
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
8216
- if (t[2]) _.ops.pop();
8217
- _.trys.pop(); continue;
8218
- }
8219
- op = body.call(thisArg, _);
8220
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
8221
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
8222
- }
8223
- };
8224
- Object.defineProperty(rtcstats, "__esModule", { value: true });
8225
- var rtcStats_1 = rtcstats.rtcStats = void 0;
8186
+ // @todo WEBEX-425803: fix types issues with inline ts-ignore rules.
8187
+ // @see https://jira-eng-gpk2.cisco.com/jira/browse/WEBEX-425803
8226
8188
  /**
8227
8189
  * Copies values of any nested depth.
8228
8190
  *
8229
8191
  * @param value - The value to be copied.
8230
8192
  * @returns - Copied value.
8231
8193
  */
8232
- var deepCopy$1 = function (value) { return JSON.parse(JSON.stringify(value)); };
8194
+ const deepCopy$1 = (value) => JSON.parse(JSON.stringify(value));
8233
8195
  /**
8234
8196
  * Check deep equality between two values.
8235
8197
  *
@@ -8237,7 +8199,7 @@ var deepCopy$1 = function (value) { return JSON.parse(JSON.stringify(value)); };
8237
8199
  * @param value2 - Second value to check.
8238
8200
  * @returns True if values are deeply equal, false otherwise.
8239
8201
  */
8240
- var deepEqual = function (value1, value2) {
8202
+ const deepEqual = (value1, value2) => {
8241
8203
  // If both immutable values are equal, return true.
8242
8204
  if (value1 === value2) {
8243
8205
  return true;
@@ -8252,8 +8214,10 @@ var deepEqual = function (value1, value2) {
8252
8214
  }
8253
8215
  // Deep equal check each property in the object, returns true if we found no
8254
8216
  // differing properties.
8255
- return Object.keys(value1).reduce(function (val, prop) {
8217
+ return Object.keys(value1).reduce((val, prop) => {
8218
+ // @ts-ignore
8256
8219
  if (value2[prop]) {
8220
+ // @ts-ignore
8257
8221
  if (!deepEqual(value1[prop], value2[prop])) {
8258
8222
  return false;
8259
8223
  }
@@ -8273,38 +8237,36 @@ var deepEqual = function (value1, value2) {
8273
8237
  * @param report - The report in Map form.
8274
8238
  * @returns - A deduped object.
8275
8239
  */
8276
- var map2obj = function (report) {
8240
+ const map2obj = (report) => {
8277
8241
  if (!report.size) {
8278
8242
  return report;
8279
8243
  }
8280
- var o = {};
8281
- report.forEach(function (value, key) {
8244
+ const o = {};
8245
+ report.forEach((value, key) => {
8246
+ // @ts-ignore
8282
8247
  o[key] = value;
8283
8248
  });
8284
8249
  return o;
8285
8250
  };
8286
- var dumpStream = function (stream) { return ({
8251
+ const dumpStream = (stream) => ({
8287
8252
  id: stream.id,
8288
- tracks: stream.getTracks().map(function (track) { return ({
8253
+ tracks: stream.getTracks().map((track) => ({
8289
8254
  id: track.id,
8290
8255
  kind: track.kind,
8291
8256
  label: track.label,
8292
8257
  enabled: track.enabled,
8293
8258
  muted: track.muted,
8294
8259
  readyState: track.readyState,
8295
- }); }),
8296
- }); };
8297
- var persistedKeys = ['type', 'id', 'timestamp'];
8260
+ })),
8261
+ });
8262
+ const persistedKeys = ['type', 'id', 'timestamp'];
8298
8263
  /**
8299
8264
  * Check to see if the report consists of more than just the persisted metadata.
8300
8265
  *
8301
8266
  * @param report - The report line being checked.
8302
8267
  * @returns True if the report item contains non-persisted keys, false otherwise.
8303
8268
  */
8304
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8305
- var hasNonMetadata = function (report) {
8306
- return !!Object.keys(report).filter(function (key) { return !persistedKeys.includes(key); }).length;
8307
- };
8269
+ const hasNonMetadata = (report) => !!Object.keys(report).filter((key) => !persistedKeys.includes(key)).length;
8308
8270
  /**
8309
8271
  * Apply a delta compression to the stats report. Reduces size by ~90%.
8310
8272
  * To reduce further, report keys could be compressed.
@@ -8313,35 +8275,42 @@ var hasNonMetadata = function (report) {
8313
8275
  * @param newStats - New incoming stats.
8314
8276
  * @returns - Compressed Stats.
8315
8277
  */
8316
- var deltaCompression = function (oldStats, newStats) {
8317
- var updatedStats = deepCopy$1(newStats);
8318
- Object.keys(updatedStats).forEach(function (id) {
8319
- var report = updatedStats[id];
8278
+ const deltaCompression = (oldStats, newStats) => {
8279
+ const updatedStats = deepCopy$1(newStats);
8280
+ Object.keys(updatedStats).forEach((id) => {
8281
+ // @ts-ignore
8282
+ const report = updatedStats[id];
8283
+ // @ts-ignore
8320
8284
  if (!oldStats[id]) {
8321
8285
  return;
8322
8286
  }
8323
8287
  // Persist specific values beyond delta compression, as long as they
8324
8288
  // aren't the only non-deduped keys.
8325
- Object.keys(report).forEach(function (name) {
8289
+ Object.keys(report).forEach((name) => {
8290
+ // @ts-ignore
8326
8291
  if (deepEqual(report[name], oldStats[id][name]) && !persistedKeys.includes(name)) {
8292
+ // @ts-ignore
8327
8293
  delete updatedStats[id][name];
8328
8294
  }
8329
8295
  if (!hasNonMetadata(report)) {
8296
+ // @ts-ignore
8330
8297
  delete updatedStats[id];
8331
8298
  }
8332
8299
  });
8333
8300
  });
8334
8301
  // Use the most recent timestamp.
8335
- var timestamp = -Infinity;
8336
- Object.keys(updatedStats).forEach(function (id) {
8337
- var report = updatedStats[id];
8302
+ let timestamp = -Infinity;
8303
+ Object.keys(updatedStats).forEach((id) => {
8304
+ // @ts-ignore
8305
+ const report = updatedStats[id];
8338
8306
  if (report.timestamp > timestamp) {
8339
8307
  timestamp = report.timestamp;
8340
8308
  }
8341
8309
  });
8342
8310
  // Delete the timestamps on each item.
8343
- Object.keys(updatedStats).forEach(function (id) {
8344
- var report = updatedStats[id];
8311
+ Object.keys(updatedStats).forEach((id) => {
8312
+ // @ts-ignore
8313
+ const report = updatedStats[id];
8345
8314
  if (report.timestamp === timestamp) {
8346
8315
  delete report.timestamp;
8347
8316
  }
@@ -8355,10 +8324,11 @@ var deltaCompression = function (oldStats, newStats) {
8355
8324
  * @param report - A WebRTC stats report.
8356
8325
  * @returns - An array of Stats Report items.
8357
8326
  */
8358
- var formatStatsReport = function (report) {
8359
- return Object.keys(report)
8360
- .filter(function (name) { return name !== 'timestamp'; })
8361
- .map(function (name) { return JSON.stringify(report[name]); });
8327
+ const formatStatsReport = (report) => {
8328
+ return (Object.keys(report)
8329
+ .filter((name) => name !== 'timestamp')
8330
+ // @ts-ignore
8331
+ .map((name) => JSON.stringify(report[name])));
8362
8332
  };
8363
8333
  /**
8364
8334
  * Parametrize a single string event to contain type and an (empty) id.
@@ -8366,7 +8336,7 @@ var formatStatsReport = function (report) {
8366
8336
  * @param value - The value to parametrize.
8367
8337
  * @returns An event object.
8368
8338
  */
8369
- var makeEvent = function (value) { return [JSON.stringify({ value: value, type: 'string', id: '' })]; };
8339
+ const makeEvent = (value) => [JSON.stringify({ value, type: 'string', id: '' })];
8370
8340
  /**
8371
8341
  * Attach a Peer Connection to periodically get updated on events and stats.
8372
8342
  *
@@ -8375,9 +8345,10 @@ var makeEvent = function (value) { return [JSON.stringify({ value: value, type:
8375
8345
  * @param intervalTime - Time between each `getStats` check.
8376
8346
  * @param statsPreProcessor - Optional function that modifies stats.
8377
8347
  */
8378
- var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8379
- if (statsPreProcessor === void 0) { statsPreProcessor = function () { return Promise.resolve(); }; }
8380
- var prev = {};
8348
+ const rtcStats = (pc, logger, intervalTime,
8349
+ // eslint-disable-next-line no-unused-vars
8350
+ statsPreProcessor = () => Promise.resolve()) => {
8351
+ let prev = {};
8381
8352
  /**
8382
8353
  * Log stats or event data with additional tracking information.
8383
8354
  *
@@ -8385,131 +8356,143 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8385
8356
  * @param payload - Log data pertaining to the event.
8386
8357
  * @param timestamp - Time the event happened in milliseconds.
8387
8358
  */
8388
- var trace = function (name, payload, timestamp) {
8389
- logger({ timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
8359
+ const trace = (name, payload, timestamp) => {
8360
+ logger({ timestamp: timestamp ? Math.round(timestamp) : Date.now(), name, payload });
8390
8361
  };
8391
8362
  trace('rtcConfiguration', makeEvent(JSON.stringify(pc.getConfiguration())));
8392
- var origPeerConnection = window.RTCPeerConnection;
8393
- pc.addEventListener('icecandidate', function (e) {
8363
+ const origPeerConnection = window.RTCPeerConnection;
8364
+ pc.addEventListener('icecandidate', (e) => {
8394
8365
  if (e.candidate) {
8395
8366
  trace('onicecandidate', makeEvent(JSON.stringify(e.candidate)));
8396
8367
  }
8397
8368
  });
8398
- pc.addEventListener('icecandidateerror', function (event) {
8399
- var url = event.url, errorCode = event.errorCode, errorText = event.errorText;
8400
- trace('onicecandidateerror', makeEvent("[".concat(url, "] ").concat(errorCode, ": ").concat(errorText)));
8369
+ pc.addEventListener('icecandidateerror', (event) => {
8370
+ const { url, errorCode, errorText } = event;
8371
+ trace('onicecandidateerror', makeEvent(`[${url}] ${errorCode}: ${errorText}`));
8401
8372
  });
8402
- pc.addEventListener('track', function (e) {
8403
- trace('ontrack', makeEvent("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams
8404
- .map(function (stream) { return "stream:".concat(stream.id); })
8405
- .join(' '))));
8373
+ pc.addEventListener('track', (e) => {
8374
+ trace('ontrack', makeEvent(`${e.track.kind}:${e.track.id} ${e.streams
8375
+ .map((stream) => `stream:${stream.id}`)
8376
+ .join(' ')}`));
8406
8377
  });
8407
- pc.addEventListener('signalingstatechange', function () {
8378
+ pc.addEventListener('signalingstatechange', () => {
8408
8379
  trace('onsignalingstatechange', makeEvent(pc.signalingState));
8409
8380
  });
8410
- pc.addEventListener('iceconnectionstatechange', function () {
8381
+ pc.addEventListener('iceconnectionstatechange', () => {
8411
8382
  trace('oniceconnectionstatechange', makeEvent(pc.iceConnectionState));
8412
8383
  });
8413
- pc.addEventListener('icegatheringstatechange', function () {
8384
+ pc.addEventListener('icegatheringstatechange', () => {
8414
8385
  trace('onicegatheringstatechange', makeEvent(pc.iceGatheringState));
8415
8386
  });
8416
- pc.addEventListener('connectionstatechange', function () {
8387
+ pc.addEventListener('connectionstatechange', () => {
8417
8388
  trace('onconnectionstatechange', makeEvent(pc.connectionState));
8418
8389
  });
8419
- pc.addEventListener('negotiationneeded', function () {
8390
+ pc.addEventListener('negotiationneeded', () => {
8420
8391
  trace('onnegotiationneeded', makeEvent('negotiationneeded'));
8421
8392
  });
8422
- pc.addEventListener('datachannel', function (event) {
8423
- trace('ondatachannel', makeEvent("".concat(event.channel.id, ": ").concat(event.channel.label)));
8393
+ pc.addEventListener('datachannel', (event) => {
8394
+ trace('ondatachannel', makeEvent(`${event.channel.id}: ${event.channel.label}`));
8424
8395
  });
8425
- ['close'].forEach(function (method) {
8426
- var nativeMethod = origPeerConnection.prototype[method];
8396
+ ['close'].forEach((method) => {
8397
+ // @ts-ignore
8398
+ const nativeMethod = origPeerConnection.prototype[method];
8427
8399
  if (nativeMethod) {
8400
+ // @ts-ignore
8428
8401
  origPeerConnection.prototype[method] = function () {
8429
- trace("on".concat(method), makeEvent(method));
8402
+ trace(`on${method}`, makeEvent(method));
8430
8403
  return nativeMethod.apply(this, arguments);
8431
8404
  };
8432
8405
  }
8433
8406
  });
8434
- ['createDataChannel'].forEach(function (method) {
8435
- var nativeMethod = origPeerConnection.prototype[method];
8407
+ ['createDataChannel'].forEach((method) => {
8408
+ // @ts-ignore
8409
+ const nativeMethod = origPeerConnection.prototype[method];
8436
8410
  if (nativeMethod) {
8411
+ // @ts-ignore
8437
8412
  origPeerConnection.prototype[method] = function () {
8438
- trace("on".concat(method), makeEvent(method));
8439
- var dataChannel = nativeMethod.apply(this, arguments);
8440
- dataChannel.addEventListener('open', function () {
8441
- trace("ondataChannelOpen", makeEvent("".concat(dataChannel.id, ":").concat(dataChannel.label)));
8413
+ trace(`on${method}`, makeEvent(method));
8414
+ const dataChannel = nativeMethod.apply(this, arguments);
8415
+ dataChannel.addEventListener('open', () => {
8416
+ trace(`ondataChannelOpen`, makeEvent(`${dataChannel.id}:${dataChannel.label}`));
8442
8417
  });
8443
- dataChannel.addEventListener('close', function () {
8444
- trace("ondataChannelClose", makeEvent("".concat(dataChannel.id, ":").concat(dataChannel.label)));
8418
+ dataChannel.addEventListener('close', () => {
8419
+ trace(`ondataChannelClose`, makeEvent(`${dataChannel.id}:${dataChannel.label}`));
8445
8420
  });
8446
- dataChannel.addEventListener('error', function (event) {
8447
- var error = event.error;
8448
- trace("ondataChannelError", makeEvent("".concat(dataChannel.id, ":").concat(dataChannel.label, ": ").concat(error.errorDetail)));
8421
+ dataChannel.addEventListener('error', (event) => {
8422
+ const { error } = event;
8423
+ trace(`ondataChannelError`, makeEvent(`${dataChannel.id}:${dataChannel.label}: ${error.errorDetail}`));
8449
8424
  });
8450
8425
  return dataChannel;
8451
8426
  };
8452
8427
  }
8453
8428
  });
8454
- ['addStream', 'removeStream'].forEach(function (method) {
8455
- var nativeMethod = origPeerConnection.prototype[method];
8429
+ ['addStream', 'removeStream'].forEach((method) => {
8430
+ // @ts-ignore
8431
+ const nativeMethod = origPeerConnection.prototype[method];
8456
8432
  if (nativeMethod) {
8433
+ // @ts-ignore
8457
8434
  origPeerConnection.prototype[method] = function () {
8458
- var stream = arguments[0];
8459
- var streamInfo = stream
8435
+ const stream = arguments[0];
8436
+ const streamInfo = stream
8460
8437
  .getTracks()
8461
- .map(function (t) { return "".concat(t.kind, ":").concat(t.id); })
8438
+ .map((t) => `${t.kind}:${t.id}`)
8462
8439
  .join(',');
8463
- trace("on".concat(method), makeEvent("".concat(stream.id, " ").concat(streamInfo)));
8440
+ trace(`on${method}`, makeEvent(`${stream.id} ${streamInfo}`));
8464
8441
  return nativeMethod.apply(this, arguments);
8465
8442
  };
8466
8443
  }
8467
8444
  });
8468
- ['addTrack'].forEach(function (method) {
8469
- var nativeMethod = origPeerConnection.prototype[method];
8445
+ ['addTrack'].forEach((method) => {
8446
+ // @ts-ignore
8447
+ const nativeMethod = origPeerConnection.prototype[method];
8470
8448
  if (nativeMethod) {
8449
+ // @ts-ignore
8471
8450
  origPeerConnection.prototype[method] = function () {
8472
- var track = arguments[0];
8473
- var streams = [].slice.call(arguments, 1);
8474
- trace("on".concat(method), makeEvent("".concat(track.kind, ":").concat(track.id, " ").concat(streams.map(function (s) { return "stream:".concat(s.id); }).join(';') || '-')));
8451
+ const track = arguments[0];
8452
+ const streams = [].slice.call(arguments, 1);
8453
+ trace(`on${method}`, makeEvent(`${track.kind}:${track.id} ${streams.map((s) => `stream:${s.id}`).join(';') || '-'}`));
8475
8454
  return nativeMethod.apply(this, arguments);
8476
8455
  };
8477
8456
  }
8478
8457
  });
8479
- ['removeTrack'].forEach(function (method) {
8480
- var nativeMethod = origPeerConnection.prototype[method];
8458
+ ['removeTrack'].forEach((method) => {
8459
+ // @ts-ignore
8460
+ const nativeMethod = origPeerConnection.prototype[method];
8481
8461
  if (nativeMethod) {
8462
+ // @ts-ignore
8482
8463
  origPeerConnection.prototype[method] = function () {
8483
- var track = arguments[0].track;
8484
- trace("on".concat(method), makeEvent(track ? "".concat(track.kind, ":").concat(track.id) : 'null'));
8464
+ const track = arguments[0].track;
8465
+ trace(`on${method}`, makeEvent(track ? `${track.kind}:${track.id}` : 'null'));
8485
8466
  return nativeMethod.apply(this, arguments);
8486
8467
  };
8487
8468
  }
8488
8469
  });
8489
- ['createOffer', 'createAnswer'].forEach(function (method) {
8490
- var nativeMethod = origPeerConnection.prototype[method];
8470
+ ['createOffer', 'createAnswer'].forEach((method) => {
8471
+ // @ts-ignore
8472
+ const nativeMethod = origPeerConnection.prototype[method];
8491
8473
  if (nativeMethod) {
8474
+ // @ts-ignore
8492
8475
  origPeerConnection.prototype[method] = function () {
8493
- var opts;
8494
- var args = arguments;
8476
+ let opts;
8477
+ const args = arguments;
8495
8478
  if (arguments.length === 1 && typeof arguments[0] === 'object') {
8496
- // eslint-disable-next-line prefer-destructuring
8497
8479
  opts = arguments[0];
8498
8480
  }
8499
8481
  else if (arguments.length === 3 && typeof arguments[2] === 'object') {
8500
- // eslint-disable-next-line prefer-destructuring
8501
8482
  opts = arguments[2];
8502
8483
  }
8503
- trace("on".concat(method), makeEvent(opts || ''));
8504
- return nativeMethod.apply(this, opts ? [opts] : undefined).then(function (description) {
8505
- trace("on".concat(method, "OnSuccess"), makeEvent(description.sdp));
8484
+ trace(`on${method}`, makeEvent(opts || ''));
8485
+ return nativeMethod.apply(this, opts ? [opts] : undefined).then(
8486
+ // @ts-ignore
8487
+ (description) => {
8488
+ trace(`on${method}OnSuccess`, makeEvent(description.sdp));
8506
8489
  if (args.length > 0 && typeof args[0] === 'function') {
8507
8490
  args[0].apply(null, [description]);
8508
8491
  return undefined;
8509
8492
  }
8510
8493
  return description;
8511
- }, function (err) {
8512
- trace("on".concat(method, "OnFailure"), makeEvent(err.toString()));
8494
+ }, (err) => {
8495
+ trace(`on${method}OnFailure`, makeEvent(err.toString()));
8513
8496
  if (args.length > 1 && typeof args[1] === 'function') {
8514
8497
  args[1].apply(null, [err]);
8515
8498
  return;
@@ -8519,64 +8502,66 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8519
8502
  };
8520
8503
  }
8521
8504
  });
8522
- ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
8523
- var nativeMethod = origPeerConnection.prototype[method];
8505
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach((method) => {
8506
+ // @ts-ignore
8507
+ const nativeMethod = origPeerConnection.prototype[method];
8524
8508
  if (nativeMethod) {
8509
+ // @ts-ignore
8525
8510
  origPeerConnection.prototype[method] = function () {
8526
- var _this = this;
8527
- var args = arguments;
8528
- trace("on".concat(method), makeEvent(method === 'addIceCandidate'
8511
+ const args = arguments;
8512
+ trace(`on${method}`, makeEvent(method === 'addIceCandidate'
8529
8513
  ? arguments[0]
8530
- : (arguments[0] ? arguments[0].sdp : 'undefined')));
8531
- return nativeMethod.apply(this, [arguments[0]]).then(function () {
8514
+ : arguments[0]
8515
+ ? arguments[0].sdp
8516
+ : 'undefined'));
8517
+ return nativeMethod.apply(this, [arguments[0]]).then(() => {
8532
8518
  var _a;
8533
- trace("on".concat(method, "OnSuccess"), makeEvent('success'));
8519
+ trace(`on${method}OnSuccess`, makeEvent('success'));
8534
8520
  if (method.endsWith('Description')) {
8535
- if (!_this.transportEventsPreviouslyAdded) {
8536
- var senders = _this.getSenders();
8537
- var _loop_1 = function (sender) {
8521
+ // @ts-ignore
8522
+ if (!this.transportEventsPreviouslyAdded) {
8523
+ const senders = this.getSenders();
8524
+ for (const sender of senders) {
8538
8525
  if (sender.transport) {
8539
- sender.transport.addEventListener('statechange', function () {
8526
+ sender.transport.addEventListener('statechange', () => {
8540
8527
  if (sender && sender.transport) {
8541
- trace("ondtlsStateChange", makeEvent(sender.transport.state));
8528
+ trace(`ondtlsStateChange`, makeEvent(sender.transport.state));
8542
8529
  }
8543
8530
  });
8544
- sender.transport.addEventListener('error', function (error) {
8545
- var errorEvent = error;
8546
- trace("ondtlsError", makeEvent(errorEvent.error.errorDetail));
8531
+ sender.transport.addEventListener('error', (error) => {
8532
+ const errorEvent = error;
8533
+ trace(`ondtlsError`, makeEvent(errorEvent.error.errorDetail));
8547
8534
  });
8548
8535
  if (sender.transport.iceTransport) {
8549
- sender.transport.iceTransport.addEventListener('selectedcandidatepairchange', function () {
8536
+ sender.transport.iceTransport.addEventListener('selectedcandidatepairchange', () => {
8550
8537
  var _a, _b, _c, _d, _e, _f;
8551
8538
  if (sender.transport && sender.transport.iceTransport) {
8552
- var pair = sender.transport.iceTransport.getSelectedCandidatePair();
8553
- var localCandidate = "".concat((_a = pair === null || pair === void 0 ? void 0 : pair.local) === null || _a === void 0 ? void 0 : _a.address, ":").concat((_b = pair === null || pair === void 0 ? void 0 : pair.local) === null || _b === void 0 ? void 0 : _b.port, "/").concat((_c = pair === null || pair === void 0 ? void 0 : pair.local) === null || _c === void 0 ? void 0 : _c.protocol);
8554
- var remoteCandidate = "".concat((_d = pair === null || pair === void 0 ? void 0 : pair.remote) === null || _d === void 0 ? void 0 : _d.address, ":").concat((_e = pair === null || pair === void 0 ? void 0 : pair.remote) === null || _e === void 0 ? void 0 : _e.port, "/").concat((_f = pair === null || pair === void 0 ? void 0 : pair.remote) === null || _f === void 0 ? void 0 : _f.protocol);
8555
- var pairString = "local: ".concat(localCandidate, ", remote: ").concat(remoteCandidate);
8539
+ const pair = sender.transport.iceTransport.getSelectedCandidatePair();
8540
+ const localCandidate = `${(_a = pair === null || pair === void 0 ? void 0 : pair.local) === null || _a === void 0 ? void 0 : _a.address}:${(_b = pair === null || pair === void 0 ? void 0 : pair.local) === null || _b === void 0 ? void 0 : _b.port}/${(_c = pair === null || pair === void 0 ? void 0 : pair.local) === null || _c === void 0 ? void 0 : _c.protocol}`;
8541
+ const remoteCandidate = `${(_d = pair === null || pair === void 0 ? void 0 : pair.remote) === null || _d === void 0 ? void 0 : _d.address}:${(_e = pair === null || pair === void 0 ? void 0 : pair.remote) === null || _e === void 0 ? void 0 : _e.port}/${(_f = pair === null || pair === void 0 ? void 0 : pair.remote) === null || _f === void 0 ? void 0 : _f.protocol}`;
8542
+ const pairString = `local: ${localCandidate}, remote: ${remoteCandidate}`;
8556
8543
  trace('onselectedCandidatePairChange', makeEvent(pairString));
8557
8544
  }
8558
8545
  });
8559
8546
  }
8560
- _this.transportEventsPreviouslyAdded = true;
8547
+ // @ts-ignore
8548
+ this.transportEventsPreviouslyAdded = true;
8561
8549
  if (pc.getConfiguration().bundlePolicy === 'max-bundle') {
8562
- return "break";
8550
+ break;
8563
8551
  }
8564
8552
  }
8565
- };
8566
- for (var _i = 0, senders_1 = senders; _i < senders_1.length; _i++) {
8567
- var sender = senders_1[_i];
8568
- var state_1 = _loop_1(sender);
8569
- if (state_1 === "break")
8570
- break;
8571
8553
  }
8572
8554
  }
8573
- if (!_this.sctpEventsPreviouslyAdded) {
8555
+ // @ts-ignore
8556
+ if (!this.sctpEventsPreviouslyAdded) {
8574
8557
  // Some Firefox versions prior to 113 have sctp defined but not the events, so check both here.
8575
- if ((_a = _this.sctp) === null || _a === void 0 ? void 0 : _a.addEventListener) {
8576
- _this.sctp.addEventListener('statechange', function () {
8577
- trace('onsctpStateChange', makeEvent(_this.sctp.state));
8558
+ if ((_a = this.sctp) === null || _a === void 0 ? void 0 : _a.addEventListener) {
8559
+ this.sctp.addEventListener('statechange', () => {
8560
+ // @ts-ignore
8561
+ trace('onsctpStateChange', makeEvent(this.sctp.state));
8578
8562
  });
8579
- _this.sctpEventsPreviouslyAdded = true;
8563
+ // @ts-ignore
8564
+ this.sctpEventsPreviouslyAdded = true;
8580
8565
  }
8581
8566
  }
8582
8567
  }
@@ -8585,8 +8570,8 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8585
8570
  return undefined;
8586
8571
  }
8587
8572
  return undefined;
8588
- }, function (err) {
8589
- trace("on".concat(method, "OnFailure"), makeEvent(err.toString()));
8573
+ }, (err) => {
8574
+ trace(`on${method}OnFailure`, makeEvent(err.toString()));
8590
8575
  if (args.length >= 3 && typeof args[2] === 'function') {
8591
8576
  args[2].apply(null, [err]);
8592
8577
  return undefined;
@@ -8597,15 +8582,15 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8597
8582
  }
8598
8583
  });
8599
8584
  if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
8600
- var origGetUserMedia_1 = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
8601
- var gum = function () {
8585
+ const origGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
8586
+ const gum = function () {
8602
8587
  trace('onnavigator.mediaDevices.getUserMedia', makeEvent(JSON.stringify(arguments[0])));
8603
- return origGetUserMedia_1
8588
+ return origGetUserMedia
8604
8589
  .apply(navigator.mediaDevices, arguments)
8605
- .then(function (stream) {
8590
+ .then((stream) => {
8606
8591
  trace('onnavigator.mediaDevices.getUserMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
8607
8592
  return stream;
8608
- }, function (err) {
8593
+ }, (err) => {
8609
8594
  trace('onnavigator.mediaDevices.getUserMediaOnFailure', makeEvent(err.name));
8610
8595
  return Promise.reject(err);
8611
8596
  });
@@ -8613,53 +8598,46 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8613
8598
  navigator.mediaDevices.getUserMedia = gum.bind(navigator.mediaDevices);
8614
8599
  }
8615
8600
  if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
8616
- var origGetDisplayMedia_1 = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
8617
- var gdm = function () {
8601
+ const origGetDisplayMedia = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
8602
+ const gdm = function () {
8618
8603
  trace('onnavigator.mediaDevices.getDisplayMedia', makeEvent(JSON.stringify(arguments[0])));
8619
- return origGetDisplayMedia_1
8604
+ return origGetDisplayMedia
8620
8605
  .apply(navigator.mediaDevices, arguments)
8621
- .then(function (stream) {
8606
+ .then((stream) => {
8622
8607
  trace('onnavigator.mediaDevices.getDisplayMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
8623
8608
  return stream;
8624
- }, function (err) {
8609
+ }, (err) => {
8625
8610
  trace('onnavigator.mediaDevices.getDisplayMediaOnFailure', makeEvent(err.name));
8626
8611
  return Promise.reject(err);
8627
8612
  });
8628
8613
  };
8629
8614
  navigator.mediaDevices.getDisplayMedia = gdm.bind(navigator.mediaDevices);
8630
8615
  }
8631
- var getStatsReport = function () { return __awaiter(void 0, void 0, void 0, function () {
8632
- return __generator(this, function (_a) {
8633
- return [2 /*return*/, pc.getStats(null).then(function (res) {
8634
- // Convert from stats report to js Map in order to have values set in `statsPreProcessor`
8635
- var statsMap = new Map();
8636
- res.forEach(function (stats, key) { return statsMap.set(key, stats); });
8637
- return statsPreProcessor(statsMap).then(function () {
8638
- var now = map2obj(statsMap);
8639
- var base = deepCopy$1(now); // our new prev
8640
- var compressed = deltaCompression(prev, now);
8641
- trace('stats-report', formatStatsReport(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
8642
- prev = base;
8643
- return Promise.resolve();
8644
- });
8645
- })];
8616
+ const getStatsReport = async () => pc.getStats(null).then((res) => {
8617
+ // Convert from stats report to js Map in order to have values set in `statsPreProcessor`
8618
+ const statsMap = new Map();
8619
+ res.forEach((stats, key) => statsMap.set(key, stats));
8620
+ return statsPreProcessor(statsMap).then(() => {
8621
+ const now = map2obj(statsMap);
8622
+ const base = deepCopy$1(now); // our new prev
8623
+ const compressed = deltaCompression(prev, now);
8624
+ trace('stats-report', formatStatsReport(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
8625
+ prev = base;
8626
+ return Promise.resolve();
8646
8627
  });
8647
- }); };
8648
- var interval = window.setInterval(function () {
8628
+ });
8629
+ const interval = window.setInterval(() => {
8649
8630
  if (pc.signalingState === 'closed') {
8650
8631
  window.clearInterval(interval);
8651
8632
  return;
8652
8633
  }
8653
8634
  getStatsReport();
8654
8635
  }, intervalTime);
8655
- var forceStatsReport = function () { return __awaiter(void 0, void 0, void 0, function () {
8656
- return __generator(this, function (_a) {
8657
- return [2 /*return*/, getStatsReport()];
8658
- });
8659
- }); };
8660
- return { forceStatsReport: forceStatsReport };
8636
+ const forceStatsReport = async () => {
8637
+ return getStatsReport();
8638
+ };
8639
+ return { forceStatsReport };
8661
8640
  };
8662
- rtcStats_1 = rtcstats.rtcStats = rtcStats;
8663
8641
 
8664
8642
  const NUM = '\\d+';
8665
8643
  const SDP_TOKEN = "[!#$%&'*+\\-.^_`{|}~a-zA-Z0-9]+";
@@ -11207,12 +11185,12 @@ function getCurrentTimestamp() {
11207
11185
  return performance.timeOrigin + performance.now();
11208
11186
  }
11209
11187
  class StatsManager {
11210
- constructor(statsGetter, statsPreprocessor = () => __awaiter$1(this, void 0, void 0, function* () { })) {
11188
+ constructor(statsGetter, statsPreprocessor = () => __awaiter(this, void 0, void 0, function* () { })) {
11211
11189
  this.statsGetter = statsGetter;
11212
11190
  this.statsPreProcessor = statsPreprocessor;
11213
11191
  }
11214
11192
  getStats() {
11215
- return __awaiter$1(this, void 0, void 0, function* () {
11193
+ return __awaiter(this, void 0, void 0, function* () {
11216
11194
  const statsReport = yield this.statsGetter();
11217
11195
  const statsMap = new Map();
11218
11196
  statsReport.forEach((stats, key) => statsMap.set(key, stats));
@@ -11278,7 +11256,7 @@ class ReceiveOnlyTransceiver extends Transceiver {
11278
11256
  return this._receiveSlot;
11279
11257
  }
11280
11258
  getStats() {
11281
- return __awaiter$1(this, void 0, void 0, function* () {
11259
+ return __awaiter(this, void 0, void 0, function* () {
11282
11260
  const statsMap = new Map();
11283
11261
  const statsReport = yield this.receiver.getStats();
11284
11262
  statsReport.forEach((stats, key) => {
@@ -15028,7 +15006,7 @@ function waterfall (tasks, callback) {
15028
15006
  awaitify(waterfall);
15029
15007
 
15030
15008
  function processTasks(task, finishedCallback) {
15031
- return __awaiter$1(this, void 0, void 0, function* () {
15009
+ return __awaiter(this, void 0, void 0, function* () {
15032
15010
  try {
15033
15011
  yield task();
15034
15012
  finishedCallback();
@@ -15088,7 +15066,7 @@ class SendOnlyTransceiver extends Transceiver {
15088
15066
  }
15089
15067
  replaceSenderSource(stream) {
15090
15068
  var _a, _b;
15091
- return __awaiter$1(this, void 0, void 0, function* () {
15069
+ return __awaiter(this, void 0, void 0, function* () {
15092
15070
  const trackOrNull = (_a = stream === null || stream === void 0 ? void 0 : stream.outputStream.getTracks()[0]) !== null && _a !== void 0 ? _a : null;
15093
15071
  if (((_b = this.sender.track) === null || _b === void 0 ? void 0 : _b.id) !== (trackOrNull === null || trackOrNull === void 0 ? void 0 : trackOrNull.id)) {
15094
15072
  yield this.sender.replaceTrack(trackOrNull);
@@ -15102,14 +15080,14 @@ class SendOnlyTransceiver extends Transceiver {
15102
15080
  });
15103
15081
  }
15104
15082
  handleTrackChange() {
15105
- return __awaiter$1(this, void 0, void 0, function* () {
15083
+ return __awaiter(this, void 0, void 0, function* () {
15106
15084
  if (this.requested) {
15107
15085
  yield this.replaceSenderSource(this.publishedStream);
15108
15086
  }
15109
15087
  });
15110
15088
  }
15111
15089
  handleStreamConstraintsChange() {
15112
- return __awaiter$1(this, void 0, void 0, function* () {
15090
+ return __awaiter(this, void 0, void 0, function* () {
15113
15091
  yield this.updateSendParameters(this.requestedIdEncodingParamsMap);
15114
15092
  });
15115
15093
  }
@@ -15126,7 +15104,7 @@ class SendOnlyTransceiver extends Transceiver {
15126
15104
  const _super = Object.create(null, {
15127
15105
  replaceTransceiver: { get: () => super.replaceTransceiver }
15128
15106
  });
15129
- return __awaiter$1(this, void 0, void 0, function* () {
15107
+ return __awaiter(this, void 0, void 0, function* () {
15130
15108
  _super.replaceTransceiver.call(this, newRtcRtpTransceiver);
15131
15109
  newRtcRtpTransceiver.direction = this.direction;
15132
15110
  if (this.requested) {
@@ -15135,7 +15113,7 @@ class SendOnlyTransceiver extends Transceiver {
15135
15113
  });
15136
15114
  }
15137
15115
  replacePublishedStream(newStream) {
15138
- return __awaiter$1(this, void 0, void 0, function* () {
15116
+ return __awaiter(this, void 0, void 0, function* () {
15139
15117
  const oldStream = this.publishedStream;
15140
15118
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(LocalStreamEventNames.OutputTrackChange, this.handleTrackChange);
15141
15119
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
@@ -15188,7 +15166,7 @@ class SendOnlyTransceiver extends Transceiver {
15188
15166
  }
15189
15167
  }
15190
15168
  getStats() {
15191
- return __awaiter$1(this, void 0, void 0, function* () {
15169
+ return __awaiter(this, void 0, void 0, function* () {
15192
15170
  const statsMap = new Map();
15193
15171
  const statsReport = yield this.sender.getStats();
15194
15172
  statsReport.forEach((stats, key) => {
@@ -15243,8 +15221,8 @@ class SendOnlyTransceiver extends Transceiver {
15243
15221
  });
15244
15222
  }
15245
15223
  updateSendParameters(requestedIdEncodingParamsMap) {
15246
- return __awaiter$1(this, void 0, void 0, function* () {
15247
- return this.updateSendParametersQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
15224
+ return __awaiter(this, void 0, void 0, function* () {
15225
+ return this.updateSendParametersQueue.push(() => __awaiter(this, void 0, void 0, function* () {
15248
15226
  const sendParameters = this.sender.getParameters();
15249
15227
  sendParameters.encodings.forEach((encoding, index) => {
15250
15228
  var _a, _b;
@@ -15358,7 +15336,7 @@ class SendSlot {
15358
15336
  this.sendTransceiver = sendTransceiver;
15359
15337
  }
15360
15338
  publishStream(stream) {
15361
- return __awaiter$1(this, void 0, void 0, function* () {
15339
+ return __awaiter(this, void 0, void 0, function* () {
15362
15340
  if (stream === this.sendTransceiver.publishedStream) {
15363
15341
  return Promise.resolve();
15364
15342
  }
@@ -15366,7 +15344,7 @@ class SendSlot {
15366
15344
  });
15367
15345
  }
15368
15346
  unpublishStream() {
15369
- return __awaiter$1(this, void 0, void 0, function* () {
15347
+ return __awaiter(this, void 0, void 0, function* () {
15370
15348
  if (!this.sendTransceiver.publishedStream) {
15371
15349
  return Promise.resolve();
15372
15350
  }
@@ -15386,12 +15364,12 @@ class SendSlot {
15386
15364
  this.sendTransceiver.active = active;
15387
15365
  }
15388
15366
  setCodecParameters(parameters) {
15389
- return __awaiter$1(this, void 0, void 0, function* () {
15367
+ return __awaiter(this, void 0, void 0, function* () {
15390
15368
  this.sendTransceiver.setCodecParameters(parameters);
15391
15369
  });
15392
15370
  }
15393
15371
  deleteCodecParameters(parameters) {
15394
- return __awaiter$1(this, void 0, void 0, function* () {
15372
+ return __awaiter(this, void 0, void 0, function* () {
15395
15373
  this.sendTransceiver.deleteCodecParameters(parameters);
15396
15374
  });
15397
15375
  }
@@ -15403,7 +15381,7 @@ class SendSlot {
15403
15381
  }
15404
15382
  }
15405
15383
 
15406
- const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnectionStats) => __awaiter$1(void 0, void 0, void 0, function* () {
15384
+ const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnectionStats) => __awaiter(void 0, void 0, void 0, function* () {
15407
15385
  const result = {
15408
15386
  audio: {
15409
15387
  senders: [],
@@ -15422,7 +15400,7 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnec
15422
15400
  receivers: [],
15423
15401
  },
15424
15402
  };
15425
- yield Promise.all([...sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter$1(void 0, void 0, void 0, function* () {
15403
+ yield Promise.all([...sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter(void 0, void 0, void 0, function* () {
15426
15404
  var _a;
15427
15405
  const item = {
15428
15406
  report: yield transceiver.getStats(),
@@ -15447,8 +15425,8 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnec
15447
15425
  result.screenShareVideo.senders.push(item);
15448
15426
  }
15449
15427
  })));
15450
- yield Promise.all([...recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter$1(void 0, void 0, void 0, function* () {
15451
- return Promise.all(transceivers.map((t) => __awaiter$1(void 0, void 0, void 0, function* () {
15428
+ yield Promise.all([...recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter(void 0, void 0, void 0, function* () {
15429
+ return Promise.all(transceivers.map((t) => __awaiter(void 0, void 0, void 0, function* () {
15452
15430
  var _b;
15453
15431
  const item = {
15454
15432
  report: yield t.getStats(),
@@ -15965,14 +15943,14 @@ SCTP Max Message Size: ${maxMessageSize}`);
15965
15943
  return recvOnlyTransceiver;
15966
15944
  }
15967
15945
  createReceiveSlot(mediaType) {
15968
- return __awaiter$1(this, void 0, void 0, function* () {
15946
+ return __awaiter(this, void 0, void 0, function* () {
15969
15947
  return (yield this.createReceiveSlots(mediaType, 1))[0];
15970
15948
  });
15971
15949
  }
15972
15950
  createReceiveSlots(mediaType, count = 1) {
15973
- return __awaiter$1(this, void 0, void 0, function* () {
15951
+ return __awaiter(this, void 0, void 0, function* () {
15974
15952
  return new Promise((createReceiveSlotsResolve) => {
15975
- this.offerAnswerQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
15953
+ this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
15976
15954
  const createdReceiveOnlyTransceivers = [];
15977
15955
  for (let i = 0; i < count; i++) {
15978
15956
  const recvOnlyTransceiver = this.createReceiveTransceiver(mediaType);
@@ -16019,7 +15997,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16019
15997
  return targetCodec.pt;
16020
15998
  }
16021
15999
  waitForIceGatheringComplete() {
16022
- return __awaiter$1(this, void 0, void 0, function* () {
16000
+ return __awaiter(this, void 0, void 0, function* () {
16023
16001
  return new Promise((resolve, reject) => {
16024
16002
  const finalizeIceCandidatesGathering = () => this.pc.getIceCandidates().length > 0
16025
16003
  ? resolve()
@@ -16045,7 +16023,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16045
16023
  });
16046
16024
  }
16047
16025
  createOffer() {
16048
- return __awaiter$1(this, void 0, void 0, function* () {
16026
+ return __awaiter(this, void 0, void 0, function* () {
16049
16027
  if (!this.pc.getLocalDescription()) {
16050
16028
  this.midPredictor.allocateMidForDatachannel();
16051
16029
  }
@@ -16056,7 +16034,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16056
16034
  }
16057
16035
  const createOfferId = ++this.currentCreateOfferId;
16058
16036
  return new Promise((createOfferResolve, createOfferReject) => {
16059
- this.offerAnswerQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
16037
+ this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
16060
16038
  var _a;
16061
16039
  try {
16062
16040
  const offer = yield this.pc.createOffer();
@@ -16066,7 +16044,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16066
16044
  offer.sdp = this.preProcessLocalOffer(offer.sdp);
16067
16045
  yield this.pc
16068
16046
  .setLocalDescription(offer)
16069
- .then(() => __awaiter$1(this, void 0, void 0, function* () {
16047
+ .then(() => __awaiter(this, void 0, void 0, function* () {
16070
16048
  logger.info('this.pc.setLocalDescription() resolved');
16071
16049
  }))
16072
16050
  .catch((error) => {
@@ -16100,7 +16078,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16100
16078
  });
16101
16079
  }
16102
16080
  setAnswer(answer) {
16103
- return __awaiter$1(this, void 0, void 0, function* () {
16081
+ return __awaiter(this, void 0, void 0, function* () {
16104
16082
  const sdp = this.preProcessRemoteAnswer(answer);
16105
16083
  if (!this.setAnswerResolve) {
16106
16084
  logErrorAndThrow(WcmeErrorType.SET_ANSWER_FAILED, `Call to setAnswer without having previously called createOffer.`);
@@ -16108,7 +16086,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16108
16086
  logger.info('calling this.pc.setRemoteDescription()');
16109
16087
  return this.pc
16110
16088
  .setRemoteDescription({ type: 'answer', sdp })
16111
- .then(() => __awaiter$1(this, void 0, void 0, function* () {
16089
+ .then(() => __awaiter(this, void 0, void 0, function* () {
16112
16090
  logger.info('this.pc.setRemoteDescription() resolved');
16113
16091
  if (this.setAnswerResolve) {
16114
16092
  this.setAnswerResolve();
@@ -16125,7 +16103,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16125
16103
  }
16126
16104
  doLocalOfferAnswer() {
16127
16105
  var _a;
16128
- return __awaiter$1(this, void 0, void 0, function* () {
16106
+ return __awaiter(this, void 0, void 0, function* () {
16129
16107
  const offer = yield this.pc.createOffer();
16130
16108
  if (!offer.sdp) {
16131
16109
  logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
@@ -16133,7 +16111,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16133
16111
  offer.sdp = this.preProcessLocalOffer(offer.sdp);
16134
16112
  yield this.pc
16135
16113
  .setLocalDescription(offer)
16136
- .then(() => __awaiter$1(this, void 0, void 0, function* () {
16114
+ .then(() => __awaiter(this, void 0, void 0, function* () {
16137
16115
  logger.info('this.pc.setLocalDescription() resolved');
16138
16116
  }))
16139
16117
  .catch((error) => {
@@ -16143,7 +16121,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16143
16121
  const answer = this.preProcessRemoteAnswer((_a = this.pc.getRemoteDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
16144
16122
  return this.pc
16145
16123
  .setRemoteDescription({ type: 'answer', sdp: answer })
16146
- .then(() => __awaiter$1(this, void 0, void 0, function* () {
16124
+ .then(() => __awaiter(this, void 0, void 0, function* () {
16147
16125
  logger.info('this.pc.setRemoteDescription() resolved');
16148
16126
  }))
16149
16127
  .catch((error) => {
@@ -16152,8 +16130,8 @@ SCTP Max Message Size: ${maxMessageSize}`);
16152
16130
  });
16153
16131
  }
16154
16132
  queueLocalOfferAnswer() {
16155
- return __awaiter$1(this, void 0, void 0, function* () {
16156
- return this.offerAnswerQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
16133
+ return __awaiter(this, void 0, void 0, function* () {
16134
+ return this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
16157
16135
  yield this.doLocalOfferAnswer();
16158
16136
  }));
16159
16137
  });
@@ -16326,7 +16304,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16326
16304
  }
16327
16305
  renewPeerConnection(userOptions) {
16328
16306
  var _a;
16329
- return __awaiter$1(this, void 0, void 0, function* () {
16307
+ return __awaiter(this, void 0, void 0, function* () {
16330
16308
  (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
16331
16309
  try {
16332
16310
  if (userOptions) {
@@ -16383,28 +16361,28 @@ SCTP Max Message Size: ${maxMessageSize}`);
16383
16361
  return this.statsManager.getStats();
16384
16362
  }
16385
16363
  getTransceiverStats() {
16386
- return __awaiter$1(this, void 0, void 0, function* () {
16364
+ return __awaiter(this, void 0, void 0, function* () {
16387
16365
  const stats = yield this.getStats();
16388
16366
  const peerConnectionStats = [...stats.values()].find((stat) => stat.type === 'peer-connection');
16389
16367
  return organizeTransceiverStats(this.sendTransceivers, this.recvTransceivers, peerConnectionStats);
16390
16368
  });
16391
16369
  }
16392
16370
  preProcessStats(stats) {
16393
- return __awaiter$1(this, void 0, void 0, function* () {
16371
+ return __awaiter(this, void 0, void 0, function* () {
16394
16372
  stats.forEach((stat) => {
16395
16373
  if (stat.type === 'peer-connection') {
16396
16374
  stat.isMediaBypassEdge = this.metadata.isMediaBypassEdge;
16397
16375
  }
16398
16376
  });
16399
- yield Promise.all([...this.sendTransceivers.values()].map((transceiver) => __awaiter$1(this, void 0, void 0, function* () {
16377
+ yield Promise.all([...this.sendTransceivers.values()].map((transceiver) => __awaiter(this, void 0, void 0, function* () {
16400
16378
  (yield transceiver.getStats()).forEach((senderStats) => {
16401
16379
  if (senderStats.type === 'outbound-rtp' || senderStats.type === 'media-source') {
16402
16380
  stats.set(senderStats.id, senderStats);
16403
16381
  }
16404
16382
  });
16405
16383
  })));
16406
- yield Promise.all([...this.recvTransceivers.values()].map((transceivers) => __awaiter$1(this, void 0, void 0, function* () {
16407
- yield Promise.all(transceivers.map((transceiver) => __awaiter$1(this, void 0, void 0, function* () {
16384
+ yield Promise.all([...this.recvTransceivers.values()].map((transceivers) => __awaiter(this, void 0, void 0, function* () {
16385
+ yield Promise.all(transceivers.map((transceiver) => __awaiter(this, void 0, void 0, function* () {
16408
16386
  (yield transceiver.getStats()).forEach((receiverStats) => {
16409
16387
  if (receiverStats.type === 'inbound-rtp') {
16410
16388
  stats.set(receiverStats.id, receiverStats);
@@ -16415,7 +16393,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16415
16393
  });
16416
16394
  }
16417
16395
  attachMetricsObserver() {
16418
- this.forceStatsReport = rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000, (stats) => this.preProcessStats(stats)).forceStatsReport;
16396
+ this.forceStatsReport = rtcStats(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000, (stats) => this.preProcessStats(stats)).forceStatsReport;
16419
16397
  }
16420
16398
  forceRtcMetricsCallback() {
16421
16399
  var _a;