@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/cjs/index.js CHANGED
@@ -34,7 +34,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34
34
  PERFORMANCE OF THIS SOFTWARE.
35
35
  ***************************************************************************** */
36
36
 
37
- function __awaiter$2(thisArg, _arguments, P, generator) {
37
+ function __awaiter$1(thisArg, _arguments, P, generator) {
38
38
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
39
39
  return new (P || (P = Promise))(function (resolve, reject) {
40
40
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -356,7 +356,7 @@ var DeviceKind$1;
356
356
  * media has successfully been obtained.
357
357
  */
358
358
  function getUserMedia(constraints) {
359
- return __awaiter$2(this, void 0, void 0, function* () {
359
+ return __awaiter$1(this, void 0, void 0, function* () {
360
360
  return navigator.mediaDevices.getUserMedia(constraints);
361
361
  });
362
362
  }
@@ -381,7 +381,7 @@ function getDisplayMedia(constraints) {
381
381
  * fulfilled.
382
382
  */
383
383
  function enumerateDevices() {
384
- return __awaiter$2(this, void 0, void 0, function* () {
384
+ return __awaiter$1(this, void 0, void 0, function* () {
385
385
  return navigator.mediaDevices.enumerateDevices();
386
386
  });
387
387
  }
@@ -403,7 +403,7 @@ function setOnDeviceChangeHandler$1(handler) {
403
403
  * @returns Array of Permission Status objects.
404
404
  */
405
405
  function checkNavigatorPermissions(deviceKinds) {
406
- return __awaiter$2(this, void 0, void 0, function* () {
406
+ return __awaiter$1(this, void 0, void 0, function* () {
407
407
  const permissionRequests = [];
408
408
  if (deviceKinds.includes(DeviceKind$1.VideoInput)) {
409
409
  permissionRequests.push(navigator.permissions.query({ name: 'camera' }));
@@ -421,7 +421,7 @@ function checkNavigatorPermissions(deviceKinds) {
421
421
  * @returns True if device permissions exist, false if otherwise.
422
422
  */
423
423
  function checkDevicePermissions(deviceKinds) {
424
- return __awaiter$2(this, void 0, void 0, function* () {
424
+ return __awaiter$1(this, void 0, void 0, function* () {
425
425
  try {
426
426
  const permissions = yield checkNavigatorPermissions(deviceKinds);
427
427
  if (permissions.every((permission) => permission.state === 'granted')) {
@@ -451,7 +451,7 @@ function checkDevicePermissions(deviceKinds) {
451
451
  * @returns The callback's response.
452
452
  */
453
453
  function ensureDevicePermissions(deviceKinds, callback) {
454
- return __awaiter$2(this, void 0, void 0, function* () {
454
+ return __awaiter$1(this, void 0, void 0, function* () {
455
455
  try {
456
456
  const hasDevicePermissions = yield checkDevicePermissions(deviceKinds);
457
457
  if (!hasDevicePermissions) {
@@ -520,7 +520,7 @@ class WebrtcCoreError {
520
520
  * @returns A LocalCameraStream object or an error.
521
521
  */
522
522
  function createCameraStream(cameraStreamConstructor, constraints) {
523
- return __awaiter$2(this, void 0, void 0, function* () {
523
+ return __awaiter$1(this, void 0, void 0, function* () {
524
524
  let stream;
525
525
  try {
526
526
  stream = yield getUserMedia({ video: Object.assign({}, constraints) });
@@ -540,7 +540,7 @@ function createCameraStream(cameraStreamConstructor, constraints) {
540
540
  * @returns A LocalMicrophoneStream object or an error.
541
541
  */
542
542
  function createMicrophoneStream(microphoneStreamConstructor, constraints) {
543
- return __awaiter$2(this, void 0, void 0, function* () {
543
+ return __awaiter$1(this, void 0, void 0, function* () {
544
544
  let stream;
545
545
  try {
546
546
  stream = yield getUserMedia({ audio: Object.assign({}, constraints) });
@@ -563,7 +563,7 @@ function createMicrophoneStream(microphoneStreamConstructor, constraints) {
563
563
  * @returns A Promise that resolves to a LocalCameraStream and a LocalMicrophoneStream or an error.
564
564
  */
565
565
  function createCameraAndMicrophoneStreams(cameraStreamConstructor, microphoneStreamConstructor, constraints) {
566
- return __awaiter$2(this, void 0, void 0, function* () {
566
+ return __awaiter$1(this, void 0, void 0, function* () {
567
567
  let stream;
568
568
  try {
569
569
  stream = yield getUserMedia({
@@ -608,7 +608,7 @@ function createCameraAndMicrophoneStreams(cameraStreamConstructor, microphoneStr
608
608
  * instead.
609
609
  */
610
610
  function createDisplayMedia(options) {
611
- return __awaiter$2(this, void 0, void 0, function* () {
611
+ return __awaiter$1(this, void 0, void 0, function* () {
612
612
  var _a, _b;
613
613
  let stream;
614
614
  const videoConstraints = options.video.constraints || true;
@@ -649,7 +649,7 @@ function createDisplayMedia(options) {
649
649
  * @returns A Promise that resolves to a LocalDisplayStream or an error.
650
650
  */
651
651
  function createDisplayStream(displayStreamConstructor, videoContentHint) {
652
- return __awaiter$2(this, void 0, void 0, function* () {
652
+ return __awaiter$1(this, void 0, void 0, function* () {
653
653
  const [localDisplayStream] = yield createDisplayMedia({
654
654
  video: { displayStreamConstructor, videoContentHint },
655
655
  });
@@ -667,7 +667,7 @@ function createDisplayStream(displayStreamConstructor, videoContentHint) {
667
667
  * instead.
668
668
  */
669
669
  function createDisplayStreamWithAudio(displayStreamConstructor, systemAudioStreamConstructor, videoContentHint) {
670
- return __awaiter$2(this, void 0, void 0, function* () {
670
+ return __awaiter$1(this, void 0, void 0, function* () {
671
671
  return createDisplayMedia({
672
672
  video: { displayStreamConstructor, videoContentHint },
673
673
  audio: { systemAudioStreamConstructor },
@@ -681,7 +681,7 @@ function createDisplayStreamWithAudio(displayStreamConstructor, systemAudioStrea
681
681
  * @returns List of media devices in an array of MediaDeviceInfo objects.
682
682
  */
683
683
  function getDevices(deviceKind) {
684
- return __awaiter$2(this, void 0, void 0, function* () {
684
+ return __awaiter$1(this, void 0, void 0, function* () {
685
685
  let devices;
686
686
  const deviceKinds = deviceKind
687
687
  ? [deviceKind]
@@ -701,7 +701,7 @@ function getDevices(deviceKind) {
701
701
  * @returns List of microphone devices in an array of MediaDeviceInfo objects.
702
702
  */
703
703
  function getAudioInputDevices() {
704
- return __awaiter$2(this, void 0, void 0, function* () {
704
+ return __awaiter$1(this, void 0, void 0, function* () {
705
705
  return getDevices(DeviceKind$1.AudioInput);
706
706
  });
707
707
  }
@@ -711,7 +711,7 @@ function getAudioInputDevices() {
711
711
  * @returns List of speaker devices in an array of MediaDeviceInfo objects.
712
712
  */
713
713
  function getAudioOutputDevices() {
714
- return __awaiter$2(this, void 0, void 0, function* () {
714
+ return __awaiter$1(this, void 0, void 0, function* () {
715
715
  return getDevices(DeviceKind$1.AudioOutput);
716
716
  });
717
717
  }
@@ -721,7 +721,7 @@ function getAudioOutputDevices() {
721
721
  * @returns List of camera devices in an array of MediaDeviceInfo objects.
722
722
  */
723
723
  function getVideoInputDevices() {
724
- return __awaiter$2(this, void 0, void 0, function* () {
724
+ return __awaiter$1(this, void 0, void 0, function* () {
725
725
  return getDevices(DeviceKind$1.VideoInput);
726
726
  });
727
727
  }
@@ -1500,7 +1500,7 @@ class _LocalStream extends Stream {
1500
1500
  * @param effect - The effect to add.
1501
1501
  */
1502
1502
  addEffect(effect) {
1503
- return __awaiter$2(this, void 0, void 0, function* () {
1503
+ return __awaiter$1(this, void 0, void 0, function* () {
1504
1504
  // Check if the effect has already been added.
1505
1505
  if (this.effects.some((e) => e.id === effect.id)) {
1506
1506
  return;
@@ -1637,7 +1637,7 @@ class _LocalStream extends Stream {
1637
1637
  * Cleanup the local effects.
1638
1638
  */
1639
1639
  disposeEffects() {
1640
- return __awaiter$2(this, void 0, void 0, function* () {
1640
+ return __awaiter$1(this, void 0, void 0, function* () {
1641
1641
  this.loadingEffects.clear();
1642
1642
  // Dispose of any effects currently in use
1643
1643
  if (this.effects.length > 0) {
@@ -1662,7 +1662,7 @@ class LocalAudioStream extends LocalStream {
1662
1662
  * @returns A promise which resolves when the constraints have been successfully applied.
1663
1663
  */
1664
1664
  applyConstraints(constraints) {
1665
- return __awaiter$2(this, void 0, void 0, function* () {
1665
+ return __awaiter$1(this, void 0, void 0, function* () {
1666
1666
  logger$3.log(`Applying constraints to local track:`, constraints);
1667
1667
  return this.inputTrack.applyConstraints(constraints).then(() => {
1668
1668
  this[exports.LocalStreamEventNames.ConstraintsChange].emit();
@@ -1682,7 +1682,7 @@ class LocalVideoStream extends LocalStream {
1682
1682
  * @returns A promise which resolves when the constraints have been successfully applied.
1683
1683
  */
1684
1684
  applyConstraints(constraints) {
1685
- return __awaiter$2(this, void 0, void 0, function* () {
1685
+ return __awaiter$1(this, void 0, void 0, function* () {
1686
1686
  logger$3.log(`Applying constraints to local track:`, constraints);
1687
1687
  return this.inputTrack.applyConstraints(constraints).then(() => {
1688
1688
  this[exports.LocalStreamEventNames.ConstraintsChange].emit();
@@ -6583,7 +6583,7 @@ class PeerConnection extends EventEmitter$4 {
6583
6583
  * other peer.
6584
6584
  */
6585
6585
  createAnswer(options) {
6586
- return __awaiter$2(this, void 0, void 0, function* () {
6586
+ return __awaiter$1(this, void 0, void 0, function* () {
6587
6587
  return this.pc.createAnswer(options).then((answer) => {
6588
6588
  this.emit(PeerConnection.Events.CreateAnswerOnSuccess, answer);
6589
6589
  return answer;
@@ -6601,7 +6601,7 @@ class PeerConnection extends EventEmitter$4 {
6601
6601
  * That received offer should be delivered through the signaling server to a remote peer.
6602
6602
  */
6603
6603
  createOffer(options) {
6604
- return __awaiter$2(this, void 0, void 0, function* () {
6604
+ return __awaiter$1(this, void 0, void 0, function* () {
6605
6605
  return this.pc.createOffer(options).then((offer) => {
6606
6606
  this.emit(PeerConnection.Events.CreateOfferOnSuccess, offer);
6607
6607
  return offer;
@@ -6617,7 +6617,7 @@ class PeerConnection extends EventEmitter$4 {
6617
6617
  * successfully changed or rejected if the change cannot be applied.
6618
6618
  */
6619
6619
  setLocalDescription(description) {
6620
- return __awaiter$2(this, void 0, void 0, function* () {
6620
+ return __awaiter$1(this, void 0, void 0, function* () {
6621
6621
  var _a;
6622
6622
  // In Firefox, setLocalDescription will not throw an error if an m-line has no codecs, even
6623
6623
  // though it violates https://datatracker.ietf.org/doc/html/rfc8866. See
@@ -6647,7 +6647,7 @@ class PeerConnection extends EventEmitter$4 {
6647
6647
  * specified description is incompatible with one or both of the peers on the connection).
6648
6648
  */
6649
6649
  setRemoteDescription(description) {
6650
- return __awaiter$2(this, void 0, void 0, function* () {
6650
+ return __awaiter$1(this, void 0, void 0, function* () {
6651
6651
  return this.pc.setRemoteDescription(description).then(() => {
6652
6652
  this.emit(PeerConnection.Events.SetRemoteDescriptionOnSuccess, description);
6653
6653
  });
@@ -6722,7 +6722,7 @@ class PeerConnection extends EventEmitter$4 {
6722
6722
  * @returns The connection type which would be `ConnectionType`.
6723
6723
  */
6724
6724
  getCurrentConnectionType() {
6725
- return __awaiter$2(this, void 0, void 0, function* () {
6725
+ return __awaiter$1(this, void 0, void 0, function* () {
6726
6726
  var _a;
6727
6727
  // make sure this method only can be called when the ice connection is established;
6728
6728
  const isIceConnected = this.pc.iceConnectionState === 'connected' || this.pc.iceConnectionState === 'completed';
@@ -8177,7 +8177,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
8177
8177
  PERFORMANCE OF THIS SOFTWARE.
8178
8178
  ***************************************************************************** */
8179
8179
 
8180
- function __awaiter$1(thisArg, _arguments, P, generator) {
8180
+ function __awaiter(thisArg, _arguments, P, generator) {
8181
8181
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8182
8182
  return new (P || (P = Promise))(function (resolve, reject) {
8183
8183
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -8187,53 +8187,15 @@ function __awaiter$1(thisArg, _arguments, P, generator) {
8187
8187
  });
8188
8188
  }
8189
8189
 
8190
- var rtcstats = {};
8191
-
8192
- var __awaiter = (commonjsGlobal$1 && commonjsGlobal$1.__awaiter) || function (thisArg, _arguments, P, generator) {
8193
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8194
- return new (P || (P = Promise))(function (resolve, reject) {
8195
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8196
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8197
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8198
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8199
- });
8200
- };
8201
- var __generator = (commonjsGlobal$1 && commonjsGlobal$1.__generator) || function (thisArg, body) {
8202
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
8203
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
8204
- function verb(n) { return function (v) { return step([n, v]); }; }
8205
- function step(op) {
8206
- if (f) throw new TypeError("Generator is already executing.");
8207
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
8208
- 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;
8209
- if (y = 0, t) op = [op[0] & 2, t.value];
8210
- switch (op[0]) {
8211
- case 0: case 1: t = op; break;
8212
- case 4: _.label++; return { value: op[1], done: false };
8213
- case 5: _.label++; y = op[1]; op = [0]; continue;
8214
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
8215
- default:
8216
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
8217
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
8218
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
8219
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
8220
- if (t[2]) _.ops.pop();
8221
- _.trys.pop(); continue;
8222
- }
8223
- op = body.call(thisArg, _);
8224
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
8225
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
8226
- }
8227
- };
8228
- Object.defineProperty(rtcstats, "__esModule", { value: true });
8229
- var rtcStats_1 = rtcstats.rtcStats = void 0;
8190
+ // @todo WEBEX-425803: fix types issues with inline ts-ignore rules.
8191
+ // @see https://jira-eng-gpk2.cisco.com/jira/browse/WEBEX-425803
8230
8192
  /**
8231
8193
  * Copies values of any nested depth.
8232
8194
  *
8233
8195
  * @param value - The value to be copied.
8234
8196
  * @returns - Copied value.
8235
8197
  */
8236
- var deepCopy$1 = function (value) { return JSON.parse(JSON.stringify(value)); };
8198
+ const deepCopy$1 = (value) => JSON.parse(JSON.stringify(value));
8237
8199
  /**
8238
8200
  * Check deep equality between two values.
8239
8201
  *
@@ -8241,7 +8203,7 @@ var deepCopy$1 = function (value) { return JSON.parse(JSON.stringify(value)); };
8241
8203
  * @param value2 - Second value to check.
8242
8204
  * @returns True if values are deeply equal, false otherwise.
8243
8205
  */
8244
- var deepEqual = function (value1, value2) {
8206
+ const deepEqual = (value1, value2) => {
8245
8207
  // If both immutable values are equal, return true.
8246
8208
  if (value1 === value2) {
8247
8209
  return true;
@@ -8256,8 +8218,10 @@ var deepEqual = function (value1, value2) {
8256
8218
  }
8257
8219
  // Deep equal check each property in the object, returns true if we found no
8258
8220
  // differing properties.
8259
- return Object.keys(value1).reduce(function (val, prop) {
8221
+ return Object.keys(value1).reduce((val, prop) => {
8222
+ // @ts-ignore
8260
8223
  if (value2[prop]) {
8224
+ // @ts-ignore
8261
8225
  if (!deepEqual(value1[prop], value2[prop])) {
8262
8226
  return false;
8263
8227
  }
@@ -8277,38 +8241,36 @@ var deepEqual = function (value1, value2) {
8277
8241
  * @param report - The report in Map form.
8278
8242
  * @returns - A deduped object.
8279
8243
  */
8280
- var map2obj = function (report) {
8244
+ const map2obj = (report) => {
8281
8245
  if (!report.size) {
8282
8246
  return report;
8283
8247
  }
8284
- var o = {};
8285
- report.forEach(function (value, key) {
8248
+ const o = {};
8249
+ report.forEach((value, key) => {
8250
+ // @ts-ignore
8286
8251
  o[key] = value;
8287
8252
  });
8288
8253
  return o;
8289
8254
  };
8290
- var dumpStream = function (stream) { return ({
8255
+ const dumpStream = (stream) => ({
8291
8256
  id: stream.id,
8292
- tracks: stream.getTracks().map(function (track) { return ({
8257
+ tracks: stream.getTracks().map((track) => ({
8293
8258
  id: track.id,
8294
8259
  kind: track.kind,
8295
8260
  label: track.label,
8296
8261
  enabled: track.enabled,
8297
8262
  muted: track.muted,
8298
8263
  readyState: track.readyState,
8299
- }); }),
8300
- }); };
8301
- var persistedKeys = ['type', 'id', 'timestamp'];
8264
+ })),
8265
+ });
8266
+ const persistedKeys = ['type', 'id', 'timestamp'];
8302
8267
  /**
8303
8268
  * Check to see if the report consists of more than just the persisted metadata.
8304
8269
  *
8305
8270
  * @param report - The report line being checked.
8306
8271
  * @returns True if the report item contains non-persisted keys, false otherwise.
8307
8272
  */
8308
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8309
- var hasNonMetadata = function (report) {
8310
- return !!Object.keys(report).filter(function (key) { return !persistedKeys.includes(key); }).length;
8311
- };
8273
+ const hasNonMetadata = (report) => !!Object.keys(report).filter((key) => !persistedKeys.includes(key)).length;
8312
8274
  /**
8313
8275
  * Apply a delta compression to the stats report. Reduces size by ~90%.
8314
8276
  * To reduce further, report keys could be compressed.
@@ -8317,35 +8279,42 @@ var hasNonMetadata = function (report) {
8317
8279
  * @param newStats - New incoming stats.
8318
8280
  * @returns - Compressed Stats.
8319
8281
  */
8320
- var deltaCompression = function (oldStats, newStats) {
8321
- var updatedStats = deepCopy$1(newStats);
8322
- Object.keys(updatedStats).forEach(function (id) {
8323
- var report = updatedStats[id];
8282
+ const deltaCompression = (oldStats, newStats) => {
8283
+ const updatedStats = deepCopy$1(newStats);
8284
+ Object.keys(updatedStats).forEach((id) => {
8285
+ // @ts-ignore
8286
+ const report = updatedStats[id];
8287
+ // @ts-ignore
8324
8288
  if (!oldStats[id]) {
8325
8289
  return;
8326
8290
  }
8327
8291
  // Persist specific values beyond delta compression, as long as they
8328
8292
  // aren't the only non-deduped keys.
8329
- Object.keys(report).forEach(function (name) {
8293
+ Object.keys(report).forEach((name) => {
8294
+ // @ts-ignore
8330
8295
  if (deepEqual(report[name], oldStats[id][name]) && !persistedKeys.includes(name)) {
8296
+ // @ts-ignore
8331
8297
  delete updatedStats[id][name];
8332
8298
  }
8333
8299
  if (!hasNonMetadata(report)) {
8300
+ // @ts-ignore
8334
8301
  delete updatedStats[id];
8335
8302
  }
8336
8303
  });
8337
8304
  });
8338
8305
  // Use the most recent timestamp.
8339
- var timestamp = -Infinity;
8340
- Object.keys(updatedStats).forEach(function (id) {
8341
- var report = updatedStats[id];
8306
+ let timestamp = -Infinity;
8307
+ Object.keys(updatedStats).forEach((id) => {
8308
+ // @ts-ignore
8309
+ const report = updatedStats[id];
8342
8310
  if (report.timestamp > timestamp) {
8343
8311
  timestamp = report.timestamp;
8344
8312
  }
8345
8313
  });
8346
8314
  // Delete the timestamps on each item.
8347
- Object.keys(updatedStats).forEach(function (id) {
8348
- var report = updatedStats[id];
8315
+ Object.keys(updatedStats).forEach((id) => {
8316
+ // @ts-ignore
8317
+ const report = updatedStats[id];
8349
8318
  if (report.timestamp === timestamp) {
8350
8319
  delete report.timestamp;
8351
8320
  }
@@ -8359,10 +8328,11 @@ var deltaCompression = function (oldStats, newStats) {
8359
8328
  * @param report - A WebRTC stats report.
8360
8329
  * @returns - An array of Stats Report items.
8361
8330
  */
8362
- var formatStatsReport = function (report) {
8363
- return Object.keys(report)
8364
- .filter(function (name) { return name !== 'timestamp'; })
8365
- .map(function (name) { return JSON.stringify(report[name]); });
8331
+ const formatStatsReport = (report) => {
8332
+ return (Object.keys(report)
8333
+ .filter((name) => name !== 'timestamp')
8334
+ // @ts-ignore
8335
+ .map((name) => JSON.stringify(report[name])));
8366
8336
  };
8367
8337
  /**
8368
8338
  * Parametrize a single string event to contain type and an (empty) id.
@@ -8370,7 +8340,7 @@ var formatStatsReport = function (report) {
8370
8340
  * @param value - The value to parametrize.
8371
8341
  * @returns An event object.
8372
8342
  */
8373
- var makeEvent = function (value) { return [JSON.stringify({ value: value, type: 'string', id: '' })]; };
8343
+ const makeEvent = (value) => [JSON.stringify({ value, type: 'string', id: '' })];
8374
8344
  /**
8375
8345
  * Attach a Peer Connection to periodically get updated on events and stats.
8376
8346
  *
@@ -8379,9 +8349,10 @@ var makeEvent = function (value) { return [JSON.stringify({ value: value, type:
8379
8349
  * @param intervalTime - Time between each `getStats` check.
8380
8350
  * @param statsPreProcessor - Optional function that modifies stats.
8381
8351
  */
8382
- var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8383
- if (statsPreProcessor === void 0) { statsPreProcessor = function () { return Promise.resolve(); }; }
8384
- var prev = {};
8352
+ const rtcStats = (pc, logger, intervalTime,
8353
+ // eslint-disable-next-line no-unused-vars
8354
+ statsPreProcessor = () => Promise.resolve()) => {
8355
+ let prev = {};
8385
8356
  /**
8386
8357
  * Log stats or event data with additional tracking information.
8387
8358
  *
@@ -8389,131 +8360,143 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8389
8360
  * @param payload - Log data pertaining to the event.
8390
8361
  * @param timestamp - Time the event happened in milliseconds.
8391
8362
  */
8392
- var trace = function (name, payload, timestamp) {
8393
- logger({ timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
8363
+ const trace = (name, payload, timestamp) => {
8364
+ logger({ timestamp: timestamp ? Math.round(timestamp) : Date.now(), name, payload });
8394
8365
  };
8395
8366
  trace('rtcConfiguration', makeEvent(JSON.stringify(pc.getConfiguration())));
8396
- var origPeerConnection = window.RTCPeerConnection;
8397
- pc.addEventListener('icecandidate', function (e) {
8367
+ const origPeerConnection = window.RTCPeerConnection;
8368
+ pc.addEventListener('icecandidate', (e) => {
8398
8369
  if (e.candidate) {
8399
8370
  trace('onicecandidate', makeEvent(JSON.stringify(e.candidate)));
8400
8371
  }
8401
8372
  });
8402
- pc.addEventListener('icecandidateerror', function (event) {
8403
- var url = event.url, errorCode = event.errorCode, errorText = event.errorText;
8404
- trace('onicecandidateerror', makeEvent("[".concat(url, "] ").concat(errorCode, ": ").concat(errorText)));
8373
+ pc.addEventListener('icecandidateerror', (event) => {
8374
+ const { url, errorCode, errorText } = event;
8375
+ trace('onicecandidateerror', makeEvent(`[${url}] ${errorCode}: ${errorText}`));
8405
8376
  });
8406
- pc.addEventListener('track', function (e) {
8407
- trace('ontrack', makeEvent("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams
8408
- .map(function (stream) { return "stream:".concat(stream.id); })
8409
- .join(' '))));
8377
+ pc.addEventListener('track', (e) => {
8378
+ trace('ontrack', makeEvent(`${e.track.kind}:${e.track.id} ${e.streams
8379
+ .map((stream) => `stream:${stream.id}`)
8380
+ .join(' ')}`));
8410
8381
  });
8411
- pc.addEventListener('signalingstatechange', function () {
8382
+ pc.addEventListener('signalingstatechange', () => {
8412
8383
  trace('onsignalingstatechange', makeEvent(pc.signalingState));
8413
8384
  });
8414
- pc.addEventListener('iceconnectionstatechange', function () {
8385
+ pc.addEventListener('iceconnectionstatechange', () => {
8415
8386
  trace('oniceconnectionstatechange', makeEvent(pc.iceConnectionState));
8416
8387
  });
8417
- pc.addEventListener('icegatheringstatechange', function () {
8388
+ pc.addEventListener('icegatheringstatechange', () => {
8418
8389
  trace('onicegatheringstatechange', makeEvent(pc.iceGatheringState));
8419
8390
  });
8420
- pc.addEventListener('connectionstatechange', function () {
8391
+ pc.addEventListener('connectionstatechange', () => {
8421
8392
  trace('onconnectionstatechange', makeEvent(pc.connectionState));
8422
8393
  });
8423
- pc.addEventListener('negotiationneeded', function () {
8394
+ pc.addEventListener('negotiationneeded', () => {
8424
8395
  trace('onnegotiationneeded', makeEvent('negotiationneeded'));
8425
8396
  });
8426
- pc.addEventListener('datachannel', function (event) {
8427
- trace('ondatachannel', makeEvent("".concat(event.channel.id, ": ").concat(event.channel.label)));
8397
+ pc.addEventListener('datachannel', (event) => {
8398
+ trace('ondatachannel', makeEvent(`${event.channel.id}: ${event.channel.label}`));
8428
8399
  });
8429
- ['close'].forEach(function (method) {
8430
- var nativeMethod = origPeerConnection.prototype[method];
8400
+ ['close'].forEach((method) => {
8401
+ // @ts-ignore
8402
+ const nativeMethod = origPeerConnection.prototype[method];
8431
8403
  if (nativeMethod) {
8404
+ // @ts-ignore
8432
8405
  origPeerConnection.prototype[method] = function () {
8433
- trace("on".concat(method), makeEvent(method));
8406
+ trace(`on${method}`, makeEvent(method));
8434
8407
  return nativeMethod.apply(this, arguments);
8435
8408
  };
8436
8409
  }
8437
8410
  });
8438
- ['createDataChannel'].forEach(function (method) {
8439
- var nativeMethod = origPeerConnection.prototype[method];
8411
+ ['createDataChannel'].forEach((method) => {
8412
+ // @ts-ignore
8413
+ const nativeMethod = origPeerConnection.prototype[method];
8440
8414
  if (nativeMethod) {
8415
+ // @ts-ignore
8441
8416
  origPeerConnection.prototype[method] = function () {
8442
- trace("on".concat(method), makeEvent(method));
8443
- var dataChannel = nativeMethod.apply(this, arguments);
8444
- dataChannel.addEventListener('open', function () {
8445
- trace("ondataChannelOpen", makeEvent("".concat(dataChannel.id, ":").concat(dataChannel.label)));
8417
+ trace(`on${method}`, makeEvent(method));
8418
+ const dataChannel = nativeMethod.apply(this, arguments);
8419
+ dataChannel.addEventListener('open', () => {
8420
+ trace(`ondataChannelOpen`, makeEvent(`${dataChannel.id}:${dataChannel.label}`));
8446
8421
  });
8447
- dataChannel.addEventListener('close', function () {
8448
- trace("ondataChannelClose", makeEvent("".concat(dataChannel.id, ":").concat(dataChannel.label)));
8422
+ dataChannel.addEventListener('close', () => {
8423
+ trace(`ondataChannelClose`, makeEvent(`${dataChannel.id}:${dataChannel.label}`));
8449
8424
  });
8450
- dataChannel.addEventListener('error', function (event) {
8451
- var error = event.error;
8452
- trace("ondataChannelError", makeEvent("".concat(dataChannel.id, ":").concat(dataChannel.label, ": ").concat(error.errorDetail)));
8425
+ dataChannel.addEventListener('error', (event) => {
8426
+ const { error } = event;
8427
+ trace(`ondataChannelError`, makeEvent(`${dataChannel.id}:${dataChannel.label}: ${error.errorDetail}`));
8453
8428
  });
8454
8429
  return dataChannel;
8455
8430
  };
8456
8431
  }
8457
8432
  });
8458
- ['addStream', 'removeStream'].forEach(function (method) {
8459
- var nativeMethod = origPeerConnection.prototype[method];
8433
+ ['addStream', 'removeStream'].forEach((method) => {
8434
+ // @ts-ignore
8435
+ const nativeMethod = origPeerConnection.prototype[method];
8460
8436
  if (nativeMethod) {
8437
+ // @ts-ignore
8461
8438
  origPeerConnection.prototype[method] = function () {
8462
- var stream = arguments[0];
8463
- var streamInfo = stream
8439
+ const stream = arguments[0];
8440
+ const streamInfo = stream
8464
8441
  .getTracks()
8465
- .map(function (t) { return "".concat(t.kind, ":").concat(t.id); })
8442
+ .map((t) => `${t.kind}:${t.id}`)
8466
8443
  .join(',');
8467
- trace("on".concat(method), makeEvent("".concat(stream.id, " ").concat(streamInfo)));
8444
+ trace(`on${method}`, makeEvent(`${stream.id} ${streamInfo}`));
8468
8445
  return nativeMethod.apply(this, arguments);
8469
8446
  };
8470
8447
  }
8471
8448
  });
8472
- ['addTrack'].forEach(function (method) {
8473
- var nativeMethod = origPeerConnection.prototype[method];
8449
+ ['addTrack'].forEach((method) => {
8450
+ // @ts-ignore
8451
+ const nativeMethod = origPeerConnection.prototype[method];
8474
8452
  if (nativeMethod) {
8453
+ // @ts-ignore
8475
8454
  origPeerConnection.prototype[method] = function () {
8476
- var track = arguments[0];
8477
- var streams = [].slice.call(arguments, 1);
8478
- trace("on".concat(method), makeEvent("".concat(track.kind, ":").concat(track.id, " ").concat(streams.map(function (s) { return "stream:".concat(s.id); }).join(';') || '-')));
8455
+ const track = arguments[0];
8456
+ const streams = [].slice.call(arguments, 1);
8457
+ trace(`on${method}`, makeEvent(`${track.kind}:${track.id} ${streams.map((s) => `stream:${s.id}`).join(';') || '-'}`));
8479
8458
  return nativeMethod.apply(this, arguments);
8480
8459
  };
8481
8460
  }
8482
8461
  });
8483
- ['removeTrack'].forEach(function (method) {
8484
- var nativeMethod = origPeerConnection.prototype[method];
8462
+ ['removeTrack'].forEach((method) => {
8463
+ // @ts-ignore
8464
+ const nativeMethod = origPeerConnection.prototype[method];
8485
8465
  if (nativeMethod) {
8466
+ // @ts-ignore
8486
8467
  origPeerConnection.prototype[method] = function () {
8487
- var track = arguments[0].track;
8488
- trace("on".concat(method), makeEvent(track ? "".concat(track.kind, ":").concat(track.id) : 'null'));
8468
+ const track = arguments[0].track;
8469
+ trace(`on${method}`, makeEvent(track ? `${track.kind}:${track.id}` : 'null'));
8489
8470
  return nativeMethod.apply(this, arguments);
8490
8471
  };
8491
8472
  }
8492
8473
  });
8493
- ['createOffer', 'createAnswer'].forEach(function (method) {
8494
- var nativeMethod = origPeerConnection.prototype[method];
8474
+ ['createOffer', 'createAnswer'].forEach((method) => {
8475
+ // @ts-ignore
8476
+ const nativeMethod = origPeerConnection.prototype[method];
8495
8477
  if (nativeMethod) {
8478
+ // @ts-ignore
8496
8479
  origPeerConnection.prototype[method] = function () {
8497
- var opts;
8498
- var args = arguments;
8480
+ let opts;
8481
+ const args = arguments;
8499
8482
  if (arguments.length === 1 && typeof arguments[0] === 'object') {
8500
- // eslint-disable-next-line prefer-destructuring
8501
8483
  opts = arguments[0];
8502
8484
  }
8503
8485
  else if (arguments.length === 3 && typeof arguments[2] === 'object') {
8504
- // eslint-disable-next-line prefer-destructuring
8505
8486
  opts = arguments[2];
8506
8487
  }
8507
- trace("on".concat(method), makeEvent(opts || ''));
8508
- return nativeMethod.apply(this, opts ? [opts] : undefined).then(function (description) {
8509
- trace("on".concat(method, "OnSuccess"), makeEvent(description.sdp));
8488
+ trace(`on${method}`, makeEvent(opts || ''));
8489
+ return nativeMethod.apply(this, opts ? [opts] : undefined).then(
8490
+ // @ts-ignore
8491
+ (description) => {
8492
+ trace(`on${method}OnSuccess`, makeEvent(description.sdp));
8510
8493
  if (args.length > 0 && typeof args[0] === 'function') {
8511
8494
  args[0].apply(null, [description]);
8512
8495
  return undefined;
8513
8496
  }
8514
8497
  return description;
8515
- }, function (err) {
8516
- trace("on".concat(method, "OnFailure"), makeEvent(err.toString()));
8498
+ }, (err) => {
8499
+ trace(`on${method}OnFailure`, makeEvent(err.toString()));
8517
8500
  if (args.length > 1 && typeof args[1] === 'function') {
8518
8501
  args[1].apply(null, [err]);
8519
8502
  return;
@@ -8523,64 +8506,66 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8523
8506
  };
8524
8507
  }
8525
8508
  });
8526
- ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
8527
- var nativeMethod = origPeerConnection.prototype[method];
8509
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach((method) => {
8510
+ // @ts-ignore
8511
+ const nativeMethod = origPeerConnection.prototype[method];
8528
8512
  if (nativeMethod) {
8513
+ // @ts-ignore
8529
8514
  origPeerConnection.prototype[method] = function () {
8530
- var _this = this;
8531
- var args = arguments;
8532
- trace("on".concat(method), makeEvent(method === 'addIceCandidate'
8515
+ const args = arguments;
8516
+ trace(`on${method}`, makeEvent(method === 'addIceCandidate'
8533
8517
  ? arguments[0]
8534
- : (arguments[0] ? arguments[0].sdp : 'undefined')));
8535
- return nativeMethod.apply(this, [arguments[0]]).then(function () {
8518
+ : arguments[0]
8519
+ ? arguments[0].sdp
8520
+ : 'undefined'));
8521
+ return nativeMethod.apply(this, [arguments[0]]).then(() => {
8536
8522
  var _a;
8537
- trace("on".concat(method, "OnSuccess"), makeEvent('success'));
8523
+ trace(`on${method}OnSuccess`, makeEvent('success'));
8538
8524
  if (method.endsWith('Description')) {
8539
- if (!_this.transportEventsPreviouslyAdded) {
8540
- var senders = _this.getSenders();
8541
- var _loop_1 = function (sender) {
8525
+ // @ts-ignore
8526
+ if (!this.transportEventsPreviouslyAdded) {
8527
+ const senders = this.getSenders();
8528
+ for (const sender of senders) {
8542
8529
  if (sender.transport) {
8543
- sender.transport.addEventListener('statechange', function () {
8530
+ sender.transport.addEventListener('statechange', () => {
8544
8531
  if (sender && sender.transport) {
8545
- trace("ondtlsStateChange", makeEvent(sender.transport.state));
8532
+ trace(`ondtlsStateChange`, makeEvent(sender.transport.state));
8546
8533
  }
8547
8534
  });
8548
- sender.transport.addEventListener('error', function (error) {
8549
- var errorEvent = error;
8550
- trace("ondtlsError", makeEvent(errorEvent.error.errorDetail));
8535
+ sender.transport.addEventListener('error', (error) => {
8536
+ const errorEvent = error;
8537
+ trace(`ondtlsError`, makeEvent(errorEvent.error.errorDetail));
8551
8538
  });
8552
8539
  if (sender.transport.iceTransport) {
8553
- sender.transport.iceTransport.addEventListener('selectedcandidatepairchange', function () {
8540
+ sender.transport.iceTransport.addEventListener('selectedcandidatepairchange', () => {
8554
8541
  var _a, _b, _c, _d, _e, _f;
8555
8542
  if (sender.transport && sender.transport.iceTransport) {
8556
- var pair = sender.transport.iceTransport.getSelectedCandidatePair();
8557
- 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);
8558
- 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);
8559
- var pairString = "local: ".concat(localCandidate, ", remote: ").concat(remoteCandidate);
8543
+ const pair = sender.transport.iceTransport.getSelectedCandidatePair();
8544
+ 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}`;
8545
+ 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}`;
8546
+ const pairString = `local: ${localCandidate}, remote: ${remoteCandidate}`;
8560
8547
  trace('onselectedCandidatePairChange', makeEvent(pairString));
8561
8548
  }
8562
8549
  });
8563
8550
  }
8564
- _this.transportEventsPreviouslyAdded = true;
8551
+ // @ts-ignore
8552
+ this.transportEventsPreviouslyAdded = true;
8565
8553
  if (pc.getConfiguration().bundlePolicy === 'max-bundle') {
8566
- return "break";
8554
+ break;
8567
8555
  }
8568
8556
  }
8569
- };
8570
- for (var _i = 0, senders_1 = senders; _i < senders_1.length; _i++) {
8571
- var sender = senders_1[_i];
8572
- var state_1 = _loop_1(sender);
8573
- if (state_1 === "break")
8574
- break;
8575
8557
  }
8576
8558
  }
8577
- if (!_this.sctpEventsPreviouslyAdded) {
8559
+ // @ts-ignore
8560
+ if (!this.sctpEventsPreviouslyAdded) {
8578
8561
  // Some Firefox versions prior to 113 have sctp defined but not the events, so check both here.
8579
- if ((_a = _this.sctp) === null || _a === void 0 ? void 0 : _a.addEventListener) {
8580
- _this.sctp.addEventListener('statechange', function () {
8581
- trace('onsctpStateChange', makeEvent(_this.sctp.state));
8562
+ if ((_a = this.sctp) === null || _a === void 0 ? void 0 : _a.addEventListener) {
8563
+ this.sctp.addEventListener('statechange', () => {
8564
+ // @ts-ignore
8565
+ trace('onsctpStateChange', makeEvent(this.sctp.state));
8582
8566
  });
8583
- _this.sctpEventsPreviouslyAdded = true;
8567
+ // @ts-ignore
8568
+ this.sctpEventsPreviouslyAdded = true;
8584
8569
  }
8585
8570
  }
8586
8571
  }
@@ -8589,8 +8574,8 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8589
8574
  return undefined;
8590
8575
  }
8591
8576
  return undefined;
8592
- }, function (err) {
8593
- trace("on".concat(method, "OnFailure"), makeEvent(err.toString()));
8577
+ }, (err) => {
8578
+ trace(`on${method}OnFailure`, makeEvent(err.toString()));
8594
8579
  if (args.length >= 3 && typeof args[2] === 'function') {
8595
8580
  args[2].apply(null, [err]);
8596
8581
  return undefined;
@@ -8601,15 +8586,15 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8601
8586
  }
8602
8587
  });
8603
8588
  if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
8604
- var origGetUserMedia_1 = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
8605
- var gum = function () {
8589
+ const origGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
8590
+ const gum = function () {
8606
8591
  trace('onnavigator.mediaDevices.getUserMedia', makeEvent(JSON.stringify(arguments[0])));
8607
- return origGetUserMedia_1
8592
+ return origGetUserMedia
8608
8593
  .apply(navigator.mediaDevices, arguments)
8609
- .then(function (stream) {
8594
+ .then((stream) => {
8610
8595
  trace('onnavigator.mediaDevices.getUserMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
8611
8596
  return stream;
8612
- }, function (err) {
8597
+ }, (err) => {
8613
8598
  trace('onnavigator.mediaDevices.getUserMediaOnFailure', makeEvent(err.name));
8614
8599
  return Promise.reject(err);
8615
8600
  });
@@ -8617,53 +8602,46 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
8617
8602
  navigator.mediaDevices.getUserMedia = gum.bind(navigator.mediaDevices);
8618
8603
  }
8619
8604
  if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
8620
- var origGetDisplayMedia_1 = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
8621
- var gdm = function () {
8605
+ const origGetDisplayMedia = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
8606
+ const gdm = function () {
8622
8607
  trace('onnavigator.mediaDevices.getDisplayMedia', makeEvent(JSON.stringify(arguments[0])));
8623
- return origGetDisplayMedia_1
8608
+ return origGetDisplayMedia
8624
8609
  .apply(navigator.mediaDevices, arguments)
8625
- .then(function (stream) {
8610
+ .then((stream) => {
8626
8611
  trace('onnavigator.mediaDevices.getDisplayMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
8627
8612
  return stream;
8628
- }, function (err) {
8613
+ }, (err) => {
8629
8614
  trace('onnavigator.mediaDevices.getDisplayMediaOnFailure', makeEvent(err.name));
8630
8615
  return Promise.reject(err);
8631
8616
  });
8632
8617
  };
8633
8618
  navigator.mediaDevices.getDisplayMedia = gdm.bind(navigator.mediaDevices);
8634
8619
  }
8635
- var getStatsReport = function () { return __awaiter(void 0, void 0, void 0, function () {
8636
- return __generator(this, function (_a) {
8637
- return [2 /*return*/, pc.getStats(null).then(function (res) {
8638
- // Convert from stats report to js Map in order to have values set in `statsPreProcessor`
8639
- var statsMap = new Map();
8640
- res.forEach(function (stats, key) { return statsMap.set(key, stats); });
8641
- return statsPreProcessor(statsMap).then(function () {
8642
- var now = map2obj(statsMap);
8643
- var base = deepCopy$1(now); // our new prev
8644
- var compressed = deltaCompression(prev, now);
8645
- trace('stats-report', formatStatsReport(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
8646
- prev = base;
8647
- return Promise.resolve();
8648
- });
8649
- })];
8620
+ const getStatsReport = async () => pc.getStats(null).then((res) => {
8621
+ // Convert from stats report to js Map in order to have values set in `statsPreProcessor`
8622
+ const statsMap = new Map();
8623
+ res.forEach((stats, key) => statsMap.set(key, stats));
8624
+ return statsPreProcessor(statsMap).then(() => {
8625
+ const now = map2obj(statsMap);
8626
+ const base = deepCopy$1(now); // our new prev
8627
+ const compressed = deltaCompression(prev, now);
8628
+ trace('stats-report', formatStatsReport(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
8629
+ prev = base;
8630
+ return Promise.resolve();
8650
8631
  });
8651
- }); };
8652
- var interval = window.setInterval(function () {
8632
+ });
8633
+ const interval = window.setInterval(() => {
8653
8634
  if (pc.signalingState === 'closed') {
8654
8635
  window.clearInterval(interval);
8655
8636
  return;
8656
8637
  }
8657
8638
  getStatsReport();
8658
8639
  }, intervalTime);
8659
- var forceStatsReport = function () { return __awaiter(void 0, void 0, void 0, function () {
8660
- return __generator(this, function (_a) {
8661
- return [2 /*return*/, getStatsReport()];
8662
- });
8663
- }); };
8664
- return { forceStatsReport: forceStatsReport };
8640
+ const forceStatsReport = async () => {
8641
+ return getStatsReport();
8642
+ };
8643
+ return { forceStatsReport };
8665
8644
  };
8666
- rtcStats_1 = rtcstats.rtcStats = rtcStats;
8667
8645
 
8668
8646
  const NUM = '\\d+';
8669
8647
  const SDP_TOKEN = "[!#$%&'*+\\-.^_`{|}~a-zA-Z0-9]+";
@@ -11211,12 +11189,12 @@ function getCurrentTimestamp() {
11211
11189
  return performance.timeOrigin + performance.now();
11212
11190
  }
11213
11191
  class StatsManager {
11214
- constructor(statsGetter, statsPreprocessor = () => __awaiter$1(this, void 0, void 0, function* () { })) {
11192
+ constructor(statsGetter, statsPreprocessor = () => __awaiter(this, void 0, void 0, function* () { })) {
11215
11193
  this.statsGetter = statsGetter;
11216
11194
  this.statsPreProcessor = statsPreprocessor;
11217
11195
  }
11218
11196
  getStats() {
11219
- return __awaiter$1(this, void 0, void 0, function* () {
11197
+ return __awaiter(this, void 0, void 0, function* () {
11220
11198
  const statsReport = yield this.statsGetter();
11221
11199
  const statsMap = new Map();
11222
11200
  statsReport.forEach((stats, key) => statsMap.set(key, stats));
@@ -11282,7 +11260,7 @@ class ReceiveOnlyTransceiver extends Transceiver {
11282
11260
  return this._receiveSlot;
11283
11261
  }
11284
11262
  getStats() {
11285
- return __awaiter$1(this, void 0, void 0, function* () {
11263
+ return __awaiter(this, void 0, void 0, function* () {
11286
11264
  const statsMap = new Map();
11287
11265
  const statsReport = yield this.receiver.getStats();
11288
11266
  statsReport.forEach((stats, key) => {
@@ -15032,7 +15010,7 @@ function waterfall (tasks, callback) {
15032
15010
  awaitify(waterfall);
15033
15011
 
15034
15012
  function processTasks(task, finishedCallback) {
15035
- return __awaiter$1(this, void 0, void 0, function* () {
15013
+ return __awaiter(this, void 0, void 0, function* () {
15036
15014
  try {
15037
15015
  yield task();
15038
15016
  finishedCallback();
@@ -15092,7 +15070,7 @@ class SendOnlyTransceiver extends Transceiver {
15092
15070
  }
15093
15071
  replaceSenderSource(stream) {
15094
15072
  var _a, _b;
15095
- return __awaiter$1(this, void 0, void 0, function* () {
15073
+ return __awaiter(this, void 0, void 0, function* () {
15096
15074
  const trackOrNull = (_a = stream === null || stream === void 0 ? void 0 : stream.outputStream.getTracks()[0]) !== null && _a !== void 0 ? _a : null;
15097
15075
  if (((_b = this.sender.track) === null || _b === void 0 ? void 0 : _b.id) !== (trackOrNull === null || trackOrNull === void 0 ? void 0 : trackOrNull.id)) {
15098
15076
  yield this.sender.replaceTrack(trackOrNull);
@@ -15106,14 +15084,14 @@ class SendOnlyTransceiver extends Transceiver {
15106
15084
  });
15107
15085
  }
15108
15086
  handleTrackChange() {
15109
- return __awaiter$1(this, void 0, void 0, function* () {
15087
+ return __awaiter(this, void 0, void 0, function* () {
15110
15088
  if (this.requested) {
15111
15089
  yield this.replaceSenderSource(this.publishedStream);
15112
15090
  }
15113
15091
  });
15114
15092
  }
15115
15093
  handleStreamConstraintsChange() {
15116
- return __awaiter$1(this, void 0, void 0, function* () {
15094
+ return __awaiter(this, void 0, void 0, function* () {
15117
15095
  yield this.updateSendParameters(this.requestedIdEncodingParamsMap);
15118
15096
  });
15119
15097
  }
@@ -15130,7 +15108,7 @@ class SendOnlyTransceiver extends Transceiver {
15130
15108
  const _super = Object.create(null, {
15131
15109
  replaceTransceiver: { get: () => super.replaceTransceiver }
15132
15110
  });
15133
- return __awaiter$1(this, void 0, void 0, function* () {
15111
+ return __awaiter(this, void 0, void 0, function* () {
15134
15112
  _super.replaceTransceiver.call(this, newRtcRtpTransceiver);
15135
15113
  newRtcRtpTransceiver.direction = this.direction;
15136
15114
  if (this.requested) {
@@ -15139,7 +15117,7 @@ class SendOnlyTransceiver extends Transceiver {
15139
15117
  });
15140
15118
  }
15141
15119
  replacePublishedStream(newStream) {
15142
- return __awaiter$1(this, void 0, void 0, function* () {
15120
+ return __awaiter(this, void 0, void 0, function* () {
15143
15121
  const oldStream = this.publishedStream;
15144
15122
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.LocalStreamEventNames.OutputTrackChange, this.handleTrackChange);
15145
15123
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
@@ -15192,7 +15170,7 @@ class SendOnlyTransceiver extends Transceiver {
15192
15170
  }
15193
15171
  }
15194
15172
  getStats() {
15195
- return __awaiter$1(this, void 0, void 0, function* () {
15173
+ return __awaiter(this, void 0, void 0, function* () {
15196
15174
  const statsMap = new Map();
15197
15175
  const statsReport = yield this.sender.getStats();
15198
15176
  statsReport.forEach((stats, key) => {
@@ -15247,8 +15225,8 @@ class SendOnlyTransceiver extends Transceiver {
15247
15225
  });
15248
15226
  }
15249
15227
  updateSendParameters(requestedIdEncodingParamsMap) {
15250
- return __awaiter$1(this, void 0, void 0, function* () {
15251
- return this.updateSendParametersQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
15228
+ return __awaiter(this, void 0, void 0, function* () {
15229
+ return this.updateSendParametersQueue.push(() => __awaiter(this, void 0, void 0, function* () {
15252
15230
  const sendParameters = this.sender.getParameters();
15253
15231
  sendParameters.encodings.forEach((encoding, index) => {
15254
15232
  var _a, _b;
@@ -15362,7 +15340,7 @@ class SendSlot {
15362
15340
  this.sendTransceiver = sendTransceiver;
15363
15341
  }
15364
15342
  publishStream(stream) {
15365
- return __awaiter$1(this, void 0, void 0, function* () {
15343
+ return __awaiter(this, void 0, void 0, function* () {
15366
15344
  if (stream === this.sendTransceiver.publishedStream) {
15367
15345
  return Promise.resolve();
15368
15346
  }
@@ -15370,7 +15348,7 @@ class SendSlot {
15370
15348
  });
15371
15349
  }
15372
15350
  unpublishStream() {
15373
- return __awaiter$1(this, void 0, void 0, function* () {
15351
+ return __awaiter(this, void 0, void 0, function* () {
15374
15352
  if (!this.sendTransceiver.publishedStream) {
15375
15353
  return Promise.resolve();
15376
15354
  }
@@ -15390,12 +15368,12 @@ class SendSlot {
15390
15368
  this.sendTransceiver.active = active;
15391
15369
  }
15392
15370
  setCodecParameters(parameters) {
15393
- return __awaiter$1(this, void 0, void 0, function* () {
15371
+ return __awaiter(this, void 0, void 0, function* () {
15394
15372
  this.sendTransceiver.setCodecParameters(parameters);
15395
15373
  });
15396
15374
  }
15397
15375
  deleteCodecParameters(parameters) {
15398
- return __awaiter$1(this, void 0, void 0, function* () {
15376
+ return __awaiter(this, void 0, void 0, function* () {
15399
15377
  this.sendTransceiver.deleteCodecParameters(parameters);
15400
15378
  });
15401
15379
  }
@@ -15407,7 +15385,7 @@ class SendSlot {
15407
15385
  }
15408
15386
  }
15409
15387
 
15410
- const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnectionStats) => __awaiter$1(void 0, void 0, void 0, function* () {
15388
+ const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnectionStats) => __awaiter(void 0, void 0, void 0, function* () {
15411
15389
  const result = {
15412
15390
  audio: {
15413
15391
  senders: [],
@@ -15426,7 +15404,7 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnec
15426
15404
  receivers: [],
15427
15405
  },
15428
15406
  };
15429
- yield Promise.all([...sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter$1(void 0, void 0, void 0, function* () {
15407
+ yield Promise.all([...sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter(void 0, void 0, void 0, function* () {
15430
15408
  var _a;
15431
15409
  const item = {
15432
15410
  report: yield transceiver.getStats(),
@@ -15451,8 +15429,8 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnec
15451
15429
  result.screenShareVideo.senders.push(item);
15452
15430
  }
15453
15431
  })));
15454
- yield Promise.all([...recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter$1(void 0, void 0, void 0, function* () {
15455
- return Promise.all(transceivers.map((t) => __awaiter$1(void 0, void 0, void 0, function* () {
15432
+ yield Promise.all([...recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter(void 0, void 0, void 0, function* () {
15433
+ return Promise.all(transceivers.map((t) => __awaiter(void 0, void 0, void 0, function* () {
15456
15434
  var _b;
15457
15435
  const item = {
15458
15436
  report: yield t.getStats(),
@@ -15969,14 +15947,14 @@ SCTP Max Message Size: ${maxMessageSize}`);
15969
15947
  return recvOnlyTransceiver;
15970
15948
  }
15971
15949
  createReceiveSlot(mediaType) {
15972
- return __awaiter$1(this, void 0, void 0, function* () {
15950
+ return __awaiter(this, void 0, void 0, function* () {
15973
15951
  return (yield this.createReceiveSlots(mediaType, 1))[0];
15974
15952
  });
15975
15953
  }
15976
15954
  createReceiveSlots(mediaType, count = 1) {
15977
- return __awaiter$1(this, void 0, void 0, function* () {
15955
+ return __awaiter(this, void 0, void 0, function* () {
15978
15956
  return new Promise((createReceiveSlotsResolve) => {
15979
- this.offerAnswerQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
15957
+ this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
15980
15958
  const createdReceiveOnlyTransceivers = [];
15981
15959
  for (let i = 0; i < count; i++) {
15982
15960
  const recvOnlyTransceiver = this.createReceiveTransceiver(mediaType);
@@ -16023,7 +16001,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16023
16001
  return targetCodec.pt;
16024
16002
  }
16025
16003
  waitForIceGatheringComplete() {
16026
- return __awaiter$1(this, void 0, void 0, function* () {
16004
+ return __awaiter(this, void 0, void 0, function* () {
16027
16005
  return new Promise((resolve, reject) => {
16028
16006
  const finalizeIceCandidatesGathering = () => this.pc.getIceCandidates().length > 0
16029
16007
  ? resolve()
@@ -16049,7 +16027,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16049
16027
  });
16050
16028
  }
16051
16029
  createOffer() {
16052
- return __awaiter$1(this, void 0, void 0, function* () {
16030
+ return __awaiter(this, void 0, void 0, function* () {
16053
16031
  if (!this.pc.getLocalDescription()) {
16054
16032
  this.midPredictor.allocateMidForDatachannel();
16055
16033
  }
@@ -16060,7 +16038,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16060
16038
  }
16061
16039
  const createOfferId = ++this.currentCreateOfferId;
16062
16040
  return new Promise((createOfferResolve, createOfferReject) => {
16063
- this.offerAnswerQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
16041
+ this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
16064
16042
  var _a;
16065
16043
  try {
16066
16044
  const offer = yield this.pc.createOffer();
@@ -16070,7 +16048,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16070
16048
  offer.sdp = this.preProcessLocalOffer(offer.sdp);
16071
16049
  yield this.pc
16072
16050
  .setLocalDescription(offer)
16073
- .then(() => __awaiter$1(this, void 0, void 0, function* () {
16051
+ .then(() => __awaiter(this, void 0, void 0, function* () {
16074
16052
  logger.info('this.pc.setLocalDescription() resolved');
16075
16053
  }))
16076
16054
  .catch((error) => {
@@ -16104,7 +16082,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16104
16082
  });
16105
16083
  }
16106
16084
  setAnswer(answer) {
16107
- return __awaiter$1(this, void 0, void 0, function* () {
16085
+ return __awaiter(this, void 0, void 0, function* () {
16108
16086
  const sdp = this.preProcessRemoteAnswer(answer);
16109
16087
  if (!this.setAnswerResolve) {
16110
16088
  logErrorAndThrow(exports.WcmeErrorType.SET_ANSWER_FAILED, `Call to setAnswer without having previously called createOffer.`);
@@ -16112,7 +16090,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16112
16090
  logger.info('calling this.pc.setRemoteDescription()');
16113
16091
  return this.pc
16114
16092
  .setRemoteDescription({ type: 'answer', sdp })
16115
- .then(() => __awaiter$1(this, void 0, void 0, function* () {
16093
+ .then(() => __awaiter(this, void 0, void 0, function* () {
16116
16094
  logger.info('this.pc.setRemoteDescription() resolved');
16117
16095
  if (this.setAnswerResolve) {
16118
16096
  this.setAnswerResolve();
@@ -16129,7 +16107,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16129
16107
  }
16130
16108
  doLocalOfferAnswer() {
16131
16109
  var _a;
16132
- return __awaiter$1(this, void 0, void 0, function* () {
16110
+ return __awaiter(this, void 0, void 0, function* () {
16133
16111
  const offer = yield this.pc.createOffer();
16134
16112
  if (!offer.sdp) {
16135
16113
  logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
@@ -16137,7 +16115,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16137
16115
  offer.sdp = this.preProcessLocalOffer(offer.sdp);
16138
16116
  yield this.pc
16139
16117
  .setLocalDescription(offer)
16140
- .then(() => __awaiter$1(this, void 0, void 0, function* () {
16118
+ .then(() => __awaiter(this, void 0, void 0, function* () {
16141
16119
  logger.info('this.pc.setLocalDescription() resolved');
16142
16120
  }))
16143
16121
  .catch((error) => {
@@ -16147,7 +16125,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16147
16125
  const answer = this.preProcessRemoteAnswer((_a = this.pc.getRemoteDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
16148
16126
  return this.pc
16149
16127
  .setRemoteDescription({ type: 'answer', sdp: answer })
16150
- .then(() => __awaiter$1(this, void 0, void 0, function* () {
16128
+ .then(() => __awaiter(this, void 0, void 0, function* () {
16151
16129
  logger.info('this.pc.setRemoteDescription() resolved');
16152
16130
  }))
16153
16131
  .catch((error) => {
@@ -16156,8 +16134,8 @@ SCTP Max Message Size: ${maxMessageSize}`);
16156
16134
  });
16157
16135
  }
16158
16136
  queueLocalOfferAnswer() {
16159
- return __awaiter$1(this, void 0, void 0, function* () {
16160
- return this.offerAnswerQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
16137
+ return __awaiter(this, void 0, void 0, function* () {
16138
+ return this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
16161
16139
  yield this.doLocalOfferAnswer();
16162
16140
  }));
16163
16141
  });
@@ -16330,7 +16308,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16330
16308
  }
16331
16309
  renewPeerConnection(userOptions) {
16332
16310
  var _a;
16333
- return __awaiter$1(this, void 0, void 0, function* () {
16311
+ return __awaiter(this, void 0, void 0, function* () {
16334
16312
  (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
16335
16313
  try {
16336
16314
  if (userOptions) {
@@ -16387,28 +16365,28 @@ SCTP Max Message Size: ${maxMessageSize}`);
16387
16365
  return this.statsManager.getStats();
16388
16366
  }
16389
16367
  getTransceiverStats() {
16390
- return __awaiter$1(this, void 0, void 0, function* () {
16368
+ return __awaiter(this, void 0, void 0, function* () {
16391
16369
  const stats = yield this.getStats();
16392
16370
  const peerConnectionStats = [...stats.values()].find((stat) => stat.type === 'peer-connection');
16393
16371
  return organizeTransceiverStats(this.sendTransceivers, this.recvTransceivers, peerConnectionStats);
16394
16372
  });
16395
16373
  }
16396
16374
  preProcessStats(stats) {
16397
- return __awaiter$1(this, void 0, void 0, function* () {
16375
+ return __awaiter(this, void 0, void 0, function* () {
16398
16376
  stats.forEach((stat) => {
16399
16377
  if (stat.type === 'peer-connection') {
16400
16378
  stat.isMediaBypassEdge = this.metadata.isMediaBypassEdge;
16401
16379
  }
16402
16380
  });
16403
- yield Promise.all([...this.sendTransceivers.values()].map((transceiver) => __awaiter$1(this, void 0, void 0, function* () {
16381
+ yield Promise.all([...this.sendTransceivers.values()].map((transceiver) => __awaiter(this, void 0, void 0, function* () {
16404
16382
  (yield transceiver.getStats()).forEach((senderStats) => {
16405
16383
  if (senderStats.type === 'outbound-rtp' || senderStats.type === 'media-source') {
16406
16384
  stats.set(senderStats.id, senderStats);
16407
16385
  }
16408
16386
  });
16409
16387
  })));
16410
- yield Promise.all([...this.recvTransceivers.values()].map((transceivers) => __awaiter$1(this, void 0, void 0, function* () {
16411
- yield Promise.all(transceivers.map((transceiver) => __awaiter$1(this, void 0, void 0, function* () {
16388
+ yield Promise.all([...this.recvTransceivers.values()].map((transceivers) => __awaiter(this, void 0, void 0, function* () {
16389
+ yield Promise.all(transceivers.map((transceiver) => __awaiter(this, void 0, void 0, function* () {
16412
16390
  (yield transceiver.getStats()).forEach((receiverStats) => {
16413
16391
  if (receiverStats.type === 'inbound-rtp') {
16414
16392
  stats.set(receiverStats.id, receiverStats);
@@ -16419,7 +16397,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
16419
16397
  });
16420
16398
  }
16421
16399
  attachMetricsObserver() {
16422
- this.forceStatsReport = rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000, (stats) => this.preProcessStats(stats)).forceStatsReport;
16400
+ this.forceStatsReport = rtcStats(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000, (stats) => this.preProcessStats(stats)).forceStatsReport;
16423
16401
  }
16424
16402
  forceRtcMetricsCallback() {
16425
16403
  var _a;