livekit-client 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/livekit-client.esm.mjs +980 -760
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/proto/google/protobuf/timestamp.d.ts +1 -1
  6. package/dist/src/proto/google/protobuf/timestamp.d.ts.map +1 -1
  7. package/dist/src/proto/livekit_models.d.ts +34 -34
  8. package/dist/src/proto/livekit_models.d.ts.map +1 -1
  9. package/dist/src/proto/livekit_rtc.d.ts +124 -124
  10. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  11. package/dist/src/room/DeviceManager.d.ts +1 -0
  12. package/dist/src/room/DeviceManager.d.ts.map +1 -1
  13. package/dist/src/room/PCTransport.d.ts +4 -1
  14. package/dist/src/room/PCTransport.d.ts.map +1 -1
  15. package/dist/src/room/RTCEngine.d.ts +1 -0
  16. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  17. package/dist/src/room/Room.d.ts +4 -1
  18. package/dist/src/room/Room.d.ts.map +1 -1
  19. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  20. package/dist/src/room/track/LocalAudioTrack.d.ts +0 -1
  21. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  22. package/dist/src/room/track/LocalVideoTrack.d.ts +1 -1
  23. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  24. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  25. package/dist/src/room/track/RemoteVideoTrack.d.ts +0 -2
  26. package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
  27. package/dist/src/room/track/create.d.ts.map +1 -1
  28. package/dist/src/room/utils.d.ts +1 -1
  29. package/dist/src/room/utils.d.ts.map +1 -1
  30. package/package.json +36 -34
  31. package/src/room/DeviceManager.ts +23 -1
  32. package/src/room/RTCEngine.ts +30 -6
  33. package/src/room/Room.ts +143 -145
  34. package/src/room/participant/LocalParticipant.ts +13 -3
  35. package/src/room/track/LocalAudioTrack.ts +0 -2
  36. package/src/room/track/LocalVideoTrack.ts +3 -7
  37. package/src/room/track/RemoteTrackPublication.ts +1 -1
  38. package/src/room/track/RemoteVideoTrack.ts +0 -3
  39. package/src/room/track/create.ts +16 -1
  40. package/src/room/utils.ts +7 -5
@@ -1607,9 +1607,11 @@ Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
1607
1607
  return new Long(bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7], bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], unsigned);
1608
1608
  };
1609
1609
 
1610
+ var minimal$1 = {exports: {}};
1611
+
1610
1612
  var indexMinimal = {};
1611
1613
 
1612
- var minimal$1 = {};
1614
+ var minimal = {};
1613
1615
 
1614
1616
  var aspromise = asPromise;
1615
1617
  /**
@@ -2387,618 +2389,656 @@ function pool(alloc, slice, size) {
2387
2389
  };
2388
2390
  }
2389
2391
 
2390
- var longbits = LongBits$2;
2391
- var util$5 = minimal$1;
2392
- /**
2393
- * Constructs new long bits.
2394
- * @classdesc Helper class for working with the low and high bits of a 64 bit value.
2395
- * @memberof util
2396
- * @constructor
2397
- * @param {number} lo Low 32 bits, unsigned
2398
- * @param {number} hi High 32 bits, unsigned
2399
- */
2392
+ var longbits;
2393
+ var hasRequiredLongbits;
2400
2394
 
2401
- function LongBits$2(lo, hi) {
2402
- // note that the casts below are theoretically unnecessary as of today, but older statically
2403
- // generated converter code might still call the ctor with signed 32bits. kept for compat.
2395
+ function requireLongbits() {
2396
+ if (hasRequiredLongbits) return longbits;
2397
+ hasRequiredLongbits = 1;
2404
2398
 
2399
+ longbits = LongBits;
2400
+ var util = requireMinimal();
2405
2401
  /**
2406
- * Low bits.
2407
- * @type {number}
2402
+ * Constructs new long bits.
2403
+ * @classdesc Helper class for working with the low and high bits of a 64 bit value.
2404
+ * @memberof util
2405
+ * @constructor
2406
+ * @param {number} lo Low 32 bits, unsigned
2407
+ * @param {number} hi High 32 bits, unsigned
2408
2408
  */
2409
- this.lo = lo >>> 0;
2409
+
2410
+ function LongBits(lo, hi) {
2411
+ // note that the casts below are theoretically unnecessary as of today, but older statically
2412
+ // generated converter code might still call the ctor with signed 32bits. kept for compat.
2413
+
2414
+ /**
2415
+ * Low bits.
2416
+ * @type {number}
2417
+ */
2418
+ this.lo = lo >>> 0;
2419
+ /**
2420
+ * High bits.
2421
+ * @type {number}
2422
+ */
2423
+
2424
+ this.hi = hi >>> 0;
2425
+ }
2410
2426
  /**
2411
- * High bits.
2412
- * @type {number}
2427
+ * Zero bits.
2428
+ * @memberof util.LongBits
2429
+ * @type {util.LongBits}
2413
2430
  */
2414
2431
 
2415
- this.hi = hi >>> 0;
2416
- }
2417
- /**
2418
- * Zero bits.
2419
- * @memberof util.LongBits
2420
- * @type {util.LongBits}
2421
- */
2422
-
2423
2432
 
2424
- var zero = LongBits$2.zero = new LongBits$2(0, 0);
2433
+ var zero = LongBits.zero = new LongBits(0, 0);
2425
2434
 
2426
- zero.toNumber = function () {
2427
- return 0;
2428
- };
2435
+ zero.toNumber = function () {
2436
+ return 0;
2437
+ };
2429
2438
 
2430
- zero.zzEncode = zero.zzDecode = function () {
2431
- return this;
2432
- };
2439
+ zero.zzEncode = zero.zzDecode = function () {
2440
+ return this;
2441
+ };
2433
2442
 
2434
- zero.length = function () {
2435
- return 1;
2436
- };
2437
- /**
2438
- * Zero hash.
2439
- * @memberof util.LongBits
2440
- * @type {string}
2441
- */
2443
+ zero.length = function () {
2444
+ return 1;
2445
+ };
2446
+ /**
2447
+ * Zero hash.
2448
+ * @memberof util.LongBits
2449
+ * @type {string}
2450
+ */
2442
2451
 
2443
2452
 
2444
- var zeroHash = LongBits$2.zeroHash = "\0\0\0\0\0\0\0\0";
2445
- /**
2446
- * Constructs new long bits from the specified number.
2447
- * @param {number} value Value
2448
- * @returns {util.LongBits} Instance
2449
- */
2453
+ var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
2454
+ /**
2455
+ * Constructs new long bits from the specified number.
2456
+ * @param {number} value Value
2457
+ * @returns {util.LongBits} Instance
2458
+ */
2450
2459
 
2451
- LongBits$2.fromNumber = function fromNumber(value) {
2452
- if (value === 0) return zero;
2453
- var sign = value < 0;
2454
- if (sign) value = -value;
2455
- var lo = value >>> 0,
2456
- hi = (value - lo) / 4294967296 >>> 0;
2460
+ LongBits.fromNumber = function fromNumber(value) {
2461
+ if (value === 0) return zero;
2462
+ var sign = value < 0;
2463
+ if (sign) value = -value;
2464
+ var lo = value >>> 0,
2465
+ hi = (value - lo) / 4294967296 >>> 0;
2457
2466
 
2458
- if (sign) {
2459
- hi = ~hi >>> 0;
2460
- lo = ~lo >>> 0;
2467
+ if (sign) {
2468
+ hi = ~hi >>> 0;
2469
+ lo = ~lo >>> 0;
2461
2470
 
2462
- if (++lo > 4294967295) {
2463
- lo = 0;
2464
- if (++hi > 4294967295) hi = 0;
2471
+ if (++lo > 4294967295) {
2472
+ lo = 0;
2473
+ if (++hi > 4294967295) hi = 0;
2474
+ }
2465
2475
  }
2466
- }
2467
2476
 
2468
- return new LongBits$2(lo, hi);
2469
- };
2470
- /**
2471
- * Constructs new long bits from a number, long or string.
2472
- * @param {Long|number|string} value Value
2473
- * @returns {util.LongBits} Instance
2474
- */
2477
+ return new LongBits(lo, hi);
2478
+ };
2479
+ /**
2480
+ * Constructs new long bits from a number, long or string.
2481
+ * @param {Long|number|string} value Value
2482
+ * @returns {util.LongBits} Instance
2483
+ */
2475
2484
 
2476
2485
 
2477
- LongBits$2.from = function from(value) {
2478
- if (typeof value === "number") return LongBits$2.fromNumber(value);
2486
+ LongBits.from = function from(value) {
2487
+ if (typeof value === "number") return LongBits.fromNumber(value);
2479
2488
 
2480
- if (util$5.isString(value)) {
2481
- /* istanbul ignore else */
2482
- if (util$5.Long) value = util$5.Long.fromString(value);else return LongBits$2.fromNumber(parseInt(value, 10));
2483
- }
2489
+ if (util.isString(value)) {
2490
+ /* istanbul ignore else */
2491
+ if (util.Long) value = util.Long.fromString(value);else return LongBits.fromNumber(parseInt(value, 10));
2492
+ }
2484
2493
 
2485
- return value.low || value.high ? new LongBits$2(value.low >>> 0, value.high >>> 0) : zero;
2486
- };
2487
- /**
2488
- * Converts this long bits to a possibly unsafe JavaScript number.
2489
- * @param {boolean} [unsigned=false] Whether unsigned or not
2490
- * @returns {number} Possibly unsafe number
2491
- */
2494
+ return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
2495
+ };
2496
+ /**
2497
+ * Converts this long bits to a possibly unsafe JavaScript number.
2498
+ * @param {boolean} [unsigned=false] Whether unsigned or not
2499
+ * @returns {number} Possibly unsafe number
2500
+ */
2492
2501
 
2493
2502
 
2494
- LongBits$2.prototype.toNumber = function toNumber(unsigned) {
2495
- if (!unsigned && this.hi >>> 31) {
2496
- var lo = ~this.lo + 1 >>> 0,
2497
- hi = ~this.hi >>> 0;
2498
- if (!lo) hi = hi + 1 >>> 0;
2499
- return -(lo + hi * 4294967296);
2500
- }
2503
+ LongBits.prototype.toNumber = function toNumber(unsigned) {
2504
+ if (!unsigned && this.hi >>> 31) {
2505
+ var lo = ~this.lo + 1 >>> 0,
2506
+ hi = ~this.hi >>> 0;
2507
+ if (!lo) hi = hi + 1 >>> 0;
2508
+ return -(lo + hi * 4294967296);
2509
+ }
2501
2510
 
2502
- return this.lo + this.hi * 4294967296;
2503
- };
2504
- /**
2505
- * Converts this long bits to a long.
2506
- * @param {boolean} [unsigned=false] Whether unsigned or not
2507
- * @returns {Long} Long
2508
- */
2511
+ return this.lo + this.hi * 4294967296;
2512
+ };
2513
+ /**
2514
+ * Converts this long bits to a long.
2515
+ * @param {boolean} [unsigned=false] Whether unsigned or not
2516
+ * @returns {Long} Long
2517
+ */
2509
2518
 
2510
2519
 
2511
- LongBits$2.prototype.toLong = function toLong(unsigned) {
2512
- return util$5.Long ? new util$5.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
2513
- /* istanbul ignore next */
2514
- : {
2515
- low: this.lo | 0,
2516
- high: this.hi | 0,
2517
- unsigned: Boolean(unsigned)
2520
+ LongBits.prototype.toLong = function toLong(unsigned) {
2521
+ return util.Long ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
2522
+ /* istanbul ignore next */
2523
+ : {
2524
+ low: this.lo | 0,
2525
+ high: this.hi | 0,
2526
+ unsigned: Boolean(unsigned)
2527
+ };
2518
2528
  };
2519
- };
2520
2529
 
2521
- var charCodeAt = String.prototype.charCodeAt;
2522
- /**
2523
- * Constructs new long bits from the specified 8 characters long hash.
2524
- * @param {string} hash Hash
2525
- * @returns {util.LongBits} Bits
2526
- */
2530
+ var charCodeAt = String.prototype.charCodeAt;
2531
+ /**
2532
+ * Constructs new long bits from the specified 8 characters long hash.
2533
+ * @param {string} hash Hash
2534
+ * @returns {util.LongBits} Bits
2535
+ */
2527
2536
 
2528
- LongBits$2.fromHash = function fromHash(hash) {
2529
- if (hash === zeroHash) return zero;
2530
- return new LongBits$2((charCodeAt.call(hash, 0) | charCodeAt.call(hash, 1) << 8 | charCodeAt.call(hash, 2) << 16 | charCodeAt.call(hash, 3) << 24) >>> 0, (charCodeAt.call(hash, 4) | charCodeAt.call(hash, 5) << 8 | charCodeAt.call(hash, 6) << 16 | charCodeAt.call(hash, 7) << 24) >>> 0);
2531
- };
2532
- /**
2533
- * Converts this long bits to a 8 characters long hash.
2534
- * @returns {string} Hash
2535
- */
2537
+ LongBits.fromHash = function fromHash(hash) {
2538
+ if (hash === zeroHash) return zero;
2539
+ return new LongBits((charCodeAt.call(hash, 0) | charCodeAt.call(hash, 1) << 8 | charCodeAt.call(hash, 2) << 16 | charCodeAt.call(hash, 3) << 24) >>> 0, (charCodeAt.call(hash, 4) | charCodeAt.call(hash, 5) << 8 | charCodeAt.call(hash, 6) << 16 | charCodeAt.call(hash, 7) << 24) >>> 0);
2540
+ };
2541
+ /**
2542
+ * Converts this long bits to a 8 characters long hash.
2543
+ * @returns {string} Hash
2544
+ */
2536
2545
 
2537
2546
 
2538
- LongBits$2.prototype.toHash = function toHash() {
2539
- return String.fromCharCode(this.lo & 255, this.lo >>> 8 & 255, this.lo >>> 16 & 255, this.lo >>> 24, this.hi & 255, this.hi >>> 8 & 255, this.hi >>> 16 & 255, this.hi >>> 24);
2540
- };
2541
- /**
2542
- * Zig-zag encodes this long bits.
2543
- * @returns {util.LongBits} `this`
2544
- */
2547
+ LongBits.prototype.toHash = function toHash() {
2548
+ return String.fromCharCode(this.lo & 255, this.lo >>> 8 & 255, this.lo >>> 16 & 255, this.lo >>> 24, this.hi & 255, this.hi >>> 8 & 255, this.hi >>> 16 & 255, this.hi >>> 24);
2549
+ };
2550
+ /**
2551
+ * Zig-zag encodes this long bits.
2552
+ * @returns {util.LongBits} `this`
2553
+ */
2545
2554
 
2546
2555
 
2547
- LongBits$2.prototype.zzEncode = function zzEncode() {
2548
- var mask = this.hi >> 31;
2549
- this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
2550
- this.lo = (this.lo << 1 ^ mask) >>> 0;
2551
- return this;
2552
- };
2553
- /**
2554
- * Zig-zag decodes this long bits.
2555
- * @returns {util.LongBits} `this`
2556
- */
2556
+ LongBits.prototype.zzEncode = function zzEncode() {
2557
+ var mask = this.hi >> 31;
2558
+ this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
2559
+ this.lo = (this.lo << 1 ^ mask) >>> 0;
2560
+ return this;
2561
+ };
2562
+ /**
2563
+ * Zig-zag decodes this long bits.
2564
+ * @returns {util.LongBits} `this`
2565
+ */
2557
2566
 
2558
2567
 
2559
- LongBits$2.prototype.zzDecode = function zzDecode() {
2560
- var mask = -(this.lo & 1);
2561
- this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
2562
- this.hi = (this.hi >>> 1 ^ mask) >>> 0;
2563
- return this;
2564
- };
2565
- /**
2566
- * Calculates the length of this longbits when encoded as a varint.
2567
- * @returns {number} Length
2568
- */
2568
+ LongBits.prototype.zzDecode = function zzDecode() {
2569
+ var mask = -(this.lo & 1);
2570
+ this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
2571
+ this.hi = (this.hi >>> 1 ^ mask) >>> 0;
2572
+ return this;
2573
+ };
2574
+ /**
2575
+ * Calculates the length of this longbits when encoded as a varint.
2576
+ * @returns {number} Length
2577
+ */
2569
2578
 
2570
2579
 
2571
- LongBits$2.prototype.length = function length() {
2572
- var part0 = this.lo,
2573
- part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,
2574
- part2 = this.hi >>> 24;
2575
- return part2 === 0 ? part1 === 0 ? part0 < 16384 ? part0 < 128 ? 1 : 2 : part0 < 2097152 ? 3 : 4 : part1 < 16384 ? part1 < 128 ? 5 : 6 : part1 < 2097152 ? 7 : 8 : part2 < 128 ? 9 : 10;
2576
- };
2580
+ LongBits.prototype.length = function length() {
2581
+ var part0 = this.lo,
2582
+ part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,
2583
+ part2 = this.hi >>> 24;
2584
+ return part2 === 0 ? part1 === 0 ? part0 < 16384 ? part0 < 128 ? 1 : 2 : part0 < 2097152 ? 3 : 4 : part1 < 16384 ? part1 < 128 ? 5 : 6 : part1 < 2097152 ? 7 : 8 : part2 < 128 ? 9 : 10;
2585
+ };
2577
2586
 
2578
- (function (exports) {
2587
+ return longbits;
2588
+ }
2579
2589
 
2580
- var util = exports; // used to return a Promise where callback is omitted
2590
+ var hasRequiredMinimal;
2581
2591
 
2582
- util.asPromise = aspromise; // converts to / from base64 encoded strings
2592
+ function requireMinimal() {
2593
+ if (hasRequiredMinimal) return minimal;
2594
+ hasRequiredMinimal = 1;
2583
2595
 
2584
- util.base64 = base64$1; // base class of rpc.Service
2596
+ (function (exports) {
2585
2597
 
2586
- util.EventEmitter = eventemitter; // float handling accross browsers
2598
+ var util = exports; // used to return a Promise where callback is omitted
2587
2599
 
2588
- util.float = float; // requires modules optionally and hides the call from bundlers
2600
+ util.asPromise = aspromise; // converts to / from base64 encoded strings
2589
2601
 
2590
- util.inquire = inquire_1; // converts to / from utf8 encoded strings
2602
+ util.base64 = base64$1; // base class of rpc.Service
2591
2603
 
2592
- util.utf8 = utf8$2; // provides a node-like buffer pool in the browser
2604
+ util.EventEmitter = eventemitter; // float handling accross browsers
2593
2605
 
2594
- util.pool = pool_1; // utility to work with the low and high bits of a 64 bit value
2606
+ util.float = float; // requires modules optionally and hides the call from bundlers
2595
2607
 
2596
- util.LongBits = longbits;
2597
- /**
2598
- * Whether running within node or not.
2599
- * @memberof util
2600
- * @type {boolean}
2601
- */
2608
+ util.inquire = inquire_1; // converts to / from utf8 encoded strings
2602
2609
 
2603
- util.isNode = Boolean(typeof commonjsGlobal !== "undefined" && commonjsGlobal && commonjsGlobal.process && commonjsGlobal.process.versions && commonjsGlobal.process.versions.node);
2604
- /**
2605
- * Global object reference.
2606
- * @memberof util
2607
- * @type {Object}
2608
- */
2610
+ util.utf8 = utf8$2; // provides a node-like buffer pool in the browser
2609
2611
 
2610
- util.global = util.isNode && commonjsGlobal || typeof window !== "undefined" && window || typeof self !== "undefined" && self || commonjsGlobal; // eslint-disable-line no-invalid-this
2612
+ util.pool = pool_1; // utility to work with the low and high bits of a 64 bit value
2611
2613
 
2612
- /**
2613
- * An immuable empty array.
2614
- * @memberof util
2615
- * @type {Array.<*>}
2616
- * @const
2617
- */
2614
+ util.LongBits = requireLongbits();
2615
+ /**
2616
+ * Whether running within node or not.
2617
+ * @memberof util
2618
+ * @type {boolean}
2619
+ */
2618
2620
 
2619
- util.emptyArray = Object.freeze ? Object.freeze([]) :
2620
- /* istanbul ignore next */
2621
- []; // used on prototypes
2621
+ util.isNode = Boolean(typeof commonjsGlobal !== "undefined" && commonjsGlobal && commonjsGlobal.process && commonjsGlobal.process.versions && commonjsGlobal.process.versions.node);
2622
+ /**
2623
+ * Global object reference.
2624
+ * @memberof util
2625
+ * @type {Object}
2626
+ */
2622
2627
 
2623
- /**
2624
- * An immutable empty object.
2625
- * @type {Object}
2626
- * @const
2627
- */
2628
+ util.global = util.isNode && commonjsGlobal || typeof window !== "undefined" && window || typeof self !== "undefined" && self || commonjsGlobal; // eslint-disable-line no-invalid-this
2628
2629
 
2629
- util.emptyObject = Object.freeze ? Object.freeze({}) :
2630
- /* istanbul ignore next */
2631
- {}; // used on prototypes
2630
+ /**
2631
+ * An immuable empty array.
2632
+ * @memberof util
2633
+ * @type {Array.<*>}
2634
+ * @const
2635
+ */
2632
2636
 
2633
- /**
2634
- * Tests if the specified value is an integer.
2635
- * @function
2636
- * @param {*} value Value to test
2637
- * @returns {boolean} `true` if the value is an integer
2638
- */
2637
+ util.emptyArray = Object.freeze ? Object.freeze([]) :
2638
+ /* istanbul ignore next */
2639
+ []; // used on prototypes
2639
2640
 
2640
- util.isInteger = Number.isInteger ||
2641
- /* istanbul ignore next */
2642
- function isInteger(value) {
2643
- return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
2644
- };
2645
- /**
2646
- * Tests if the specified value is a string.
2647
- * @param {*} value Value to test
2648
- * @returns {boolean} `true` if the value is a string
2649
- */
2641
+ /**
2642
+ * An immutable empty object.
2643
+ * @type {Object}
2644
+ * @const
2645
+ */
2650
2646
 
2647
+ util.emptyObject = Object.freeze ? Object.freeze({}) :
2648
+ /* istanbul ignore next */
2649
+ {}; // used on prototypes
2651
2650
 
2652
- util.isString = function isString(value) {
2653
- return typeof value === "string" || value instanceof String;
2654
- };
2655
- /**
2656
- * Tests if the specified value is a non-null object.
2657
- * @param {*} value Value to test
2658
- * @returns {boolean} `true` if the value is a non-null object
2659
- */
2651
+ /**
2652
+ * Tests if the specified value is an integer.
2653
+ * @function
2654
+ * @param {*} value Value to test
2655
+ * @returns {boolean} `true` if the value is an integer
2656
+ */
2660
2657
 
2658
+ util.isInteger = Number.isInteger ||
2659
+ /* istanbul ignore next */
2660
+ function isInteger(value) {
2661
+ return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
2662
+ };
2663
+ /**
2664
+ * Tests if the specified value is a string.
2665
+ * @param {*} value Value to test
2666
+ * @returns {boolean} `true` if the value is a string
2667
+ */
2661
2668
 
2662
- util.isObject = function isObject(value) {
2663
- return value && typeof value === "object";
2664
- };
2665
- /**
2666
- * Checks if a property on a message is considered to be present.
2667
- * This is an alias of {@link util.isSet}.
2668
- * @function
2669
- * @param {Object} obj Plain object or message instance
2670
- * @param {string} prop Property name
2671
- * @returns {boolean} `true` if considered to be present, otherwise `false`
2672
- */
2673
2669
 
2670
+ util.isString = function isString(value) {
2671
+ return typeof value === "string" || value instanceof String;
2672
+ };
2673
+ /**
2674
+ * Tests if the specified value is a non-null object.
2675
+ * @param {*} value Value to test
2676
+ * @returns {boolean} `true` if the value is a non-null object
2677
+ */
2674
2678
 
2675
- util.isset =
2676
- /**
2677
- * Checks if a property on a message is considered to be present.
2678
- * @param {Object} obj Plain object or message instance
2679
- * @param {string} prop Property name
2680
- * @returns {boolean} `true` if considered to be present, otherwise `false`
2681
- */
2682
- util.isSet = function isSet(obj, prop) {
2683
- var value = obj[prop];
2684
- if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins
2685
- return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
2686
- return false;
2687
- };
2688
- /**
2689
- * Any compatible Buffer instance.
2690
- * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
2691
- * @interface Buffer
2692
- * @extends Uint8Array
2693
- */
2694
2679
 
2695
- /**
2696
- * Node's Buffer class if available.
2697
- * @type {Constructor<Buffer>}
2698
- */
2680
+ util.isObject = function isObject(value) {
2681
+ return value && typeof value === "object";
2682
+ };
2683
+ /**
2684
+ * Checks if a property on a message is considered to be present.
2685
+ * This is an alias of {@link util.isSet}.
2686
+ * @function
2687
+ * @param {Object} obj Plain object or message instance
2688
+ * @param {string} prop Property name
2689
+ * @returns {boolean} `true` if considered to be present, otherwise `false`
2690
+ */
2699
2691
 
2700
2692
 
2701
- util.Buffer = function () {
2702
- try {
2703
- var Buffer = util.inquire("buffer").Buffer; // refuse to use non-node buffers if not explicitly assigned (perf reasons):
2693
+ util.isset =
2694
+ /**
2695
+ * Checks if a property on a message is considered to be present.
2696
+ * @param {Object} obj Plain object or message instance
2697
+ * @param {string} prop Property name
2698
+ * @returns {boolean} `true` if considered to be present, otherwise `false`
2699
+ */
2700
+ util.isSet = function isSet(obj, prop) {
2701
+ var value = obj[prop];
2702
+ if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins
2703
+ return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
2704
+ return false;
2705
+ };
2706
+ /**
2707
+ * Any compatible Buffer instance.
2708
+ * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
2709
+ * @interface Buffer
2710
+ * @extends Uint8Array
2711
+ */
2704
2712
 
2705
- return Buffer.prototype.utf8Write ? Buffer :
2706
- /* istanbul ignore next */
2707
- null;
2708
- } catch (e) {
2709
- /* istanbul ignore next */
2710
- return null;
2711
- }
2712
- }(); // Internal alias of or polyfull for Buffer.from.
2713
+ /**
2714
+ * Node's Buffer class if available.
2715
+ * @type {Constructor<Buffer>}
2716
+ */
2713
2717
 
2714
2718
 
2715
- util._Buffer_from = null; // Internal alias of or polyfill for Buffer.allocUnsafe.
2719
+ util.Buffer = function () {
2720
+ try {
2721
+ var Buffer = util.inquire("buffer").Buffer; // refuse to use non-node buffers if not explicitly assigned (perf reasons):
2716
2722
 
2717
- util._Buffer_allocUnsafe = null;
2718
- /**
2719
- * Creates a new buffer of whatever type supported by the environment.
2720
- * @param {number|number[]} [sizeOrArray=0] Buffer size or number array
2721
- * @returns {Uint8Array|Buffer} Buffer
2722
- */
2723
+ return Buffer.prototype.utf8Write ? Buffer :
2724
+ /* istanbul ignore next */
2725
+ null;
2726
+ } catch (e) {
2727
+ /* istanbul ignore next */
2728
+ return null;
2729
+ }
2730
+ }(); // Internal alias of or polyfull for Buffer.from.
2723
2731
 
2724
- util.newBuffer = function newBuffer(sizeOrArray) {
2725
- /* istanbul ignore next */
2726
- return typeof sizeOrArray === "number" ? util.Buffer ? util._Buffer_allocUnsafe(sizeOrArray) : new util.Array(sizeOrArray) : util.Buffer ? util._Buffer_from(sizeOrArray) : typeof Uint8Array === "undefined" ? sizeOrArray : new Uint8Array(sizeOrArray);
2727
- };
2728
- /**
2729
- * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.
2730
- * @type {Constructor<Uint8Array>}
2731
- */
2732
2732
 
2733
+ util._Buffer_from = null; // Internal alias of or polyfill for Buffer.allocUnsafe.
2733
2734
 
2734
- util.Array = typeof Uint8Array !== "undefined" ? Uint8Array
2735
- /* istanbul ignore next */
2736
- : Array;
2737
- /**
2738
- * Any compatible Long instance.
2739
- * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.
2740
- * @interface Long
2741
- * @property {number} low Low bits
2742
- * @property {number} high High bits
2743
- * @property {boolean} unsigned Whether unsigned or not
2744
- */
2735
+ util._Buffer_allocUnsafe = null;
2736
+ /**
2737
+ * Creates a new buffer of whatever type supported by the environment.
2738
+ * @param {number|number[]} [sizeOrArray=0] Buffer size or number array
2739
+ * @returns {Uint8Array|Buffer} Buffer
2740
+ */
2745
2741
 
2746
- /**
2747
- * Long.js's Long class if available.
2748
- * @type {Constructor<Long>}
2749
- */
2742
+ util.newBuffer = function newBuffer(sizeOrArray) {
2743
+ /* istanbul ignore next */
2744
+ return typeof sizeOrArray === "number" ? util.Buffer ? util._Buffer_allocUnsafe(sizeOrArray) : new util.Array(sizeOrArray) : util.Buffer ? util._Buffer_from(sizeOrArray) : typeof Uint8Array === "undefined" ? sizeOrArray : new Uint8Array(sizeOrArray);
2745
+ };
2746
+ /**
2747
+ * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.
2748
+ * @type {Constructor<Uint8Array>}
2749
+ */
2750
2750
 
2751
- util.Long =
2752
- /* istanbul ignore next */
2753
- util.global.dcodeIO &&
2754
- /* istanbul ignore next */
2755
- util.global.dcodeIO.Long ||
2756
- /* istanbul ignore next */
2757
- util.global.Long || util.inquire("long");
2758
- /**
2759
- * Regular expression used to verify 2 bit (`bool`) map keys.
2760
- * @type {RegExp}
2761
- * @const
2762
- */
2763
2751
 
2764
- util.key2Re = /^true|false|0|1$/;
2765
- /**
2766
- * Regular expression used to verify 32 bit (`int32` etc.) map keys.
2767
- * @type {RegExp}
2768
- * @const
2769
- */
2752
+ util.Array = typeof Uint8Array !== "undefined" ? Uint8Array
2753
+ /* istanbul ignore next */
2754
+ : Array;
2755
+ /**
2756
+ * Any compatible Long instance.
2757
+ * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.
2758
+ * @interface Long
2759
+ * @property {number} low Low bits
2760
+ * @property {number} high High bits
2761
+ * @property {boolean} unsigned Whether unsigned or not
2762
+ */
2770
2763
 
2771
- util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
2772
- /**
2773
- * Regular expression used to verify 64 bit (`int64` etc.) map keys.
2774
- * @type {RegExp}
2775
- * @const
2776
- */
2764
+ /**
2765
+ * Long.js's Long class if available.
2766
+ * @type {Constructor<Long>}
2767
+ */
2777
2768
 
2778
- util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
2779
- /**
2780
- * Converts a number or long to an 8 characters long hash string.
2781
- * @param {Long|number} value Value to convert
2782
- * @returns {string} Hash
2783
- */
2769
+ util.Long =
2770
+ /* istanbul ignore next */
2771
+ util.global.dcodeIO &&
2772
+ /* istanbul ignore next */
2773
+ util.global.dcodeIO.Long ||
2774
+ /* istanbul ignore next */
2775
+ util.global.Long || util.inquire("long");
2776
+ /**
2777
+ * Regular expression used to verify 2 bit (`bool`) map keys.
2778
+ * @type {RegExp}
2779
+ * @const
2780
+ */
2784
2781
 
2785
- util.longToHash = function longToHash(value) {
2786
- return value ? util.LongBits.from(value).toHash() : util.LongBits.zeroHash;
2787
- };
2788
- /**
2789
- * Converts an 8 characters long hash string to a long or number.
2790
- * @param {string} hash Hash
2791
- * @param {boolean} [unsigned=false] Whether unsigned or not
2792
- * @returns {Long|number} Original value
2793
- */
2782
+ util.key2Re = /^true|false|0|1$/;
2783
+ /**
2784
+ * Regular expression used to verify 32 bit (`int32` etc.) map keys.
2785
+ * @type {RegExp}
2786
+ * @const
2787
+ */
2794
2788
 
2789
+ util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
2790
+ /**
2791
+ * Regular expression used to verify 64 bit (`int64` etc.) map keys.
2792
+ * @type {RegExp}
2793
+ * @const
2794
+ */
2795
2795
 
2796
- util.longFromHash = function longFromHash(hash, unsigned) {
2797
- var bits = util.LongBits.fromHash(hash);
2798
- if (util.Long) return util.Long.fromBits(bits.lo, bits.hi, unsigned);
2799
- return bits.toNumber(Boolean(unsigned));
2800
- };
2801
- /**
2802
- * Merges the properties of the source object into the destination object.
2803
- * @memberof util
2804
- * @param {Object.<string,*>} dst Destination object
2805
- * @param {Object.<string,*>} src Source object
2806
- * @param {boolean} [ifNotSet=false] Merges only if the key is not already set
2807
- * @returns {Object.<string,*>} Destination object
2808
- */
2796
+ util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
2797
+ /**
2798
+ * Converts a number or long to an 8 characters long hash string.
2799
+ * @param {Long|number} value Value to convert
2800
+ * @returns {string} Hash
2801
+ */
2809
2802
 
2803
+ util.longToHash = function longToHash(value) {
2804
+ return value ? util.LongBits.from(value).toHash() : util.LongBits.zeroHash;
2805
+ };
2806
+ /**
2807
+ * Converts an 8 characters long hash string to a long or number.
2808
+ * @param {string} hash Hash
2809
+ * @param {boolean} [unsigned=false] Whether unsigned or not
2810
+ * @returns {Long|number} Original value
2811
+ */
2810
2812
 
2811
- function merge(dst, src, ifNotSet) {
2812
- // used by converters
2813
- for (var keys = Object.keys(src), i = 0; i < keys.length; ++i) if (dst[keys[i]] === undefined || !ifNotSet) dst[keys[i]] = src[keys[i]];
2814
2813
 
2815
- return dst;
2816
- }
2814
+ util.longFromHash = function longFromHash(hash, unsigned) {
2815
+ var bits = util.LongBits.fromHash(hash);
2816
+ if (util.Long) return util.Long.fromBits(bits.lo, bits.hi, unsigned);
2817
+ return bits.toNumber(Boolean(unsigned));
2818
+ };
2819
+ /**
2820
+ * Merges the properties of the source object into the destination object.
2821
+ * @memberof util
2822
+ * @param {Object.<string,*>} dst Destination object
2823
+ * @param {Object.<string,*>} src Source object
2824
+ * @param {boolean} [ifNotSet=false] Merges only if the key is not already set
2825
+ * @returns {Object.<string,*>} Destination object
2826
+ */
2817
2827
 
2818
- util.merge = merge;
2819
- /**
2820
- * Converts the first character of a string to lower case.
2821
- * @param {string} str String to convert
2822
- * @returns {string} Converted string
2823
- */
2824
2828
 
2825
- util.lcFirst = function lcFirst(str) {
2826
- return str.charAt(0).toLowerCase() + str.substring(1);
2827
- };
2828
- /**
2829
- * Creates a custom error constructor.
2830
- * @memberof util
2831
- * @param {string} name Error name
2832
- * @returns {Constructor<Error>} Custom error constructor
2833
- */
2829
+ function merge(dst, src, ifNotSet) {
2830
+ // used by converters
2831
+ for (var keys = Object.keys(src), i = 0; i < keys.length; ++i) if (dst[keys[i]] === undefined || !ifNotSet) dst[keys[i]] = src[keys[i]];
2834
2832
 
2833
+ return dst;
2834
+ }
2835
2835
 
2836
- function newError(name) {
2837
- function CustomError(message, properties) {
2838
- if (!(this instanceof CustomError)) return new CustomError(message, properties); // Error.call(this, message);
2839
- // ^ just returns a new error instance because the ctor can be called as a function
2836
+ util.merge = merge;
2837
+ /**
2838
+ * Converts the first character of a string to lower case.
2839
+ * @param {string} str String to convert
2840
+ * @returns {string} Converted string
2841
+ */
2840
2842
 
2841
- Object.defineProperty(this, "message", {
2842
- get: function () {
2843
- return message;
2844
- }
2845
- });
2846
- /* istanbul ignore next */
2843
+ util.lcFirst = function lcFirst(str) {
2844
+ return str.charAt(0).toLowerCase() + str.substring(1);
2845
+ };
2846
+ /**
2847
+ * Creates a custom error constructor.
2848
+ * @memberof util
2849
+ * @param {string} name Error name
2850
+ * @returns {Constructor<Error>} Custom error constructor
2851
+ */
2847
2852
 
2848
- if (Error.captureStackTrace) // node
2849
- Error.captureStackTrace(this, CustomError);else Object.defineProperty(this, "stack", {
2850
- value: new Error().stack || ""
2851
- });
2852
- if (properties) merge(this, properties);
2853
- }
2854
2853
 
2855
- (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError;
2856
- Object.defineProperty(CustomError.prototype, "name", {
2857
- get: function () {
2858
- return name;
2859
- }
2860
- });
2854
+ function newError(name) {
2855
+ function CustomError(message, properties) {
2856
+ if (!(this instanceof CustomError)) return new CustomError(message, properties); // Error.call(this, message);
2857
+ // ^ just returns a new error instance because the ctor can be called as a function
2861
2858
 
2862
- CustomError.prototype.toString = function toString() {
2863
- return this.name + ": " + this.message;
2864
- };
2859
+ Object.defineProperty(this, "message", {
2860
+ get: function () {
2861
+ return message;
2862
+ }
2863
+ });
2864
+ /* istanbul ignore next */
2865
2865
 
2866
- return CustomError;
2867
- }
2866
+ if (Error.captureStackTrace) // node
2867
+ Error.captureStackTrace(this, CustomError);else Object.defineProperty(this, "stack", {
2868
+ value: new Error().stack || ""
2869
+ });
2870
+ if (properties) merge(this, properties);
2871
+ }
2868
2872
 
2869
- util.newError = newError;
2870
- /**
2871
- * Constructs a new protocol error.
2872
- * @classdesc Error subclass indicating a protocol specifc error.
2873
- * @memberof util
2874
- * @extends Error
2875
- * @template T extends Message<T>
2876
- * @constructor
2877
- * @param {string} message Error message
2878
- * @param {Object.<string,*>} [properties] Additional properties
2879
- * @example
2880
- * try {
2881
- * MyMessage.decode(someBuffer); // throws if required fields are missing
2882
- * } catch (e) {
2883
- * if (e instanceof ProtocolError && e.instance)
2884
- * console.log("decoded so far: " + JSON.stringify(e.instance));
2885
- * }
2886
- */
2873
+ CustomError.prototype = Object.create(Error.prototype, {
2874
+ constructor: {
2875
+ value: CustomError,
2876
+ writable: true,
2877
+ enumerable: false,
2878
+ configurable: true
2879
+ },
2880
+ name: {
2881
+ get() {
2882
+ return name;
2883
+ },
2887
2884
 
2888
- util.ProtocolError = newError("ProtocolError");
2889
- /**
2890
- * So far decoded message instance.
2891
- * @name util.ProtocolError#instance
2892
- * @type {Message<T>}
2893
- */
2885
+ set: undefined,
2886
+ enumerable: false,
2887
+ // configurable: false would accurately preserve the behavior of
2888
+ // the original, but I'm guessing that was not intentional.
2889
+ // For an actual error subclass, this property would
2890
+ // be configurable.
2891
+ configurable: true
2892
+ },
2893
+ toString: {
2894
+ value() {
2895
+ return this.name + ": " + this.message;
2896
+ },
2894
2897
 
2895
- /**
2896
- * A OneOf getter as returned by {@link util.oneOfGetter}.
2897
- * @typedef OneOfGetter
2898
- * @type {function}
2899
- * @returns {string|undefined} Set field name, if any
2900
- */
2898
+ writable: true,
2899
+ enumerable: false,
2900
+ configurable: true
2901
+ }
2902
+ });
2903
+ return CustomError;
2904
+ }
2901
2905
 
2902
- /**
2903
- * Builds a getter for a oneof's present field name.
2904
- * @param {string[]} fieldNames Field names
2905
- * @returns {OneOfGetter} Unbound getter
2906
- */
2906
+ util.newError = newError;
2907
+ /**
2908
+ * Constructs a new protocol error.
2909
+ * @classdesc Error subclass indicating a protocol specifc error.
2910
+ * @memberof util
2911
+ * @extends Error
2912
+ * @template T extends Message<T>
2913
+ * @constructor
2914
+ * @param {string} message Error message
2915
+ * @param {Object.<string,*>} [properties] Additional properties
2916
+ * @example
2917
+ * try {
2918
+ * MyMessage.decode(someBuffer); // throws if required fields are missing
2919
+ * } catch (e) {
2920
+ * if (e instanceof ProtocolError && e.instance)
2921
+ * console.log("decoded so far: " + JSON.stringify(e.instance));
2922
+ * }
2923
+ */
2907
2924
 
2908
- util.oneOfGetter = function getOneOf(fieldNames) {
2909
- var fieldMap = {};
2925
+ util.ProtocolError = newError("ProtocolError");
2926
+ /**
2927
+ * So far decoded message instance.
2928
+ * @name util.ProtocolError#instance
2929
+ * @type {Message<T>}
2930
+ */
2910
2931
 
2911
- for (var i = 0; i < fieldNames.length; ++i) fieldMap[fieldNames[i]] = 1;
2912
2932
  /**
2933
+ * A OneOf getter as returned by {@link util.oneOfGetter}.
2934
+ * @typedef OneOfGetter
2935
+ * @type {function}
2913
2936
  * @returns {string|undefined} Set field name, if any
2914
- * @this Object
2915
- * @ignore
2916
2937
  */
2917
2938
 
2939
+ /**
2940
+ * Builds a getter for a oneof's present field name.
2941
+ * @param {string[]} fieldNames Field names
2942
+ * @returns {OneOfGetter} Unbound getter
2943
+ */
2918
2944
 
2919
- return function () {
2920
- // eslint-disable-line consistent-return
2921
- for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i) if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null) return keys[i];
2922
- };
2923
- };
2924
- /**
2925
- * A OneOf setter as returned by {@link util.oneOfSetter}.
2926
- * @typedef OneOfSetter
2927
- * @type {function}
2928
- * @param {string|undefined} value Field name
2929
- * @returns {undefined}
2930
- */
2945
+ util.oneOfGetter = function getOneOf(fieldNames) {
2946
+ var fieldMap = {};
2931
2947
 
2932
- /**
2933
- * Builds a setter for a oneof's present field name.
2934
- * @param {string[]} fieldNames Field names
2935
- * @returns {OneOfSetter} Unbound setter
2936
- */
2948
+ for (var i = 0; i < fieldNames.length; ++i) fieldMap[fieldNames[i]] = 1;
2949
+ /**
2950
+ * @returns {string|undefined} Set field name, if any
2951
+ * @this Object
2952
+ * @ignore
2953
+ */
2937
2954
 
2938
2955
 
2939
- util.oneOfSetter = function setOneOf(fieldNames) {
2956
+ return function () {
2957
+ // eslint-disable-line consistent-return
2958
+ for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i) if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null) return keys[i];
2959
+ };
2960
+ };
2940
2961
  /**
2941
- * @param {string} name Field name
2962
+ * A OneOf setter as returned by {@link util.oneOfSetter}.
2963
+ * @typedef OneOfSetter
2964
+ * @type {function}
2965
+ * @param {string|undefined} value Field name
2942
2966
  * @returns {undefined}
2943
- * @this Object
2944
- * @ignore
2945
2967
  */
2946
- return function (name) {
2947
- for (var i = 0; i < fieldNames.length; ++i) if (fieldNames[i] !== name) delete this[fieldNames[i]];
2968
+
2969
+ /**
2970
+ * Builds a setter for a oneof's present field name.
2971
+ * @param {string[]} fieldNames Field names
2972
+ * @returns {OneOfSetter} Unbound setter
2973
+ */
2974
+
2975
+
2976
+ util.oneOfSetter = function setOneOf(fieldNames) {
2977
+ /**
2978
+ * @param {string} name Field name
2979
+ * @returns {undefined}
2980
+ * @this Object
2981
+ * @ignore
2982
+ */
2983
+ return function (name) {
2984
+ for (var i = 0; i < fieldNames.length; ++i) if (fieldNames[i] !== name) delete this[fieldNames[i]];
2985
+ };
2948
2986
  };
2949
- };
2950
- /**
2951
- * Default conversion options used for {@link Message#toJSON} implementations.
2952
- *
2953
- * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:
2954
- *
2955
- * - Longs become strings
2956
- * - Enums become string keys
2957
- * - Bytes become base64 encoded strings
2958
- * - (Sub-)Messages become plain objects
2959
- * - Maps become plain objects with all string keys
2960
- * - Repeated fields become arrays
2961
- * - NaN and Infinity for float and double fields become strings
2962
- *
2963
- * @type {IConversionOptions}
2964
- * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json
2965
- */
2987
+ /**
2988
+ * Default conversion options used for {@link Message#toJSON} implementations.
2989
+ *
2990
+ * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:
2991
+ *
2992
+ * - Longs become strings
2993
+ * - Enums become string keys
2994
+ * - Bytes become base64 encoded strings
2995
+ * - (Sub-)Messages become plain objects
2996
+ * - Maps become plain objects with all string keys
2997
+ * - Repeated fields become arrays
2998
+ * - NaN and Infinity for float and double fields become strings
2999
+ *
3000
+ * @type {IConversionOptions}
3001
+ * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json
3002
+ */
2966
3003
 
2967
3004
 
2968
- util.toJSONOptions = {
2969
- longs: String,
2970
- enums: String,
2971
- bytes: String,
2972
- json: true
2973
- }; // Sets up buffer utility according to the environment (called in index-minimal)
3005
+ util.toJSONOptions = {
3006
+ longs: String,
3007
+ enums: String,
3008
+ bytes: String,
3009
+ json: true
3010
+ }; // Sets up buffer utility according to the environment (called in index-minimal)
2974
3011
 
2975
- util._configure = function () {
2976
- var Buffer = util.Buffer;
2977
- /* istanbul ignore if */
3012
+ util._configure = function () {
3013
+ var Buffer = util.Buffer;
3014
+ /* istanbul ignore if */
2978
3015
 
2979
- if (!Buffer) {
2980
- util._Buffer_from = util._Buffer_allocUnsafe = null;
2981
- return;
2982
- } // because node 4.x buffers are incompatible & immutable
2983
- // see: https://github.com/dcodeIO/protobuf.js/pull/665
3016
+ if (!Buffer) {
3017
+ util._Buffer_from = util._Buffer_allocUnsafe = null;
3018
+ return;
3019
+ } // because node 4.x buffers are incompatible & immutable
3020
+ // see: https://github.com/dcodeIO/protobuf.js/pull/665
2984
3021
 
2985
3022
 
2986
- util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||
2987
- /* istanbul ignore next */
2988
- function Buffer_from(value, encoding) {
2989
- return new Buffer(value, encoding);
2990
- };
3023
+ util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||
3024
+ /* istanbul ignore next */
3025
+ function Buffer_from(value, encoding) {
3026
+ return new Buffer(value, encoding);
3027
+ };
2991
3028
 
2992
- util._Buffer_allocUnsafe = Buffer.allocUnsafe ||
2993
- /* istanbul ignore next */
2994
- function Buffer_allocUnsafe(size) {
2995
- return new Buffer(size);
3029
+ util._Buffer_allocUnsafe = Buffer.allocUnsafe ||
3030
+ /* istanbul ignore next */
3031
+ function Buffer_allocUnsafe(size) {
3032
+ return new Buffer(size);
3033
+ };
2996
3034
  };
2997
- };
2998
- })(minimal$1);
3035
+ })(minimal);
3036
+
3037
+ return minimal;
3038
+ }
2999
3039
 
3000
3040
  var writer$2 = Writer$1;
3001
- var util$4 = minimal$1;
3041
+ var util$4 = requireMinimal();
3002
3042
  var BufferWriter$1; // cyclic
3003
3043
 
3004
3044
  var LongBits$1 = util$4.LongBits,
@@ -3478,7 +3518,7 @@ var writer_buffer = BufferWriter; // extends Writer
3478
3518
 
3479
3519
  var Writer = writer$2;
3480
3520
  (BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
3481
- var util$3 = minimal$1;
3521
+ var util$3 = requireMinimal();
3482
3522
  /**
3483
3523
  * Constructs a new buffer writer instance.
3484
3524
  * @classdesc Wire format writer using node buffers.
@@ -3548,7 +3588,7 @@ BufferWriter.prototype.string = function write_string_buffer(value) {
3548
3588
  BufferWriter._configure();
3549
3589
 
3550
3590
  var reader = Reader$1;
3551
- var util$2 = minimal$1;
3591
+ var util$2 = requireMinimal();
3552
3592
  var BufferReader$1; // cyclic
3553
3593
 
3554
3594
  var LongBits = util$2.LongBits,
@@ -3961,7 +4001,7 @@ var reader_buffer = BufferReader; // extends Reader
3961
4001
 
3962
4002
  var Reader = reader;
3963
4003
  (BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
3964
- var util$1 = minimal$1;
4004
+ var util$1 = requireMinimal();
3965
4005
  /**
3966
4006
  * Constructs a new buffer reader instance.
3967
4007
  * @classdesc Wire format reader using node buffers.
@@ -4006,7 +4046,7 @@ BufferReader._configure();
4006
4046
  var rpc = {};
4007
4047
 
4008
4048
  var service = Service;
4009
- var util = minimal$1; // Extends EventEmitter
4049
+ var util = requireMinimal(); // Extends EventEmitter
4010
4050
 
4011
4051
  (Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
4012
4052
  /**
@@ -4198,7 +4238,7 @@ var roots = {};
4198
4238
  protobuf.Reader = reader;
4199
4239
  protobuf.BufferReader = reader_buffer; // Utility
4200
4240
 
4201
- protobuf.util = minimal$1;
4241
+ protobuf.util = requireMinimal();
4202
4242
  protobuf.rpc = rpc;
4203
4243
  protobuf.roots = roots;
4204
4244
  protobuf.configure = configure;
@@ -4221,7 +4261,10 @@ var roots = {};
4221
4261
  configure();
4222
4262
  })(indexMinimal);
4223
4263
 
4224
- var minimal = indexMinimal;
4264
+ (function (module) {
4265
+
4266
+ module.exports = indexMinimal;
4267
+ })(minimal$1);
4225
4268
 
4226
4269
  /* eslint-disable */
4227
4270
 
@@ -4233,10 +4276,10 @@ var globalThis$2 = (() => {
4233
4276
  throw 'Unable to locate global object';
4234
4277
  })();
4235
4278
 
4236
- if (minimal.util.Long !== long) {
4237
- minimal.util.Long = long;
4279
+ if (minimal$1.exports.util.Long !== long) {
4280
+ minimal$1.exports.util.Long = long;
4238
4281
 
4239
- minimal.configure();
4282
+ minimal$1.exports.configure();
4240
4283
  }
4241
4284
 
4242
4285
  /* eslint-disable */
@@ -4749,7 +4792,7 @@ function createBaseRoom() {
4749
4792
 
4750
4793
  const Room$1 = {
4751
4794
  encode(message) {
4752
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
4795
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
4753
4796
 
4754
4797
  if (message.sid !== '') {
4755
4798
  writer.uint32(10).string(message.sid);
@@ -4795,7 +4838,7 @@ const Room$1 = {
4795
4838
  },
4796
4839
 
4797
4840
  decode(input, length) {
4798
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
4841
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
4799
4842
  let end = length === undefined ? reader.len : reader.pos + length;
4800
4843
  const message = createBaseRoom();
4801
4844
 
@@ -4916,7 +4959,7 @@ function createBaseCodec() {
4916
4959
 
4917
4960
  const Codec = {
4918
4961
  encode(message) {
4919
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
4962
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
4920
4963
 
4921
4964
  if (message.mime !== '') {
4922
4965
  writer.uint32(10).string(message.mime);
@@ -4930,7 +4973,7 @@ const Codec = {
4930
4973
  },
4931
4974
 
4932
4975
  decode(input, length) {
4933
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
4976
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
4934
4977
  let end = length === undefined ? reader.len : reader.pos + length;
4935
4978
  const message = createBaseCodec();
4936
4979
 
@@ -4992,7 +5035,7 @@ function createBaseParticipantPermission() {
4992
5035
 
4993
5036
  const ParticipantPermission = {
4994
5037
  encode(message) {
4995
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
5038
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
4996
5039
 
4997
5040
  if (message.canSubscribe === true) {
4998
5041
  writer.uint32(8).bool(message.canSubscribe);
@@ -5018,7 +5061,7 @@ const ParticipantPermission = {
5018
5061
  },
5019
5062
 
5020
5063
  decode(input, length) {
5021
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
5064
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
5022
5065
  let end = length === undefined ? reader.len : reader.pos + length;
5023
5066
  const message = createBaseParticipantPermission();
5024
5067
 
@@ -5107,7 +5150,7 @@ function createBaseParticipantInfo() {
5107
5150
 
5108
5151
  const ParticipantInfo = {
5109
5152
  encode(message) {
5110
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
5153
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
5111
5154
 
5112
5155
  if (message.sid !== '') {
5113
5156
  writer.uint32(10).string(message.sid);
@@ -5157,7 +5200,7 @@ const ParticipantInfo = {
5157
5200
  },
5158
5201
 
5159
5202
  decode(input, length) {
5160
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
5203
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
5161
5204
  let end = length === undefined ? reader.len : reader.pos + length;
5162
5205
  const message = createBaseParticipantInfo();
5163
5206
 
@@ -5287,7 +5330,7 @@ function createBaseSimulcastCodecInfo() {
5287
5330
 
5288
5331
  const SimulcastCodecInfo = {
5289
5332
  encode(message) {
5290
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
5333
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
5291
5334
 
5292
5335
  if (message.mimeType !== '') {
5293
5336
  writer.uint32(10).string(message.mimeType);
@@ -5309,7 +5352,7 @@ const SimulcastCodecInfo = {
5309
5352
  },
5310
5353
 
5311
5354
  decode(input, length) {
5312
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
5355
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
5313
5356
  let end = length === undefined ? reader.len : reader.pos + length;
5314
5357
  const message = createBaseSimulcastCodecInfo();
5315
5358
 
@@ -5399,7 +5442,7 @@ function createBaseTrackInfo() {
5399
5442
 
5400
5443
  const TrackInfo = {
5401
5444
  encode(message) {
5402
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
5445
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
5403
5446
 
5404
5447
  if (message.sid !== '') {
5405
5448
  writer.uint32(10).string(message.sid);
@@ -5457,7 +5500,7 @@ const TrackInfo = {
5457
5500
  },
5458
5501
 
5459
5502
  decode(input, length) {
5460
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
5503
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
5461
5504
  let end = length === undefined ? reader.len : reader.pos + length;
5462
5505
  const message = createBaseTrackInfo();
5463
5506
 
@@ -5608,7 +5651,7 @@ function createBaseVideoLayer() {
5608
5651
 
5609
5652
  const VideoLayer = {
5610
5653
  encode(message) {
5611
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
5654
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
5612
5655
 
5613
5656
  if (message.quality !== 0) {
5614
5657
  writer.uint32(8).int32(message.quality);
@@ -5634,7 +5677,7 @@ const VideoLayer = {
5634
5677
  },
5635
5678
 
5636
5679
  decode(input, length) {
5637
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
5680
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
5638
5681
  let end = length === undefined ? reader.len : reader.pos + length;
5639
5682
  const message = createBaseVideoLayer();
5640
5683
 
@@ -5715,7 +5758,7 @@ function createBaseDataPacket() {
5715
5758
 
5716
5759
  const DataPacket = {
5717
5760
  encode(message) {
5718
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
5761
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
5719
5762
 
5720
5763
  if (message.kind !== 0) {
5721
5764
  writer.uint32(8).int32(message.kind);
@@ -5733,7 +5776,7 @@ const DataPacket = {
5733
5776
  },
5734
5777
 
5735
5778
  decode(input, length) {
5736
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
5779
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
5737
5780
  let end = length === undefined ? reader.len : reader.pos + length;
5738
5781
  const message = createBaseDataPacket();
5739
5782
 
@@ -5798,7 +5841,7 @@ function createBaseActiveSpeakerUpdate() {
5798
5841
 
5799
5842
  const ActiveSpeakerUpdate = {
5800
5843
  encode(message) {
5801
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
5844
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
5802
5845
 
5803
5846
  for (const v of message.speakers) {
5804
5847
  SpeakerInfo.encode(v, writer.uint32(10).fork()).ldelim();
@@ -5808,7 +5851,7 @@ const ActiveSpeakerUpdate = {
5808
5851
  },
5809
5852
 
5810
5853
  decode(input, length) {
5811
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
5854
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
5812
5855
  let end = length === undefined ? reader.len : reader.pos + length;
5813
5856
  const message = createBaseActiveSpeakerUpdate();
5814
5857
 
@@ -5867,7 +5910,7 @@ function createBaseSpeakerInfo() {
5867
5910
 
5868
5911
  const SpeakerInfo = {
5869
5912
  encode(message) {
5870
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
5913
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
5871
5914
 
5872
5915
  if (message.sid !== '') {
5873
5916
  writer.uint32(10).string(message.sid);
@@ -5885,7 +5928,7 @@ const SpeakerInfo = {
5885
5928
  },
5886
5929
 
5887
5930
  decode(input, length) {
5888
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
5931
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
5889
5932
  let end = length === undefined ? reader.len : reader.pos + length;
5890
5933
  const message = createBaseSpeakerInfo();
5891
5934
 
@@ -5952,7 +5995,7 @@ function createBaseUserPacket() {
5952
5995
 
5953
5996
  const UserPacket = {
5954
5997
  encode(message) {
5955
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
5998
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
5956
5999
 
5957
6000
  if (message.participantSid !== '') {
5958
6001
  writer.uint32(10).string(message.participantSid);
@@ -5970,7 +6013,7 @@ const UserPacket = {
5970
6013
  },
5971
6014
 
5972
6015
  decode(input, length) {
5973
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
6016
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
5974
6017
  let end = length === undefined ? reader.len : reader.pos + length;
5975
6018
  const message = createBaseUserPacket();
5976
6019
 
@@ -6042,7 +6085,7 @@ function createBaseParticipantTracks() {
6042
6085
 
6043
6086
  const ParticipantTracks = {
6044
6087
  encode(message) {
6045
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
6088
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
6046
6089
 
6047
6090
  if (message.participantSid !== '') {
6048
6091
  writer.uint32(10).string(message.participantSid);
@@ -6056,7 +6099,7 @@ const ParticipantTracks = {
6056
6099
  },
6057
6100
 
6058
6101
  decode(input, length) {
6059
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
6102
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
6060
6103
  let end = length === undefined ? reader.len : reader.pos + length;
6061
6104
  const message = createBaseParticipantTracks();
6062
6105
 
@@ -6128,7 +6171,7 @@ function createBaseClientInfo() {
6128
6171
 
6129
6172
  const ClientInfo = {
6130
6173
  encode(message) {
6131
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
6174
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
6132
6175
 
6133
6176
  if (message.sdk !== 0) {
6134
6177
  writer.uint32(8).int32(message.sdk);
@@ -6170,7 +6213,7 @@ const ClientInfo = {
6170
6213
  },
6171
6214
 
6172
6215
  decode(input, length) {
6173
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
6216
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
6174
6217
  let end = length === undefined ? reader.len : reader.pos + length;
6175
6218
  const message = createBaseClientInfo();
6176
6219
 
@@ -6280,7 +6323,7 @@ function createBaseClientConfiguration() {
6280
6323
 
6281
6324
  const ClientConfiguration = {
6282
6325
  encode(message) {
6283
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
6326
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
6284
6327
 
6285
6328
  if (message.video !== undefined) {
6286
6329
  VideoConfiguration.encode(message.video, writer.uint32(10).fork()).ldelim();
@@ -6302,7 +6345,7 @@ const ClientConfiguration = {
6302
6345
  },
6303
6346
 
6304
6347
  decode(input, length) {
6305
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
6348
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
6306
6349
  let end = length === undefined ? reader.len : reader.pos + length;
6307
6350
  const message = createBaseClientConfiguration();
6308
6351
 
@@ -6374,7 +6417,7 @@ function createBaseVideoConfiguration() {
6374
6417
 
6375
6418
  const VideoConfiguration = {
6376
6419
  encode(message) {
6377
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
6420
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
6378
6421
 
6379
6422
  if (message.hardwareEncoder !== 0) {
6380
6423
  writer.uint32(8).int32(message.hardwareEncoder);
@@ -6384,7 +6427,7 @@ const VideoConfiguration = {
6384
6427
  },
6385
6428
 
6386
6429
  decode(input, length) {
6387
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
6430
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
6388
6431
  let end = length === undefined ? reader.len : reader.pos + length;
6389
6432
  const message = createBaseVideoConfiguration();
6390
6433
 
@@ -6435,7 +6478,7 @@ function createBaseDisabledCodecs() {
6435
6478
 
6436
6479
  const DisabledCodecs = {
6437
6480
  encode(message) {
6438
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
6481
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
6439
6482
 
6440
6483
  for (const v of message.codecs) {
6441
6484
  Codec.encode(v, writer.uint32(10).fork()).ldelim();
@@ -6445,7 +6488,7 @@ const DisabledCodecs = {
6445
6488
  },
6446
6489
 
6447
6490
  decode(input, length) {
6448
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
6491
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
6449
6492
  let end = length === undefined ? reader.len : reader.pos + length;
6450
6493
  const message = createBaseDisabledCodecs();
6451
6494
 
@@ -6535,16 +6578,65 @@ function longToNumber(long) {
6535
6578
  return long.toNumber();
6536
6579
  }
6537
6580
 
6538
- if (minimal.util.Long !== long) {
6539
- minimal.util.Long = long;
6581
+ if (minimal$1.exports.util.Long !== long) {
6582
+ minimal$1.exports.util.Long = long;
6540
6583
 
6541
- minimal.configure();
6584
+ minimal$1.exports.configure();
6542
6585
  }
6543
6586
 
6544
6587
  function isSet$1(value) {
6545
6588
  return value !== null && value !== undefined;
6546
6589
  }
6547
6590
 
6591
+ function _asyncIterator(iterable) {
6592
+ var method,
6593
+ async,
6594
+ sync,
6595
+ retry = 2;
6596
+
6597
+ for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) {
6598
+ if (async && null != (method = iterable[async])) return method.call(iterable);
6599
+ if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
6600
+ async = "@@asyncIterator", sync = "@@iterator";
6601
+ }
6602
+
6603
+ throw new TypeError("Object is not async iterable");
6604
+ }
6605
+
6606
+ function AsyncFromSyncIterator(s) {
6607
+ function AsyncFromSyncIteratorContinuation(r) {
6608
+ if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
6609
+ var done = r.done;
6610
+ return Promise.resolve(r.value).then(function (value) {
6611
+ return {
6612
+ value: value,
6613
+ done: done
6614
+ };
6615
+ });
6616
+ }
6617
+
6618
+ return AsyncFromSyncIterator = function (s) {
6619
+ this.s = s, this.n = s.next;
6620
+ }, AsyncFromSyncIterator.prototype = {
6621
+ s: null,
6622
+ n: null,
6623
+ next: function () {
6624
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
6625
+ },
6626
+ return: function (value) {
6627
+ var ret = this.s.return;
6628
+ return void 0 === ret ? Promise.resolve({
6629
+ value: value,
6630
+ done: !0
6631
+ }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
6632
+ },
6633
+ throw: function (value) {
6634
+ var thr = this.s.return;
6635
+ return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
6636
+ }
6637
+ }, new AsyncFromSyncIterator(s);
6638
+ }
6639
+
6548
6640
  function ownKeys(object, enumerableOnly) {
6549
6641
  var keys = Object.keys(object);
6550
6642
 
@@ -6715,7 +6807,7 @@ function createBaseSignalRequest() {
6715
6807
 
6716
6808
  const SignalRequest = {
6717
6809
  encode(message) {
6718
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
6810
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
6719
6811
 
6720
6812
  if (message.offer !== undefined) {
6721
6813
  SessionDescription.encode(message.offer, writer.uint32(10).fork()).ldelim();
@@ -6769,7 +6861,7 @@ const SignalRequest = {
6769
6861
  },
6770
6862
 
6771
6863
  decode(input, length) {
6772
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
6864
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
6773
6865
  let end = length === undefined ? reader.len : reader.pos + length;
6774
6866
  const message = createBaseSignalRequest();
6775
6867
 
@@ -6910,7 +7002,7 @@ function createBaseSignalResponse() {
6910
7002
 
6911
7003
  const SignalResponse = {
6912
7004
  encode(message) {
6913
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
7005
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
6914
7006
 
6915
7007
  if (message.join !== undefined) {
6916
7008
  JoinResponse.encode(message.join, writer.uint32(10).fork()).ldelim();
@@ -6980,7 +7072,7 @@ const SignalResponse = {
6980
7072
  },
6981
7073
 
6982
7074
  decode(input, length) {
6983
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
7075
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
6984
7076
  let end = length === undefined ? reader.len : reader.pos + length;
6985
7077
  const message = createBaseSignalResponse();
6986
7078
 
@@ -7138,7 +7230,7 @@ function createBaseSimulcastCodec() {
7138
7230
 
7139
7231
  const SimulcastCodec = {
7140
7232
  encode(message) {
7141
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
7233
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
7142
7234
 
7143
7235
  if (message.codec !== '') {
7144
7236
  writer.uint32(10).string(message.codec);
@@ -7156,7 +7248,7 @@ const SimulcastCodec = {
7156
7248
  },
7157
7249
 
7158
7250
  decode(input, length) {
7159
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
7251
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
7160
7252
  let end = length === undefined ? reader.len : reader.pos + length;
7161
7253
  const message = createBaseSimulcastCodec();
7162
7254
 
@@ -7231,7 +7323,7 @@ function createBaseAddTrackRequest() {
7231
7323
 
7232
7324
  const AddTrackRequest = {
7233
7325
  encode(message) {
7234
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
7326
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
7235
7327
 
7236
7328
  if (message.cid !== '') {
7237
7329
  writer.uint32(10).string(message.cid);
@@ -7281,7 +7373,7 @@ const AddTrackRequest = {
7281
7373
  },
7282
7374
 
7283
7375
  decode(input, length) {
7284
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
7376
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
7285
7377
  let end = length === undefined ? reader.len : reader.pos + length;
7286
7378
  const message = createBaseAddTrackRequest();
7287
7379
 
@@ -7414,7 +7506,7 @@ function createBaseTrickleRequest() {
7414
7506
 
7415
7507
  const TrickleRequest = {
7416
7508
  encode(message) {
7417
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
7509
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
7418
7510
 
7419
7511
  if (message.candidateInit !== '') {
7420
7512
  writer.uint32(10).string(message.candidateInit);
@@ -7428,7 +7520,7 @@ const TrickleRequest = {
7428
7520
  },
7429
7521
 
7430
7522
  decode(input, length) {
7431
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
7523
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
7432
7524
  let end = length === undefined ? reader.len : reader.pos + length;
7433
7525
  const message = createBaseTrickleRequest();
7434
7526
 
@@ -7487,7 +7579,7 @@ function createBaseMuteTrackRequest() {
7487
7579
 
7488
7580
  const MuteTrackRequest = {
7489
7581
  encode(message) {
7490
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
7582
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
7491
7583
 
7492
7584
  if (message.sid !== '') {
7493
7585
  writer.uint32(10).string(message.sid);
@@ -7501,7 +7593,7 @@ const MuteTrackRequest = {
7501
7593
  },
7502
7594
 
7503
7595
  decode(input, length) {
7504
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
7596
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
7505
7597
  let end = length === undefined ? reader.len : reader.pos + length;
7506
7598
  const message = createBaseMuteTrackRequest();
7507
7599
 
@@ -7567,7 +7659,7 @@ function createBaseJoinResponse() {
7567
7659
 
7568
7660
  const JoinResponse = {
7569
7661
  encode(message) {
7570
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
7662
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
7571
7663
 
7572
7664
  if (message.room !== undefined) {
7573
7665
  Room$1.encode(message.room, writer.uint32(10).fork()).ldelim();
@@ -7609,7 +7701,7 @@ const JoinResponse = {
7609
7701
  },
7610
7702
 
7611
7703
  decode(input, length) {
7612
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
7704
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
7613
7705
  let end = length === undefined ? reader.len : reader.pos + length;
7614
7706
  const message = createBaseJoinResponse();
7615
7707
 
@@ -7729,7 +7821,7 @@ function createBaseTrackPublishedResponse() {
7729
7821
 
7730
7822
  const TrackPublishedResponse = {
7731
7823
  encode(message) {
7732
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
7824
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
7733
7825
 
7734
7826
  if (message.cid !== '') {
7735
7827
  writer.uint32(10).string(message.cid);
@@ -7743,7 +7835,7 @@ const TrackPublishedResponse = {
7743
7835
  },
7744
7836
 
7745
7837
  decode(input, length) {
7746
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
7838
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
7747
7839
  let end = length === undefined ? reader.len : reader.pos + length;
7748
7840
  const message = createBaseTrackPublishedResponse();
7749
7841
 
@@ -7801,7 +7893,7 @@ function createBaseTrackUnpublishedResponse() {
7801
7893
 
7802
7894
  const TrackUnpublishedResponse = {
7803
7895
  encode(message) {
7804
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
7896
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
7805
7897
 
7806
7898
  if (message.trackSid !== '') {
7807
7899
  writer.uint32(10).string(message.trackSid);
@@ -7811,7 +7903,7 @@ const TrackUnpublishedResponse = {
7811
7903
  },
7812
7904
 
7813
7905
  decode(input, length) {
7814
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
7906
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
7815
7907
  let end = length === undefined ? reader.len : reader.pos + length;
7816
7908
  const message = createBaseTrackUnpublishedResponse();
7817
7909
 
@@ -7863,7 +7955,7 @@ function createBaseSessionDescription() {
7863
7955
 
7864
7956
  const SessionDescription = {
7865
7957
  encode(message) {
7866
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
7958
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
7867
7959
 
7868
7960
  if (message.type !== '') {
7869
7961
  writer.uint32(10).string(message.type);
@@ -7877,7 +7969,7 @@ const SessionDescription = {
7877
7969
  },
7878
7970
 
7879
7971
  decode(input, length) {
7880
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
7972
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
7881
7973
  let end = length === undefined ? reader.len : reader.pos + length;
7882
7974
  const message = createBaseSessionDescription();
7883
7975
 
@@ -7935,7 +8027,7 @@ function createBaseParticipantUpdate() {
7935
8027
 
7936
8028
  const ParticipantUpdate = {
7937
8029
  encode(message) {
7938
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8030
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
7939
8031
 
7940
8032
  for (const v of message.participants) {
7941
8033
  ParticipantInfo.encode(v, writer.uint32(10).fork()).ldelim();
@@ -7945,7 +8037,7 @@ const ParticipantUpdate = {
7945
8037
  },
7946
8038
 
7947
8039
  decode(input, length) {
7948
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8040
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
7949
8041
  let end = length === undefined ? reader.len : reader.pos + length;
7950
8042
  const message = createBaseParticipantUpdate();
7951
8043
 
@@ -8004,7 +8096,7 @@ function createBaseUpdateSubscription() {
8004
8096
 
8005
8097
  const UpdateSubscription = {
8006
8098
  encode(message) {
8007
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8099
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8008
8100
 
8009
8101
  for (const v of message.trackSids) {
8010
8102
  writer.uint32(10).string(v);
@@ -8022,7 +8114,7 @@ const UpdateSubscription = {
8022
8114
  },
8023
8115
 
8024
8116
  decode(input, length) {
8025
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8117
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8026
8118
  let end = length === undefined ? reader.len : reader.pos + length;
8027
8119
  const message = createBaseUpdateSubscription();
8028
8120
 
@@ -8103,7 +8195,7 @@ function createBaseUpdateTrackSettings() {
8103
8195
 
8104
8196
  const UpdateTrackSettings = {
8105
8197
  encode(message) {
8106
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8198
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8107
8199
 
8108
8200
  for (const v of message.trackSids) {
8109
8201
  writer.uint32(10).string(v);
@@ -8129,7 +8221,7 @@ const UpdateTrackSettings = {
8129
8221
  },
8130
8222
 
8131
8223
  decode(input, length) {
8132
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8224
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8133
8225
  let end = length === undefined ? reader.len : reader.pos + length;
8134
8226
  const message = createBaseUpdateTrackSettings();
8135
8227
 
@@ -8215,7 +8307,7 @@ function createBaseLeaveRequest() {
8215
8307
 
8216
8308
  const LeaveRequest = {
8217
8309
  encode(message) {
8218
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8310
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8219
8311
 
8220
8312
  if (message.canReconnect === true) {
8221
8313
  writer.uint32(8).bool(message.canReconnect);
@@ -8229,7 +8321,7 @@ const LeaveRequest = {
8229
8321
  },
8230
8322
 
8231
8323
  decode(input, length) {
8232
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8324
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8233
8325
  let end = length === undefined ? reader.len : reader.pos + length;
8234
8326
  const message = createBaseLeaveRequest();
8235
8327
 
@@ -8288,7 +8380,7 @@ function createBaseUpdateVideoLayers() {
8288
8380
 
8289
8381
  const UpdateVideoLayers = {
8290
8382
  encode(message) {
8291
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8383
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8292
8384
 
8293
8385
  if (message.trackSid !== '') {
8294
8386
  writer.uint32(10).string(message.trackSid);
@@ -8302,7 +8394,7 @@ const UpdateVideoLayers = {
8302
8394
  },
8303
8395
 
8304
8396
  decode(input, length) {
8305
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8397
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8306
8398
  let end = length === undefined ? reader.len : reader.pos + length;
8307
8399
  const message = createBaseUpdateVideoLayers();
8308
8400
 
@@ -8368,7 +8460,7 @@ function createBaseICEServer() {
8368
8460
 
8369
8461
  const ICEServer = {
8370
8462
  encode(message) {
8371
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8463
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8372
8464
 
8373
8465
  for (const v of message.urls) {
8374
8466
  writer.uint32(10).string(v);
@@ -8386,7 +8478,7 @@ const ICEServer = {
8386
8478
  },
8387
8479
 
8388
8480
  decode(input, length) {
8389
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8481
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8390
8482
  let end = length === undefined ? reader.len : reader.pos + length;
8391
8483
  const message = createBaseICEServer();
8392
8484
 
@@ -8457,7 +8549,7 @@ function createBaseSpeakersChanged() {
8457
8549
 
8458
8550
  const SpeakersChanged = {
8459
8551
  encode(message) {
8460
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8552
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8461
8553
 
8462
8554
  for (const v of message.speakers) {
8463
8555
  SpeakerInfo.encode(v, writer.uint32(10).fork()).ldelim();
@@ -8467,7 +8559,7 @@ const SpeakersChanged = {
8467
8559
  },
8468
8560
 
8469
8561
  decode(input, length) {
8470
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8562
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8471
8563
  let end = length === undefined ? reader.len : reader.pos + length;
8472
8564
  const message = createBaseSpeakersChanged();
8473
8565
 
@@ -8524,7 +8616,7 @@ function createBaseRoomUpdate() {
8524
8616
 
8525
8617
  const RoomUpdate = {
8526
8618
  encode(message) {
8527
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8619
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8528
8620
 
8529
8621
  if (message.room !== undefined) {
8530
8622
  Room$1.encode(message.room, writer.uint32(10).fork()).ldelim();
@@ -8534,7 +8626,7 @@ const RoomUpdate = {
8534
8626
  },
8535
8627
 
8536
8628
  decode(input, length) {
8537
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8629
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8538
8630
  let end = length === undefined ? reader.len : reader.pos + length;
8539
8631
  const message = createBaseRoomUpdate();
8540
8632
 
@@ -8585,7 +8677,7 @@ function createBaseConnectionQualityInfo() {
8585
8677
 
8586
8678
  const ConnectionQualityInfo = {
8587
8679
  encode(message) {
8588
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8680
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8589
8681
 
8590
8682
  if (message.participantSid !== '') {
8591
8683
  writer.uint32(10).string(message.participantSid);
@@ -8603,7 +8695,7 @@ const ConnectionQualityInfo = {
8603
8695
  },
8604
8696
 
8605
8697
  decode(input, length) {
8606
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8698
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8607
8699
  let end = length === undefined ? reader.len : reader.pos + length;
8608
8700
  const message = createBaseConnectionQualityInfo();
8609
8701
 
@@ -8668,7 +8760,7 @@ function createBaseConnectionQualityUpdate() {
8668
8760
 
8669
8761
  const ConnectionQualityUpdate = {
8670
8762
  encode(message) {
8671
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8763
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8672
8764
 
8673
8765
  for (const v of message.updates) {
8674
8766
  ConnectionQualityInfo.encode(v, writer.uint32(10).fork()).ldelim();
@@ -8678,7 +8770,7 @@ const ConnectionQualityUpdate = {
8678
8770
  },
8679
8771
 
8680
8772
  decode(input, length) {
8681
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8773
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8682
8774
  let end = length === undefined ? reader.len : reader.pos + length;
8683
8775
  const message = createBaseConnectionQualityUpdate();
8684
8776
 
@@ -8737,7 +8829,7 @@ function createBaseStreamStateInfo() {
8737
8829
 
8738
8830
  const StreamStateInfo = {
8739
8831
  encode(message) {
8740
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8832
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8741
8833
 
8742
8834
  if (message.participantSid !== '') {
8743
8835
  writer.uint32(10).string(message.participantSid);
@@ -8755,7 +8847,7 @@ const StreamStateInfo = {
8755
8847
  },
8756
8848
 
8757
8849
  decode(input, length) {
8758
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8850
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8759
8851
  let end = length === undefined ? reader.len : reader.pos + length;
8760
8852
  const message = createBaseStreamStateInfo();
8761
8853
 
@@ -8820,7 +8912,7 @@ function createBaseStreamStateUpdate() {
8820
8912
 
8821
8913
  const StreamStateUpdate = {
8822
8914
  encode(message) {
8823
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8915
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8824
8916
 
8825
8917
  for (const v of message.streamStates) {
8826
8918
  StreamStateInfo.encode(v, writer.uint32(10).fork()).ldelim();
@@ -8830,7 +8922,7 @@ const StreamStateUpdate = {
8830
8922
  },
8831
8923
 
8832
8924
  decode(input, length) {
8833
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8925
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8834
8926
  let end = length === undefined ? reader.len : reader.pos + length;
8835
8927
  const message = createBaseStreamStateUpdate();
8836
8928
 
@@ -8888,7 +8980,7 @@ function createBaseSubscribedQuality() {
8888
8980
 
8889
8981
  const SubscribedQuality = {
8890
8982
  encode(message) {
8891
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
8983
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8892
8984
 
8893
8985
  if (message.quality !== 0) {
8894
8986
  writer.uint32(8).int32(message.quality);
@@ -8902,7 +8994,7 @@ const SubscribedQuality = {
8902
8994
  },
8903
8995
 
8904
8996
  decode(input, length) {
8905
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
8997
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8906
8998
  let end = length === undefined ? reader.len : reader.pos + length;
8907
8999
  const message = createBaseSubscribedQuality();
8908
9000
 
@@ -8961,7 +9053,7 @@ function createBaseSubscribedCodec() {
8961
9053
 
8962
9054
  const SubscribedCodec = {
8963
9055
  encode(message) {
8964
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
9056
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
8965
9057
 
8966
9058
  if (message.codec !== '') {
8967
9059
  writer.uint32(10).string(message.codec);
@@ -8975,7 +9067,7 @@ const SubscribedCodec = {
8975
9067
  },
8976
9068
 
8977
9069
  decode(input, length) {
8978
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
9070
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
8979
9071
  let end = length === undefined ? reader.len : reader.pos + length;
8980
9072
  const message = createBaseSubscribedCodec();
8981
9073
 
@@ -9041,7 +9133,7 @@ function createBaseSubscribedQualityUpdate() {
9041
9133
 
9042
9134
  const SubscribedQualityUpdate = {
9043
9135
  encode(message) {
9044
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
9136
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
9045
9137
 
9046
9138
  if (message.trackSid !== '') {
9047
9139
  writer.uint32(10).string(message.trackSid);
@@ -9059,7 +9151,7 @@ const SubscribedQualityUpdate = {
9059
9151
  },
9060
9152
 
9061
9153
  decode(input, length) {
9062
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
9154
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
9063
9155
  let end = length === undefined ? reader.len : reader.pos + length;
9064
9156
  const message = createBaseSubscribedQualityUpdate();
9065
9157
 
@@ -9138,7 +9230,7 @@ function createBaseTrackPermission() {
9138
9230
 
9139
9231
  const TrackPermission = {
9140
9232
  encode(message) {
9141
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
9233
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
9142
9234
 
9143
9235
  if (message.participantSid !== '') {
9144
9236
  writer.uint32(10).string(message.participantSid);
@@ -9160,7 +9252,7 @@ const TrackPermission = {
9160
9252
  },
9161
9253
 
9162
9254
  decode(input, length) {
9163
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
9255
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
9164
9256
  let end = length === undefined ? reader.len : reader.pos + length;
9165
9257
  const message = createBaseTrackPermission();
9166
9258
 
@@ -9239,7 +9331,7 @@ function createBaseSubscriptionPermission() {
9239
9331
 
9240
9332
  const SubscriptionPermission = {
9241
9333
  encode(message) {
9242
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
9334
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
9243
9335
 
9244
9336
  if (message.allParticipants === true) {
9245
9337
  writer.uint32(8).bool(message.allParticipants);
@@ -9253,7 +9345,7 @@ const SubscriptionPermission = {
9253
9345
  },
9254
9346
 
9255
9347
  decode(input, length) {
9256
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
9348
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
9257
9349
  let end = length === undefined ? reader.len : reader.pos + length;
9258
9350
  const message = createBaseSubscriptionPermission();
9259
9351
 
@@ -9319,7 +9411,7 @@ function createBaseSubscriptionPermissionUpdate() {
9319
9411
 
9320
9412
  const SubscriptionPermissionUpdate = {
9321
9413
  encode(message) {
9322
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
9414
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
9323
9415
 
9324
9416
  if (message.participantSid !== '') {
9325
9417
  writer.uint32(10).string(message.participantSid);
@@ -9337,7 +9429,7 @@ const SubscriptionPermissionUpdate = {
9337
9429
  },
9338
9430
 
9339
9431
  decode(input, length) {
9340
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
9432
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
9341
9433
  let end = length === undefined ? reader.len : reader.pos + length;
9342
9434
  const message = createBaseSubscriptionPermissionUpdate();
9343
9435
 
@@ -9405,7 +9497,7 @@ function createBaseSyncState() {
9405
9497
 
9406
9498
  const SyncState = {
9407
9499
  encode(message) {
9408
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
9500
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
9409
9501
 
9410
9502
  if (message.answer !== undefined) {
9411
9503
  SessionDescription.encode(message.answer, writer.uint32(10).fork()).ldelim();
@@ -9427,7 +9519,7 @@ const SyncState = {
9427
9519
  },
9428
9520
 
9429
9521
  decode(input, length) {
9430
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
9522
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
9431
9523
  let end = length === undefined ? reader.len : reader.pos + length;
9432
9524
  const message = createBaseSyncState();
9433
9525
 
@@ -9512,7 +9604,7 @@ function createBaseDataChannelInfo() {
9512
9604
 
9513
9605
  const DataChannelInfo = {
9514
9606
  encode(message) {
9515
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
9607
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
9516
9608
 
9517
9609
  if (message.label !== '') {
9518
9610
  writer.uint32(10).string(message.label);
@@ -9530,7 +9622,7 @@ const DataChannelInfo = {
9530
9622
  },
9531
9623
 
9532
9624
  decode(input, length) {
9533
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
9625
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
9534
9626
  let end = length === undefined ? reader.len : reader.pos + length;
9535
9627
  const message = createBaseDataChannelInfo();
9536
9628
 
@@ -9599,7 +9691,7 @@ function createBaseSimulateScenario() {
9599
9691
 
9600
9692
  const SimulateScenario = {
9601
9693
  encode(message) {
9602
- let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal.Writer.create();
9694
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minimal$1.exports.Writer.create();
9603
9695
 
9604
9696
  if (message.speakerUpdate !== undefined) {
9605
9697
  writer.uint32(8).int32(message.speakerUpdate);
@@ -9625,7 +9717,7 @@ const SimulateScenario = {
9625
9717
  },
9626
9718
 
9627
9719
  decode(input, length) {
9628
- const reader = input instanceof minimal.Reader ? input : new minimal.Reader(input);
9720
+ const reader = input instanceof minimal$1.exports.Reader ? input : new minimal$1.exports.Reader(input);
9629
9721
  let end = length === undefined ? reader.len : reader.pos + length;
9630
9722
  const message = createBaseSimulateScenario();
9631
9723
 
@@ -9696,10 +9788,10 @@ const SimulateScenario = {
9696
9788
 
9697
9789
  };
9698
9790
 
9699
- if (minimal.util.Long !== long) {
9700
- minimal.util.Long = long;
9791
+ if (minimal$1.exports.util.Long !== long) {
9792
+ minimal$1.exports.util.Long = long;
9701
9793
 
9702
- minimal.configure();
9794
+ minimal$1.exports.configure();
9703
9795
  }
9704
9796
 
9705
9797
  function isSet(value) {
@@ -10265,7 +10357,7 @@ function computeBitrate(currentStats, prevStats) {
10265
10357
  return (bytesNow - bytesPrev) * 8 * 1000 / (currentStats.timestamp - prevStats.timestamp);
10266
10358
  }
10267
10359
 
10268
- var version$1 = "1.2.4";
10360
+ var version$1 = "1.2.5";
10269
10361
 
10270
10362
  const version = version$1;
10271
10363
  const protocolVersion = 8;
@@ -10376,8 +10468,8 @@ function getEmptyAudioStreamTrack() {
10376
10468
  return emptyAudioStreamTrack;
10377
10469
  }
10378
10470
  class Future {
10379
- constructor() {
10380
- this.promise = new Promise((resolve, reject) => {
10471
+ constructor(promise) {
10472
+ this.promise = promise !== null && promise !== void 0 ? promise : new Promise((resolve, reject) => {
10381
10473
  this.resolve = resolve;
10382
10474
  this.reject = reject;
10383
10475
  });
@@ -10569,9 +10661,27 @@ class DeviceManager {
10569
10661
 
10570
10662
  async getDevices(kind) {
10571
10663
  let requestPermissions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
10664
+
10665
+ var _a;
10666
+
10667
+ if (((_a = DeviceManager.userMediaPromiseMap) === null || _a === void 0 ? void 0 : _a.size) > 0) {
10668
+ livekitLogger.debug('awaiting getUserMedia promise');
10669
+
10670
+ try {
10671
+ if (kind) {
10672
+ await DeviceManager.userMediaPromiseMap.get(kind);
10673
+ } else {
10674
+ await Promise.all(DeviceManager.userMediaPromiseMap.values());
10675
+ }
10676
+ } catch (e) {
10677
+ livekitLogger.warn('error waiting for media permissons');
10678
+ }
10679
+ }
10680
+
10572
10681
  let devices = await navigator.mediaDevices.enumerateDevices();
10573
10682
 
10574
- if (requestPermissions) {
10683
+ if (requestPermissions && kind && ( // for safari we need to skip this check, as otherwise it will re-acquire user media and fail on iOS https://bugs.webkit.org/show_bug.cgi?id=179363
10684
+ !DeviceManager.userMediaPromiseMap.get(kind) || !isSafari())) {
10575
10685
  const isDummyDeviceOrEmpty = devices.length === 0 || devices.some(device => {
10576
10686
  const noLabel = device.label === '';
10577
10687
  const isRelevant = kind ? device.kind === kind : true;
@@ -10631,6 +10741,7 @@ class DeviceManager {
10631
10741
 
10632
10742
  }
10633
10743
  DeviceManager.mediaDeviceKinds = ['audioinput', 'audiooutput', 'videoinput'];
10744
+ DeviceManager.userMediaPromiseMap = new Map();
10634
10745
 
10635
10746
  var events = {exports: {}};
10636
10747
 
@@ -11944,6 +12055,8 @@ class LocalVideoTrack extends LocalTrack {
11944
12055
  constructor(mediaTrack, constraints) {
11945
12056
  let userProvidedTrack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
11946
12057
  super(mediaTrack, Track.Kind.Video, constraints, userProvidedTrack);
12058
+ /* @internal */
12059
+
11947
12060
  this.simulcastCodecs = new Map();
11948
12061
 
11949
12062
  this.monitorSender = async () => {
@@ -12020,9 +12133,7 @@ class LocalVideoTrack extends LocalTrack {
12020
12133
 
12021
12134
  this.simulcastCodecs.forEach(trackInfo => {
12022
12135
  trackInfo.mediaStreamTrack.stop();
12023
- trackInfo.sender = undefined;
12024
12136
  });
12025
- this.simulcastCodecs.clear();
12026
12137
  super.stop();
12027
12138
  }
12028
12139
 
@@ -12187,24 +12298,45 @@ class LocalVideoTrack extends LocalTrack {
12187
12298
 
12188
12299
  this.subscribedCodecs = codecs;
12189
12300
  const newCodecs = [];
12301
+ var _iteratorAbruptCompletion = false;
12302
+ var _didIteratorError = false;
12190
12303
 
12191
- for await (const codec of codecs) {
12192
- if (!this.codec || this.codec === codec.codec) {
12193
- await this.setPublishingLayers(codec.qualities);
12194
- } else {
12195
- const simulcastCodecInfo = this.simulcastCodecs.get(codec.codec);
12196
- livekitLogger.debug("try setPublishingCodec for ".concat(codec.codec), simulcastCodecInfo);
12304
+ var _iteratorError;
12197
12305
 
12198
- if (!simulcastCodecInfo || !simulcastCodecInfo.sender) {
12199
- for (const q of codec.qualities) {
12200
- if (q.enabled) {
12201
- newCodecs.push(codec.codec);
12202
- break;
12306
+ try {
12307
+ for (var _iterator = _asyncIterator(codecs), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
12308
+ const codec = _step.value;
12309
+
12310
+ if (!this.codec || this.codec === codec.codec) {
12311
+ await this.setPublishingLayers(codec.qualities);
12312
+ } else {
12313
+ const simulcastCodecInfo = this.simulcastCodecs.get(codec.codec);
12314
+ livekitLogger.debug("try setPublishingCodec for ".concat(codec.codec), simulcastCodecInfo);
12315
+
12316
+ if (!simulcastCodecInfo || !simulcastCodecInfo.sender) {
12317
+ for (const q of codec.qualities) {
12318
+ if (q.enabled) {
12319
+ newCodecs.push(codec.codec);
12320
+ break;
12321
+ }
12203
12322
  }
12323
+ } else if (simulcastCodecInfo.encodings) {
12324
+ livekitLogger.debug("try setPublishingLayersForSender ".concat(codec.codec));
12325
+ await setPublishingLayersForSender(simulcastCodecInfo.sender, simulcastCodecInfo.encodings, codec.qualities);
12204
12326
  }
12205
- } else if (simulcastCodecInfo.encodings) {
12206
- livekitLogger.debug("try setPublishingLayersForSender ".concat(codec.codec));
12207
- await setPublishingLayersForSender(simulcastCodecInfo.sender, simulcastCodecInfo.encodings, codec.qualities);
12327
+ }
12328
+ }
12329
+ } catch (err) {
12330
+ _didIteratorError = true;
12331
+ _iteratorError = err;
12332
+ } finally {
12333
+ try {
12334
+ if (_iteratorAbruptCompletion && _iterator.return != null) {
12335
+ await _iterator.return();
12336
+ }
12337
+ } finally {
12338
+ if (_didIteratorError) {
12339
+ throw _iteratorError;
12208
12340
  }
12209
12341
  }
12210
12342
  }
@@ -13618,6 +13750,7 @@ function sortPresets(presets) {
13618
13750
  class RemoteTrackPublication extends TrackPublication {
13619
13751
  constructor() {
13620
13752
  super(...arguments);
13753
+ this.track = undefined;
13621
13754
  /** @internal */
13622
13755
 
13623
13756
  this.allowed = true;
@@ -14200,10 +14333,30 @@ class LocalParticipant extends Participant {
14200
14333
  }
14201
14334
 
14202
14335
  const newCodecs = await pub.videoTrack.setPublishingCodecs(update.subscribedCodecs);
14336
+ var _iteratorAbruptCompletion = false;
14337
+ var _didIteratorError = false;
14338
+
14339
+ var _iteratorError;
14203
14340
 
14204
- for await (const codec of newCodecs) {
14205
- livekitLogger.debug("publish ".concat(codec, " for ").concat(pub.videoTrack.sid));
14206
- await this.publishAdditionalCodecForTrack(pub.videoTrack, codec, pub.options);
14341
+ try {
14342
+ for (var _iterator = _asyncIterator(newCodecs), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
14343
+ const codec = _step.value;
14344
+ livekitLogger.debug("publish ".concat(codec, " for ").concat(pub.videoTrack.sid));
14345
+ await this.publishAdditionalCodecForTrack(pub.videoTrack, codec, pub.options);
14346
+ }
14347
+ } catch (err) {
14348
+ _didIteratorError = true;
14349
+ _iteratorError = err;
14350
+ } finally {
14351
+ try {
14352
+ if (_iteratorAbruptCompletion && _iterator.return != null) {
14353
+ await _iterator.return();
14354
+ }
14355
+ } finally {
14356
+ if (_didIteratorError) {
14357
+ throw _iteratorError;
14358
+ }
14359
+ }
14207
14360
  }
14208
14361
  } else if (update.subscribedQualities.length > 0) {
14209
14362
  (_b = pub.videoTrack) === null || _b === void 0 ? void 0 : _b.setPublishingLayers(update.subscribedQualities);
@@ -14891,13 +15044,25 @@ class LocalParticipant extends Participant {
14891
15044
 
14892
15045
  if (this.engine.publisher && this.engine.publisher.pc.connectionState !== 'closed' && track.sender) {
14893
15046
  try {
14894
- this.engine.publisher.pc.removeTrack(track.sender);
14895
- this.engine.negotiate();
15047
+ this.engine.removeTrack(track.sender);
15048
+
15049
+ if (track instanceof LocalVideoTrack) {
15050
+ for (const [, trackInfo] of track.simulcastCodecs) {
15051
+ if (trackInfo.sender) {
15052
+ this.engine.removeTrack(trackInfo.sender);
15053
+ trackInfo.sender = undefined;
15054
+ }
15055
+ }
15056
+
15057
+ track.simulcastCodecs.clear();
15058
+ }
14896
15059
  } catch (e) {
14897
- livekitLogger.warn('failed to remove track', {
15060
+ livekitLogger.warn('failed to unpublish track', {
14898
15061
  error: e,
14899
15062
  method: 'unpublishTrack'
14900
15063
  });
15064
+ } finally {
15065
+ this.engine.negotiate();
14901
15066
  }
14902
15067
  }
14903
15068
 
@@ -19768,6 +19933,13 @@ var parser = parser$1;
19768
19933
  var writer = writer$1;
19769
19934
  var write = writer;
19770
19935
  var parse = parser.parse;
19936
+ parser.parseParams;
19937
+ parser.parseFmtpConfig; // Alias of parseParams().
19938
+
19939
+ parser.parsePayloads;
19940
+ parser.parseRemoteCandidates;
19941
+ parser.parseImageAttributes;
19942
+ parser.parseSimulcastStreamList;
19771
19943
 
19772
19944
  /** @internal */
19773
19945
 
@@ -20224,18 +20396,48 @@ class RTCEngine extends events.exports.EventEmitter {
20224
20396
 
20225
20397
  return new Promise((resolve, reject) => {
20226
20398
  const publicationTimeout = setTimeout(() => {
20399
+ delete this.pendingTrackResolvers[req.cid];
20227
20400
  reject(new ConnectionError('publication of local track timed out, no response from server'));
20228
- }, 15000);
20229
-
20230
- this.pendingTrackResolvers[req.cid] = info => {
20231
- clearTimeout(publicationTimeout);
20232
- resolve(info);
20401
+ }, 10000);
20402
+ this.pendingTrackResolvers[req.cid] = {
20403
+ resolve: info => {
20404
+ clearTimeout(publicationTimeout);
20405
+ resolve(info);
20406
+ },
20407
+ reject: () => {
20408
+ clearTimeout(publicationTimeout);
20409
+ reject('Cancelled publication by calling unpublish');
20410
+ }
20233
20411
  };
20234
-
20235
20412
  this.client.sendAddTrack(req);
20236
20413
  });
20237
20414
  }
20238
20415
 
20416
+ removeTrack(sender) {
20417
+ var _a;
20418
+
20419
+ if (sender.track && this.pendingTrackResolvers[sender.track.id]) {
20420
+ const {
20421
+ reject
20422
+ } = this.pendingTrackResolvers[sender.track.id];
20423
+
20424
+ if (reject) {
20425
+ reject();
20426
+ }
20427
+
20428
+ delete this.pendingTrackResolvers[sender.track.id];
20429
+ }
20430
+
20431
+ try {
20432
+ (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.pc.removeTrack(sender);
20433
+ } catch (e) {
20434
+ livekitLogger.warn('failed to remove track', {
20435
+ error: e,
20436
+ method: 'removeTrack'
20437
+ });
20438
+ }
20439
+ }
20440
+
20239
20441
  updateMuteStatus(trackSid, muted) {
20240
20442
  this.client.sendMuteTrack(trackSid, muted);
20241
20443
  }
@@ -20411,7 +20613,9 @@ class RTCEngine extends events.exports.EventEmitter {
20411
20613
 
20412
20614
  this.client.onLocalTrackPublished = res => {
20413
20615
  livekitLogger.debug('received trackPublishedResponse', res);
20414
- const resolve = this.pendingTrackResolvers[res.cid];
20616
+ const {
20617
+ resolve
20618
+ } = this.pendingTrackResolvers[res.cid];
20415
20619
 
20416
20620
  if (!resolve) {
20417
20621
  livekitLogger.error("missing track resolver for ".concat(res.cid));
@@ -20817,117 +21021,123 @@ class Room extends events.exports.EventEmitter {
20817
21021
  this.metadata = undefined;
20818
21022
  this.audioEnabled = true;
20819
21023
 
20820
- this.connect = async (url, token, opts) => {
20821
- var _a, _b, _c, _d;
20822
-
21024
+ this.connect = (url, token, opts) => {
20823
21025
  if (this.state === ConnectionState.Connected) {
20824
21026
  // when the state is reconnecting or connected, this function returns immediately
20825
21027
  livekitLogger.warn("already connected to room ".concat(this.name));
20826
- return;
21028
+ return Promise.resolve();
20827
21029
  }
20828
21030
 
20829
21031
  if (this.connectFuture) {
20830
21032
  return this.connectFuture.promise;
21033
+ } else if (this.reconnectFuture) {
21034
+ this.connectFuture = this.reconnectFuture;
21035
+ return this.connectFuture.promise;
20831
21036
  }
20832
21037
 
20833
- this.setAndEmitConnectionState(ConnectionState.Connecting);
21038
+ const connectPromise = new Promise(async (resolve, reject) => {
21039
+ var _a, _b, _c, _d;
20834
21040
 
20835
- if (!this.abortController || this.abortController.signal.aborted) {
20836
- this.abortController = new AbortController();
20837
- } // recreate engine if previously disconnected
21041
+ this.setAndEmitConnectionState(ConnectionState.Connecting);
20838
21042
 
21043
+ if (!this.abortController || this.abortController.signal.aborted) {
21044
+ this.abortController = new AbortController();
21045
+ } // recreate engine if previously disconnected
20839
21046
 
20840
- this.createEngine();
20841
- this.acquireAudioContext();
20842
-
20843
- if (opts === null || opts === void 0 ? void 0 : opts.rtcConfig) {
20844
- this.engine.rtcConfig = opts.rtcConfig;
20845
- }
20846
21047
 
20847
- this.connOptions = opts;
21048
+ this.createEngine();
21049
+ this.acquireAudioContext();
20848
21050
 
20849
- try {
20850
- const joinResponse = await this.engine.join(url, token, {
20851
- autoSubscribe: opts === null || opts === void 0 ? void 0 : opts.autoSubscribe,
20852
- publishOnly: opts === null || opts === void 0 ? void 0 : opts.publishOnly,
20853
- adaptiveStream: typeof ((_a = this.options) === null || _a === void 0 ? void 0 : _a.adaptiveStream) === 'object' ? true : (_b = this.options) === null || _b === void 0 ? void 0 : _b.adaptiveStream
20854
- }, this.abortController.signal);
20855
- livekitLogger.debug("connected to Livekit Server version: ".concat(joinResponse.serverVersion, ", region: ").concat(joinResponse.serverRegion));
20856
-
20857
- if (!joinResponse.serverVersion) {
20858
- throw new UnsupportedServer('unknown server version');
21051
+ if (opts === null || opts === void 0 ? void 0 : opts.rtcConfig) {
21052
+ this.engine.rtcConfig = opts.rtcConfig;
20859
21053
  }
20860
21054
 
20861
- if (joinResponse.serverVersion === '0.15.1' && this.options.dynacast) {
20862
- livekitLogger.debug('disabling dynacast due to server version'); // dynacast has a bug in 0.15.1, so we cannot use it then
20863
-
20864
- this.options.dynacast = false;
20865
- }
21055
+ this.connOptions = opts;
20866
21056
 
20867
- const pi = joinResponse.participant;
20868
- this.localParticipant.sid = pi.sid;
20869
- this.localParticipant.identity = pi.identity;
20870
- this.localParticipant.updateInfo(pi); // forward metadata changed for the local participant
21057
+ try {
21058
+ const joinResponse = await this.engine.join(url, token, {
21059
+ autoSubscribe: opts === null || opts === void 0 ? void 0 : opts.autoSubscribe,
21060
+ publishOnly: opts === null || opts === void 0 ? void 0 : opts.publishOnly,
21061
+ adaptiveStream: typeof ((_a = this.options) === null || _a === void 0 ? void 0 : _a.adaptiveStream) === 'object' ? true : (_b = this.options) === null || _b === void 0 ? void 0 : _b.adaptiveStream
21062
+ }, this.abortController.signal);
21063
+ livekitLogger.debug("connected to Livekit Server version: ".concat(joinResponse.serverVersion, ", region: ").concat(joinResponse.serverRegion));
21064
+
21065
+ if (!joinResponse.serverVersion) {
21066
+ throw new UnsupportedServer('unknown server version');
21067
+ }
20871
21068
 
20872
- this.localParticipant.on(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged).on(ParticipantEvent.TrackMuted, this.onLocalTrackMuted).on(ParticipantEvent.TrackUnmuted, this.onLocalTrackUnmuted).on(ParticipantEvent.LocalTrackPublished, this.onLocalTrackPublished).on(ParticipantEvent.LocalTrackUnpublished, this.onLocalTrackUnpublished).on(ParticipantEvent.ConnectionQualityChanged, this.onLocalConnectionQualityChanged).on(ParticipantEvent.MediaDevicesError, this.onMediaDevicesError).on(ParticipantEvent.ParticipantPermissionsChanged, this.onLocalParticipantPermissionsChanged); // populate remote participants, these should not trigger new events
21069
+ if (joinResponse.serverVersion === '0.15.1' && this.options.dynacast) {
21070
+ livekitLogger.debug('disabling dynacast due to server version'); // dynacast has a bug in 0.15.1, so we cannot use it then
20873
21071
 
20874
- joinResponse.otherParticipants.forEach(info => {
20875
- if (info.sid !== this.localParticipant.sid && info.identity !== this.localParticipant.identity) {
20876
- this.getOrCreateParticipant(info.sid, info);
20877
- } else {
20878
- livekitLogger.warn('received info to create local participant as remote participant', {
20879
- info,
20880
- localParticipant: this.localParticipant
20881
- });
21072
+ this.options.dynacast = false;
20882
21073
  }
20883
- });
20884
- this.name = joinResponse.room.name;
20885
- this.sid = joinResponse.room.sid;
20886
- this.metadata = joinResponse.room.metadata;
20887
- this.emit(RoomEvent.SignalConnected);
20888
- } catch (err) {
20889
- this.recreateEngine();
20890
- this.setAndEmitConnectionState(ConnectionState.Disconnected, new ConnectionError('could not establish signal connection'));
20891
- throw err;
20892
- } // don't return until ICE connected
20893
-
20894
-
20895
- const connectTimeout = setTimeout(() => {
20896
- // timeout
20897
- this.recreateEngine();
20898
- this.setAndEmitConnectionState(ConnectionState.Disconnected, new ConnectionError('could not connect PeerConnection after timeout'));
20899
- }, maxICEConnectTimeout);
20900
-
20901
- const abortHandler = () => {
20902
- livekitLogger.warn('closing engine');
20903
- clearTimeout(connectTimeout);
20904
- this.recreateEngine();
20905
- this.setAndEmitConnectionState(ConnectionState.Disconnected, new ConnectionError('room connection has been cancelled'));
20906
- };
20907
21074
 
20908
- if ((_c = this.abortController) === null || _c === void 0 ? void 0 : _c.signal.aborted) {
20909
- abortHandler();
20910
- }
21075
+ const pi = joinResponse.participant;
21076
+ this.localParticipant.sid = pi.sid;
21077
+ this.localParticipant.identity = pi.identity;
21078
+ this.localParticipant.updateInfo(pi); // forward metadata changed for the local participant
20911
21079
 
20912
- (_d = this.abortController) === null || _d === void 0 ? void 0 : _d.signal.addEventListener('abort', abortHandler);
20913
- this.engine.once(EngineEvent.Connected, () => {
20914
- var _a, _b;
21080
+ this.localParticipant.on(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged).on(ParticipantEvent.TrackMuted, this.onLocalTrackMuted).on(ParticipantEvent.TrackUnmuted, this.onLocalTrackUnmuted).on(ParticipantEvent.LocalTrackPublished, this.onLocalTrackPublished).on(ParticipantEvent.LocalTrackUnpublished, this.onLocalTrackUnpublished).on(ParticipantEvent.ConnectionQualityChanged, this.onLocalConnectionQualityChanged).on(ParticipantEvent.MediaDevicesError, this.onMediaDevicesError).on(ParticipantEvent.ParticipantPermissionsChanged, this.onLocalParticipantPermissionsChanged); // populate remote participants, these should not trigger new events
20915
21081
 
20916
- clearTimeout(connectTimeout);
20917
- (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.signal.removeEventListener('abort', abortHandler); // also hook unload event
21082
+ joinResponse.otherParticipants.forEach(info => {
21083
+ if (info.sid !== this.localParticipant.sid && info.identity !== this.localParticipant.identity) {
21084
+ this.getOrCreateParticipant(info.sid, info);
21085
+ } else {
21086
+ livekitLogger.warn('received info to create local participant as remote participant', {
21087
+ info,
21088
+ localParticipant: this.localParticipant
21089
+ });
21090
+ }
21091
+ });
21092
+ this.name = joinResponse.room.name;
21093
+ this.sid = joinResponse.room.sid;
21094
+ this.metadata = joinResponse.room.metadata;
21095
+ this.emit(RoomEvent.SignalConnected);
21096
+ } catch (err) {
21097
+ this.recreateEngine();
21098
+ this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
21099
+ reject(new ConnectionError('could not establish signal connection'));
21100
+ } // don't return until ICE connected
21101
+
21102
+
21103
+ const connectTimeout = setTimeout(() => {
21104
+ // timeout
21105
+ this.recreateEngine();
21106
+ this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
21107
+ reject(new ConnectionError('could not connect PeerConnection after timeout'));
21108
+ }, maxICEConnectTimeout);
21109
+
21110
+ const abortHandler = () => {
21111
+ livekitLogger.warn('closing engine');
21112
+ clearTimeout(connectTimeout);
21113
+ this.recreateEngine();
21114
+ this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
21115
+ reject(new ConnectionError('room connection has been cancelled'));
21116
+ };
20918
21117
 
20919
- if (isWeb()) {
20920
- window.addEventListener('beforeunload', this.onBeforeUnload);
20921
- (_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.addEventListener('devicechange', this.handleDeviceChange);
21118
+ if ((_c = this.abortController) === null || _c === void 0 ? void 0 : _c.signal.aborted) {
21119
+ abortHandler();
20922
21120
  }
20923
21121
 
20924
- this.setAndEmitConnectionState(ConnectionState.Connected);
20925
- });
21122
+ (_d = this.abortController) === null || _d === void 0 ? void 0 : _d.signal.addEventListener('abort', abortHandler);
21123
+ this.engine.once(EngineEvent.Connected, () => {
21124
+ var _a, _b;
20926
21125
 
20927
- if (this.connectFuture) {
20928
- /** @ts-ignore */
20929
- return this.connectFuture.promise;
20930
- }
21126
+ clearTimeout(connectTimeout);
21127
+ (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.signal.removeEventListener('abort', abortHandler); // also hook unload event
21128
+
21129
+ if (isWeb()) {
21130
+ window.addEventListener('beforeunload', this.onBeforeUnload);
21131
+ (_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.addEventListener('devicechange', this.handleDeviceChange);
21132
+ }
21133
+
21134
+ this.setAndEmitConnectionState(ConnectionState.Connected);
21135
+ resolve();
21136
+ });
21137
+ });
21138
+ this.connectFuture = new Future(connectPromise);
21139
+ this.connectFuture.promise.finally(() => this.connectFuture = undefined);
21140
+ return this.connectFuture.promise;
20931
21141
  };
20932
21142
  /**
20933
21143
  * disconnects the room, emits [[RoomEvent.Disconnected]]
@@ -20937,21 +21147,23 @@ class Room extends events.exports.EventEmitter {
20937
21147
  this.disconnect = async function () {
20938
21148
  let stopTracks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
20939
21149
 
20940
- var _a, _b;
21150
+ var _a, _b, _c;
20941
21151
 
20942
21152
  livekitLogger.info('disconnect from room', {
20943
21153
  identity: _this.localParticipant.identity
20944
21154
  });
20945
21155
 
20946
- if (_this.state === ConnectionState.Connecting) {
21156
+ if (_this.state === ConnectionState.Connecting || _this.state === ConnectionState.Reconnecting) {
20947
21157
  // try aborting pending connection attempt
20948
21158
  livekitLogger.warn('abort connection attempt');
20949
- (_a = _this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
20950
- return;
21159
+ (_a = _this.abortController) === null || _a === void 0 ? void 0 : _a.abort(); // in case the abort controller didn't manage to cancel the connection attempt, reject the connect promise explicitly
21160
+
21161
+ (_b = _this.connectFuture) === null || _b === void 0 ? void 0 : _b.reject(new ConnectionError('Client initiated disconnect'));
21162
+ _this.connectFuture = undefined;
20951
21163
  } // send leave
20952
21164
 
20953
21165
 
20954
- if ((_b = _this.engine) === null || _b === void 0 ? void 0 : _b.client.isConnected) {
21166
+ if ((_c = _this.engine) === null || _c === void 0 ? void 0 : _c.client.isConnected) {
20955
21167
  await _this.engine.client.sendLeave();
20956
21168
  } // close engine (also closes client)
20957
21169
 
@@ -20972,7 +21184,11 @@ class Room extends events.exports.EventEmitter {
20972
21184
  };
20973
21185
 
20974
21186
  this.handleRestarting = () => {
20975
- // also unwind existing participants & existing subscriptions
21187
+ if (!this.reconnectFuture) {
21188
+ this.reconnectFuture = new Future();
21189
+ } // also unwind existing participants & existing subscriptions
21190
+
21191
+
20976
21192
  for (const p of this.participants.values()) {
20977
21193
  this.handleParticipantDisconnected(p.sid, p);
20978
21194
  }
@@ -20983,11 +21199,15 @@ class Room extends events.exports.EventEmitter {
20983
21199
  };
20984
21200
 
20985
21201
  this.handleRestarted = async joinResponse => {
21202
+ var _a;
21203
+
20986
21204
  livekitLogger.debug("reconnected to server", {
20987
21205
  region: joinResponse.serverRegion
20988
21206
  });
20989
21207
  this.setAndEmitConnectionState(ConnectionState.Connected);
20990
- this.emit(RoomEvent.Reconnected); // rehydrate participants
21208
+ this.emit(RoomEvent.Reconnected);
21209
+ (_a = this.reconnectFuture) === null || _a === void 0 ? void 0 : _a.resolve();
21210
+ this.reconnectFuture = undefined; // rehydrate participants
20991
21211
 
20992
21212
  if (joinResponse.participant) {
20993
21213
  // with a restart, the sid will have changed, we'll map our understanding to it
@@ -21271,11 +21491,19 @@ class Room extends events.exports.EventEmitter {
21271
21491
  }).on(EngineEvent.Disconnected, reason => {
21272
21492
  this.handleDisconnect(this.options.stopLocalTrackOnUnpublish, reason);
21273
21493
  }).on(EngineEvent.ActiveSpeakersUpdate, this.handleActiveSpeakersUpdate).on(EngineEvent.DataPacketReceived, this.handleDataPacket).on(EngineEvent.Resuming, () => {
21494
+ if (!this.reconnectFuture) {
21495
+ this.reconnectFuture = new Future();
21496
+ }
21497
+
21274
21498
  if (this.setAndEmitConnectionState(ConnectionState.Reconnecting)) {
21275
21499
  this.emit(RoomEvent.Reconnecting);
21276
21500
  }
21277
21501
  }).on(EngineEvent.Resumed, () => {
21502
+ var _a;
21503
+
21278
21504
  this.setAndEmitConnectionState(ConnectionState.Connected);
21505
+ (_a = this.reconnectFuture) === null || _a === void 0 ? void 0 : _a.resolve();
21506
+ this.reconnectFuture = undefined;
21279
21507
  this.emit(RoomEvent.Reconnected);
21280
21508
  this.updateSubscriptions();
21281
21509
  }).on(EngineEvent.SignalResumed, () => {
@@ -21529,10 +21757,17 @@ class Room extends events.exports.EventEmitter {
21529
21757
  let shouldStopTracks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
21530
21758
  let reason = arguments.length > 1 ? arguments[1] : undefined;
21531
21759
 
21532
- var _a;
21760
+ var _a, _b;
21533
21761
 
21534
21762
  if (this.state === ConnectionState.Disconnected) {
21535
21763
  return;
21764
+ } // reject potentially ongoing reconnection attempt
21765
+
21766
+
21767
+ if (this.connectFuture === this.reconnectFuture) {
21768
+ (_a = this.connectFuture) === null || _a === void 0 ? void 0 : _a.reject(undefined);
21769
+ this.connectFuture = undefined;
21770
+ this.reconnectFuture = undefined;
21536
21771
  }
21537
21772
 
21538
21773
  this.participants.forEach(p => {
@@ -21566,7 +21801,7 @@ class Room extends events.exports.EventEmitter {
21566
21801
 
21567
21802
  if (isWeb()) {
21568
21803
  window.removeEventListener('beforeunload', this.onBeforeUnload);
21569
- (_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.removeEventListener('devicechange', this.handleDeviceChange);
21804
+ (_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.removeEventListener('devicechange', this.handleDeviceChange);
21570
21805
  }
21571
21806
 
21572
21807
  this.setAndEmitConnectionState(ConnectionState.Disconnected);
@@ -21721,41 +21956,12 @@ class Room extends events.exports.EventEmitter {
21721
21956
  }
21722
21957
  }
21723
21958
 
21724
- setAndEmitConnectionState(state, error) {
21959
+ setAndEmitConnectionState(state) {
21725
21960
  if (state === this.state) {
21726
21961
  // unchanged
21727
21962
  return false;
21728
21963
  }
21729
21964
 
21730
- switch (state) {
21731
- case ConnectionState.Connecting:
21732
- case ConnectionState.Reconnecting:
21733
- if (!this.connectFuture) {
21734
- // reuse existing connect future if possible
21735
- this.connectFuture = new Future();
21736
- }
21737
-
21738
- break;
21739
-
21740
- case ConnectionState.Connected:
21741
- if (this.connectFuture) {
21742
- this.connectFuture.resolve();
21743
- this.connectFuture = undefined;
21744
- }
21745
-
21746
- break;
21747
-
21748
- case ConnectionState.Disconnected:
21749
- if (this.connectFuture) {
21750
- error !== null && error !== void 0 ? error : error = new Error('disconnected from Room');
21751
- this.connectFuture.reject(error);
21752
- this.connectFuture = undefined;
21753
- }
21754
-
21755
- break;
21756
-
21757
- }
21758
-
21759
21965
  this.state = state;
21760
21966
  this.emit(RoomEvent.ConnectionStateChanged, this.state);
21761
21967
  return true;
@@ -21803,8 +22009,22 @@ async function createLocalTracks(options) {
21803
22009
  (_a = options.audio) !== null && _a !== void 0 ? _a : options.audio = true;
21804
22010
  (_b = options.video) !== null && _b !== void 0 ? _b : options.video = true;
21805
22011
  const opts = mergeDefaultOptions(options, audioDefaults, videoDefaults);
21806
- const constraints = constraintsForOptions(opts);
21807
- const stream = await navigator.mediaDevices.getUserMedia(constraints);
22012
+ const constraints = constraintsForOptions(opts); // Keep a reference to the promise on DeviceManager and await it in getLocalDevices()
22013
+ // works around iOS Safari Bug https://bugs.webkit.org/show_bug.cgi?id=179363
22014
+
22015
+ const mediaPromise = navigator.mediaDevices.getUserMedia(constraints);
22016
+
22017
+ if (options.audio) {
22018
+ DeviceManager.userMediaPromiseMap.set('audioinput', mediaPromise);
22019
+ mediaPromise.catch(() => DeviceManager.userMediaPromiseMap.delete('audioinput'));
22020
+ }
22021
+
22022
+ if (options.video) {
22023
+ DeviceManager.userMediaPromiseMap.set('videoinput', mediaPromise);
22024
+ mediaPromise.catch(() => DeviceManager.userMediaPromiseMap.delete('videoinput'));
22025
+ }
22026
+
22027
+ const stream = await mediaPromise;
21808
22028
  return stream.getTracks().map(mediaStreamTrack => {
21809
22029
  const isAudio = mediaStreamTrack.kind === 'audio';
21810
22030
  isAudio ? options.audio : options.video;