quickvo-sdk-js 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- var Ht = Object.defineProperty;
2
- var Ft = (_) => {
1
+ var Xt = Object.defineProperty;
2
+ var Vt = (_) => {
3
3
  throw TypeError(_);
4
4
  };
5
- var zt = (_, D, $) => D in _ ? Ht(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $;
6
- var W = (_, D, $) => zt(_, typeof D != "symbol" ? D + "" : D, $), jt = (_, D, $) => D.has(_) || Ft("Cannot " + $);
7
- var X = (_, D, $) => (jt(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), lt = (_, D, $) => D.has(_) ? Ft("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), yt = (_, D, $, U) => (jt(_, D, "write to private field"), U ? U.call(_, $) : D.set(_, $), $);
5
+ var Qt = (_, D, $) => D in _ ? Xt(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $;
6
+ var K = (_, D, $) => Qt(_, typeof D != "symbol" ? D + "" : D, $), Yt = (_, D, $) => D.has(_) || Vt("Cannot " + $);
7
+ var G = (_, D, $) => (Yt(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), st = (_, D, $) => D.has(_) ? Vt("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), _t = (_, D, $, U) => (Yt(_, D, "write to private field"), U ? U.call(_, $) : D.set(_, $), $);
8
8
  const v$1 = (_, D = []) => {
9
9
  const $ = { ..._ }, U = Object.keys($);
10
10
  for (const R of U)
@@ -587,9 +587,9 @@ function requireParser() {
587
587
  var Z = F[0], H = F.slice(2);
588
588
  Z === "m" && (M.push({ rtp: [], fmtp: [] }), L = M[M.length - 1]);
589
589
  for (var z = 0; z < (R[Z] || []).length; z += 1) {
590
- var V = R[Z][z];
591
- if (V.reg.test(H))
592
- return U(V, L, H);
590
+ var Y = R[Z][z];
591
+ if (Y.reg.test(H))
592
+ return U(Y, L, H);
593
593
  }
594
594
  }), A.media = M, A;
595
595
  };
@@ -704,9 +704,9 @@ function requireLib() {
704
704
  return lib.grammar = $, lib.write = D, lib.parse = _.parse, lib.parseParams = _.parseParams, lib.parseFmtpConfig = _.parseFmtpConfig, lib.parsePayloads = _.parsePayloads, lib.parseRemoteCandidates = _.parseRemoteCandidates, lib.parseImageAttributes = _.parseImageAttributes, lib.parseSimulcastStreamList = _.parseSimulcastStreamList, lib;
705
705
  }
706
706
  var libExports = requireLib();
707
- class AudioMediaStreamContext {
707
+ class AudioMediaContext {
708
708
  constructor(D) {
709
- W(this, "options", {
709
+ K(this, "options", {
710
710
  autoGainControl: !1,
711
711
  // 自动增益
712
712
  noiseSuppression: !1,
@@ -714,28 +714,29 @@ class AudioMediaStreamContext {
714
714
  echoCancellation: !1
715
715
  // 回声消除
716
716
  });
717
- W(this, "stream", new MediaStream());
718
- W(this, "audio", new Audio());
717
+ K(this, "kind", "audio");
718
+ K(this, "stream", new MediaStream());
719
+ K(this, "audio", new Audio());
719
720
  // @ts-ignore 音频上下文
720
- W(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
721
+ K(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
721
722
  // 媒体流音频源节点
722
- W(this, "mediaStreamAudioSourceNode");
723
+ K(this, "mediaStreamAudioSourceNode");
723
724
  // 增益节点 (自动增益)
724
- W(this, "autoGainNode");
725
+ K(this, "autoGainNode");
725
726
  // 滤波器节点 (噪声抑制)
726
- W(this, "biquadFilterNode");
727
+ K(this, "biquadFilterNode");
727
728
  // 延迟节点 (回声消除)
728
- W(this, "delayNode");
729
+ K(this, "delayNode");
729
730
  // 增益节点 (音量控制)
730
- W(this, "gainNode");
731
+ K(this, "gainNode");
731
732
  // 音频分析节点
732
- W(this, "analyserNode");
733
+ K(this, "analyserNode");
733
734
  // 缓冲区 存储分析节点的时域数据
734
- W(this, "analyserArrayData");
735
+ K(this, "analyserArrayData");
735
736
  /**
736
737
  * 停止
737
738
  */
738
- W(this, "stop", () => {
739
+ K(this, "stop", () => {
739
740
  const D = this.stream.getTracks();
740
741
  for (const $ of D)
741
742
  $.enabled = !1, $.stop(), this.stream.removeTrack($);
@@ -743,7 +744,7 @@ class AudioMediaStreamContext {
743
744
  /**
744
745
  * 替换媒体
745
746
  */
746
- W(this, "replaceStream", (D) => {
747
+ K(this, "replaceStream", (D) => {
747
748
  this.stop();
748
749
  const [$] = D.getAudioTracks();
749
750
  this.stream.addTrack($);
@@ -751,23 +752,23 @@ class AudioMediaStreamContext {
751
752
  /**
752
753
  * 获取数据流
753
754
  */
754
- W(this, "getStream", () => this.mediaStreamAudioSourceNode.mediaStream);
755
+ K(this, "getStream", () => this.mediaStreamAudioSourceNode.mediaStream);
755
756
  /**
756
757
  * 静音
757
758
  */
758
- W(this, "setMute", (D = !0) => {
759
+ K(this, "setMute", (D = !0) => {
759
760
  D ? this.analyserNode.disconnect(this.audioContext.destination) : this.analyserNode.connect(this.audioContext.destination);
760
761
  });
761
762
  /**
762
763
  * 设置音量
763
764
  */
764
- W(this, "setVolumeGain", (D) => {
765
+ K(this, "setVolumeGain", (D) => {
765
766
  this.gainNode.gain.setValueAtTime(D, this.audioContext.currentTime);
766
767
  });
767
768
  /**
768
769
  * 获取音量
769
770
  */
770
- W(this, "getVolume", () => {
771
+ K(this, "getVolume", () => {
771
772
  const { analyserNode: D, analyserArrayData: $ } = this;
772
773
  D.getByteFrequencyData($);
773
774
  let U = 0;
@@ -778,12 +779,12 @@ class AudioMediaStreamContext {
778
779
  /**
779
780
  * 设置音频过滤
780
781
  */
781
- W(this, "setFilter", (D = {}) => {
782
+ K(this, "setFilter", (D = {}) => {
782
783
  this.options = { ...this.options, ...D };
783
784
  const { autoGainControl: $, noiseSuppression: U, echoCancellation: R } = this.options, { mediaStreamAudioSourceNode: N, autoGainNode: e, biquadFilterNode: o, delayNode: A, gainNode: M } = this, L = N;
784
785
  return $ && L.connect(e), U && L.connect(o), R && L.connect(A), L.connect(M), D;
785
786
  });
786
- this.stream = D, this.audio.srcObject = this.stream, this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.autoGainNode = this.audioContext.createGain(), this.autoGainNode.gain.setValueAtTime(0.8, this.audioContext.currentTime), this.biquadFilterNode = this.audioContext.createBiquadFilter(), this.biquadFilterNode.type = "lowpass", this.biquadFilterNode.frequency.value = 1e3, this.delayNode = this.audioContext.createDelay(), this.delayNode.delayTime.value = 0.5, this.gainNode = this.audioContext.createGain(), this.gainNode.gain.setValueAtTime(0.5, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 1024, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
787
+ this.stream.addTrack(D), this.audio.srcObject = this.stream, this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.autoGainNode = this.audioContext.createGain(), this.autoGainNode.gain.setValueAtTime(0.8, this.audioContext.currentTime), this.biquadFilterNode = this.audioContext.createBiquadFilter(), this.biquadFilterNode.type = "lowpass", this.biquadFilterNode.frequency.value = 1e3, this.delayNode = this.audioContext.createDelay(), this.delayNode.delayTime.value = 0.5, this.gainNode = this.audioContext.createGain(), this.gainNode.gain.setValueAtTime(0.5, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 1024, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
787
788
  const { gainNode: $, analyserNode: U } = this;
788
789
  $.connect(U), this.audioContext.state === "suspended" ? document.addEventListener(
789
790
  "touchend",
@@ -794,13 +795,14 @@ class AudioMediaStreamContext {
794
795
  ) : this.setFilter();
795
796
  }
796
797
  }
797
- class VideoMediaStreamContext {
798
+ class VideoMediaContext {
798
799
  constructor(D) {
799
- W(this, "stream");
800
+ K(this, "kind", "video");
801
+ K(this, "stream");
800
802
  /**
801
803
  * 停止
802
804
  */
803
- W(this, "stop", () => {
805
+ K(this, "stop", () => {
804
806
  const D = this.stream.getTracks();
805
807
  for (const $ of D)
806
808
  $.enabled = !1, $.stop(), this.stream.removeTrack($);
@@ -808,7 +810,7 @@ class VideoMediaStreamContext {
808
810
  /**
809
811
  * 替换媒体
810
812
  */
811
- W(this, "replaceStream", (D) => {
813
+ K(this, "replaceStream", (D) => {
812
814
  this.stop();
813
815
  const [$] = D.getVideoTracks();
814
816
  this.stream.addTrack($);
@@ -816,7 +818,7 @@ class VideoMediaStreamContext {
816
818
  /**
817
819
  * 获取数据流
818
820
  */
819
- W(this, "getStream", () => this.stream);
821
+ K(this, "getStream", () => this.stream);
820
822
  this.stream = D;
821
823
  }
822
824
  }
@@ -945,16 +947,16 @@ function requireBase64() {
945
947
  U[$[R] = R < 26 ? R + 65 : R < 52 ? R + 71 : R < 62 ? R - 4 : R - 59 | 43] = R++;
946
948
  D.encode = function(o, A, M) {
947
949
  for (var L = null, F = [], Z = 0, H = 0, z; A < M; ) {
948
- var V = o[A++];
950
+ var Y = o[A++];
949
951
  switch (H) {
950
952
  case 0:
951
- F[Z++] = $[V >> 2], z = (V & 3) << 4, H = 1;
953
+ F[Z++] = $[Y >> 2], z = (Y & 3) << 4, H = 1;
952
954
  break;
953
955
  case 1:
954
- F[Z++] = $[z | V >> 4], z = (V & 15) << 2, H = 2;
956
+ F[Z++] = $[z | Y >> 4], z = (Y & 15) << 2, H = 2;
955
957
  break;
956
958
  case 2:
957
- F[Z++] = $[z | V >> 6], F[Z++] = $[V & 63], H = 0;
959
+ F[Z++] = $[z | Y >> 6], F[Z++] = $[Y & 63], H = 0;
958
960
  break;
959
961
  }
960
962
  Z > 8191 && ((L || (L = [])).push(String.fromCharCode.apply(String, F)), Z = 0);
@@ -1031,11 +1033,11 @@ function requireFloat() {
1031
1033
  function _(N) {
1032
1034
  return typeof Float32Array < "u" ? function() {
1033
1035
  var e = new Float32Array([-0]), o = new Uint8Array(e.buffer), A = o[3] === 128;
1034
- function M(H, z, V) {
1035
- e[0] = H, z[V] = o[0], z[V + 1] = o[1], z[V + 2] = o[2], z[V + 3] = o[3];
1036
+ function M(H, z, Y) {
1037
+ e[0] = H, z[Y] = o[0], z[Y + 1] = o[1], z[Y + 2] = o[2], z[Y + 3] = o[3];
1036
1038
  }
1037
- function L(H, z, V) {
1038
- e[0] = H, z[V] = o[3], z[V + 1] = o[2], z[V + 2] = o[1], z[V + 3] = o[0];
1039
+ function L(H, z, Y) {
1040
+ e[0] = H, z[Y] = o[3], z[Y + 1] = o[2], z[Y + 2] = o[1], z[Y + 3] = o[0];
1039
1041
  }
1040
1042
  N.writeFloatLE = A ? M : L, N.writeFloatBE = A ? L : M;
1041
1043
  function F(H, z) {
@@ -1075,11 +1077,11 @@ function requireFloat() {
1075
1077
  N.readFloatLE = o.bind(null, U), N.readFloatBE = o.bind(null, R);
1076
1078
  }(), typeof Float64Array < "u" ? function() {
1077
1079
  var e = new Float64Array([-0]), o = new Uint8Array(e.buffer), A = o[7] === 128;
1078
- function M(H, z, V) {
1079
- e[0] = H, z[V] = o[0], z[V + 1] = o[1], z[V + 2] = o[2], z[V + 3] = o[3], z[V + 4] = o[4], z[V + 5] = o[5], z[V + 6] = o[6], z[V + 7] = o[7];
1080
+ function M(H, z, Y) {
1081
+ e[0] = H, z[Y] = o[0], z[Y + 1] = o[1], z[Y + 2] = o[2], z[Y + 3] = o[3], z[Y + 4] = o[4], z[Y + 5] = o[5], z[Y + 6] = o[6], z[Y + 7] = o[7];
1080
1082
  }
1081
- function L(H, z, V) {
1082
- e[0] = H, z[V] = o[7], z[V + 1] = o[6], z[V + 2] = o[5], z[V + 3] = o[4], z[V + 4] = o[3], z[V + 5] = o[2], z[V + 6] = o[1], z[V + 7] = o[0];
1083
+ function L(H, z, Y) {
1084
+ e[0] = H, z[Y] = o[7], z[Y + 1] = o[6], z[Y + 2] = o[5], z[Y + 3] = o[4], z[Y + 4] = o[3], z[Y + 5] = o[2], z[Y + 6] = o[1], z[Y + 7] = o[0];
1083
1085
  }
1084
1086
  N.writeDoubleLE = A ? M : L, N.writeDoubleBE = A ? L : M;
1085
1087
  function F(H, z) {
@@ -1105,19 +1107,19 @@ function requireFloat() {
1105
1107
  else if (F > 17976931348623157e292)
1106
1108
  A(0, Z, H + M), A((z << 31 | 2146435072) >>> 0, Z, H + L);
1107
1109
  else {
1108
- var V;
1110
+ var Y;
1109
1111
  if (F < 22250738585072014e-324)
1110
- V = F / 5e-324, A(V >>> 0, Z, H + M), A((z << 31 | V / 4294967296) >>> 0, Z, H + L);
1112
+ Y = F / 5e-324, A(Y >>> 0, Z, H + M), A((z << 31 | Y / 4294967296) >>> 0, Z, H + L);
1111
1113
  else {
1112
- var K = Math.floor(Math.log(F) / Math.LN2);
1113
- K === 1024 && (K = 1023), V = F * Math.pow(2, -K), A(V * 4503599627370496 >>> 0, Z, H + M), A((z << 31 | K + 1023 << 20 | V * 1048576 & 1048575) >>> 0, Z, H + L);
1114
+ var W = Math.floor(Math.log(F) / Math.LN2);
1115
+ W === 1024 && (W = 1023), Y = F * Math.pow(2, -W), A(Y * 4503599627370496 >>> 0, Z, H + M), A((z << 31 | W + 1023 << 20 | Y * 1048576 & 1048575) >>> 0, Z, H + L);
1114
1116
  }
1115
1117
  }
1116
1118
  }
1117
1119
  N.writeDoubleLE = e.bind(null, D, 0, 4), N.writeDoubleBE = e.bind(null, $, 4, 0);
1118
1120
  function o(A, M, L, F, Z) {
1119
- var H = A(F, Z + M), z = A(F, Z + L), V = (z >> 31) * 2 + 1, K = z >>> 20 & 2047, J = 4294967296 * (z & 1048575) + H;
1120
- return K === 2047 ? J ? NaN : V * (1 / 0) : K === 0 ? V * 5e-324 * J : V * Math.pow(2, K - 1075) * (J + 4503599627370496);
1121
+ var H = A(F, Z + M), z = A(F, Z + L), Y = (z >> 31) * 2 + 1, W = z >>> 20 & 2047, J = 4294967296 * (z & 1048575) + H;
1122
+ return W === 2047 ? J ? NaN : Y * (1 / 0) : W === 0 ? Y * 5e-324 * J : Y * Math.pow(2, W - 1075) * (J + 4503599627370496);
1121
1123
  }
1122
1124
  N.readDoubleLE = o.bind(null, U, 0, 4), N.readDoubleBE = o.bind(null, R, 4, 0);
1123
1125
  }(), N;
@@ -1390,13 +1392,13 @@ function requireWriter() {
1390
1392
  if (hasRequiredWriter) return writer;
1391
1393
  hasRequiredWriter = 1, writer = A;
1392
1394
  var _ = requireMinimal$1(), D, $ = _.LongBits, U = _.base64, R = _.utf8;
1393
- function N(K, J, G) {
1394
- this.fn = K, this.len = J, this.next = void 0, this.val = G;
1395
+ function N(W, J, V) {
1396
+ this.fn = W, this.len = J, this.next = void 0, this.val = V;
1395
1397
  }
1396
1398
  function e() {
1397
1399
  }
1398
- function o(K) {
1399
- this.head = K.head, this.tail = K.tail, this.len = K.len, this.next = K.states;
1400
+ function o(W) {
1401
+ this.head = W.head, this.tail = W.tail, this.len = W.len, this.next = W.states;
1400
1402
  }
1401
1403
  function A() {
1402
1404
  this.len = 0, this.head = new N(e, 0, 0), this.tail = this.head, this.states = null;
@@ -1412,19 +1414,19 @@ function requireWriter() {
1412
1414
  };
1413
1415
  A.create = M(), A.alloc = function(J) {
1414
1416
  return new _.Array(J);
1415
- }, _.Array !== Array && (A.alloc = _.pool(A.alloc, _.Array.prototype.subarray)), A.prototype._push = function(J, G, tt) {
1416
- return this.tail = this.tail.next = new N(J, G, tt), this.len += G, this;
1417
+ }, _.Array !== Array && (A.alloc = _.pool(A.alloc, _.Array.prototype.subarray)), A.prototype._push = function(J, V, tt) {
1418
+ return this.tail = this.tail.next = new N(J, V, tt), this.len += V, this;
1417
1419
  };
1418
- function L(K, J, G) {
1419
- J[G] = K & 255;
1420
+ function L(W, J, V) {
1421
+ J[V] = W & 255;
1420
1422
  }
1421
- function F(K, J, G) {
1422
- for (; K > 127; )
1423
- J[G++] = K & 127 | 128, K >>>= 7;
1424
- J[G] = K;
1423
+ function F(W, J, V) {
1424
+ for (; W > 127; )
1425
+ J[V++] = W & 127 | 128, W >>>= 7;
1426
+ J[V] = W;
1425
1427
  }
1426
- function Z(K, J) {
1427
- this.len = K, this.next = void 0, this.val = J;
1428
+ function Z(W, J) {
1429
+ this.len = W, this.next = void 0, this.val = J;
1428
1430
  }
1429
1431
  Z.prototype = Object.create(N.prototype), Z.prototype.fn = F, A.prototype.uint32 = function(J) {
1430
1432
  return this.len += (this.tail = this.tail.next = new Z(
@@ -1436,66 +1438,66 @@ function requireWriter() {
1436
1438
  }, A.prototype.sint32 = function(J) {
1437
1439
  return this.uint32((J << 1 ^ J >> 31) >>> 0);
1438
1440
  };
1439
- function H(K, J, G) {
1440
- for (; K.hi; )
1441
- J[G++] = K.lo & 127 | 128, K.lo = (K.lo >>> 7 | K.hi << 25) >>> 0, K.hi >>>= 7;
1442
- for (; K.lo > 127; )
1443
- J[G++] = K.lo & 127 | 128, K.lo = K.lo >>> 7;
1444
- J[G++] = K.lo;
1441
+ function H(W, J, V) {
1442
+ for (; W.hi; )
1443
+ J[V++] = W.lo & 127 | 128, W.lo = (W.lo >>> 7 | W.hi << 25) >>> 0, W.hi >>>= 7;
1444
+ for (; W.lo > 127; )
1445
+ J[V++] = W.lo & 127 | 128, W.lo = W.lo >>> 7;
1446
+ J[V++] = W.lo;
1445
1447
  }
1446
1448
  A.prototype.uint64 = function(J) {
1447
- var G = $.from(J);
1448
- return this._push(H, G.length(), G);
1449
+ var V = $.from(J);
1450
+ return this._push(H, V.length(), V);
1449
1451
  }, A.prototype.int64 = A.prototype.uint64, A.prototype.sint64 = function(J) {
1450
- var G = $.from(J).zzEncode();
1451
- return this._push(H, G.length(), G);
1452
+ var V = $.from(J).zzEncode();
1453
+ return this._push(H, V.length(), V);
1452
1454
  }, A.prototype.bool = function(J) {
1453
1455
  return this._push(L, 1, J ? 1 : 0);
1454
1456
  };
1455
- function z(K, J, G) {
1456
- J[G] = K & 255, J[G + 1] = K >>> 8 & 255, J[G + 2] = K >>> 16 & 255, J[G + 3] = K >>> 24;
1457
+ function z(W, J, V) {
1458
+ J[V] = W & 255, J[V + 1] = W >>> 8 & 255, J[V + 2] = W >>> 16 & 255, J[V + 3] = W >>> 24;
1457
1459
  }
1458
1460
  A.prototype.fixed32 = function(J) {
1459
1461
  return this._push(z, 4, J >>> 0);
1460
1462
  }, A.prototype.sfixed32 = A.prototype.fixed32, A.prototype.fixed64 = function(J) {
1461
- var G = $.from(J);
1462
- return this._push(z, 4, G.lo)._push(z, 4, G.hi);
1463
+ var V = $.from(J);
1464
+ return this._push(z, 4, V.lo)._push(z, 4, V.hi);
1463
1465
  }, A.prototype.sfixed64 = A.prototype.fixed64, A.prototype.float = function(J) {
1464
1466
  return this._push(_.float.writeFloatLE, 4, J);
1465
1467
  }, A.prototype.double = function(J) {
1466
1468
  return this._push(_.float.writeDoubleLE, 8, J);
1467
1469
  };
1468
- var V = _.Array.prototype.set ? function(J, G, tt) {
1469
- G.set(J, tt);
1470
- } : function(J, G, tt) {
1471
- for (var Y = 0; Y < J.length; ++Y)
1472
- G[tt + Y] = J[Y];
1470
+ var Y = _.Array.prototype.set ? function(J, V, tt) {
1471
+ V.set(J, tt);
1472
+ } : function(J, V, tt) {
1473
+ for (var X = 0; X < J.length; ++X)
1474
+ V[tt + X] = J[X];
1473
1475
  };
1474
1476
  return A.prototype.bytes = function(J) {
1475
- var G = J.length >>> 0;
1476
- if (!G)
1477
+ var V = J.length >>> 0;
1478
+ if (!V)
1477
1479
  return this._push(L, 1, 0);
1478
1480
  if (_.isString(J)) {
1479
- var tt = A.alloc(G = U.length(J));
1481
+ var tt = A.alloc(V = U.length(J));
1480
1482
  U.decode(J, tt, 0), J = tt;
1481
1483
  }
1482
- return this.uint32(G)._push(V, G, J);
1484
+ return this.uint32(V)._push(Y, V, J);
1483
1485
  }, A.prototype.string = function(J) {
1484
- var G = R.length(J);
1485
- return G ? this.uint32(G)._push(R.write, G, J) : this._push(L, 1, 0);
1486
+ var V = R.length(J);
1487
+ return V ? this.uint32(V)._push(R.write, V, J) : this._push(L, 1, 0);
1486
1488
  }, A.prototype.fork = function() {
1487
1489
  return this.states = new o(this), this.head = this.tail = new N(e, 0, 0), this.len = 0, this;
1488
1490
  }, A.prototype.reset = function() {
1489
1491
  return this.states ? (this.head = this.states.head, this.tail = this.states.tail, this.len = this.states.len, this.states = this.states.next) : (this.head = this.tail = new N(e, 0, 0), this.len = 0), this;
1490
1492
  }, A.prototype.ldelim = function() {
1491
- var J = this.head, G = this.tail, tt = this.len;
1492
- return this.reset().uint32(tt), tt && (this.tail.next = J.next, this.tail = G, this.len += tt), this;
1493
+ var J = this.head, V = this.tail, tt = this.len;
1494
+ return this.reset().uint32(tt), tt && (this.tail.next = J.next, this.tail = V, this.len += tt), this;
1493
1495
  }, A.prototype.finish = function() {
1494
- for (var J = this.head.next, G = this.constructor.alloc(this.len), tt = 0; J; )
1495
- J.fn(J.val, G, tt), tt += J.len, J = J.next;
1496
- return G;
1497
- }, A._configure = function(K) {
1498
- D = K, A.create = M(), D._configure();
1496
+ for (var J = this.head.next, V = this.constructor.alloc(this.len), tt = 0; J; )
1497
+ J.fn(J.val, V, tt), tt += J.len, J = J.next;
1498
+ return V;
1499
+ }, A._configure = function(W) {
1500
+ D = W, A.create = M(), D._configure();
1499
1501
  }, writer;
1500
1502
  }
1501
1503
  var writer_buffer, hasRequiredWriter_buffer;
@@ -1551,8 +1553,8 @@ function requireReader() {
1551
1553
  throw Error("illegal buffer");
1552
1554
  }, o = function() {
1553
1555
  return _.Buffer ? function(H) {
1554
- return (N.create = function(V) {
1555
- return _.Buffer.isBuffer(V) ? new D(V) : e(V);
1556
+ return (N.create = function(Y) {
1557
+ return _.Buffer.isBuffer(Y) ? new D(Y) : e(Y);
1556
1558
  })(H);
1557
1559
  } : e;
1558
1560
  };
@@ -1639,8 +1641,8 @@ function requireReader() {
1639
1641
  if (this.pos += Z, Array.isArray(this.buf))
1640
1642
  return this.buf.slice(H, z);
1641
1643
  if (H === z) {
1642
- var V = _.Buffer;
1643
- return V ? V.alloc(0) : new this.buf.constructor(0);
1644
+ var Y = _.Buffer;
1645
+ return Y ? Y.alloc(0) : new this.buf.constructor(0);
1644
1646
  }
1645
1647
  return this._slice.call(this.buf, H, z);
1646
1648
  }, N.prototype.string = function() {
@@ -4545,13 +4547,16 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
4545
4547
  onNetQuality: "网络质量回调",
4546
4548
  onLogin: "登录回调",
4547
4549
  onLocalStream: "更新本地媒体流",
4548
- onRoomUsers: "房间用户变化",
4550
+ onRoomUser: "房间用户变化",
4551
+ onRoomUserStreams: "房间用户媒体流变化",
4552
+ onRoomUsers: "房间所有用户所有变化",
4549
4553
  onRoomState: "房间状态变化",
4550
4554
  onJoinRoom: "加入房间回调",
4551
4555
  onQuitRoom: "退出房间回调",
4552
4556
  onPublish: "监听到流发布",
4553
4557
  onCloseTrack: "关闭轨道",
4554
4558
  onUpdateCall: "更新通讯状态",
4559
+ onUpdateStreams: "更新媒体流",
4555
4560
  onUpdatePermissions: "更新推流权限通知",
4556
4561
  onTokenExpired: "Token已过期",
4557
4562
  onDestroyRoom: "直播模式房间销毁",
@@ -4616,17 +4621,17 @@ const d_code = (_) => _ < 256 ? _dist_code[_] : _dist_code[256 + (_ >>> 7)], put
4616
4621
  _.bi_valid === 16 ? (put_short(_, _.bi_buf), _.bi_buf = 0, _.bi_valid = 0) : _.bi_valid >= 8 && (_.pending_buf[_.pending++] = _.bi_buf & 255, _.bi_buf >>= 8, _.bi_valid -= 8);
4617
4622
  }, gen_bitlen = (_, D) => {
4618
4623
  const $ = D.dyn_tree, U = D.max_code, R = D.stat_desc.static_tree, N = D.stat_desc.has_stree, e = D.stat_desc.extra_bits, o = D.stat_desc.extra_base, A = D.stat_desc.max_length;
4619
- let M, L, F, Z, H, z, V = 0;
4624
+ let M, L, F, Z, H, z, Y = 0;
4620
4625
  for (Z = 0; Z <= MAX_BITS$1; Z++)
4621
4626
  _.bl_count[Z] = 0;
4622
4627
  for ($[_.heap[_.heap_max] * 2 + 1] = 0, M = _.heap_max + 1; M < HEAP_SIZE$1; M++)
4623
- L = _.heap[M], Z = $[$[L * 2 + 1] * 2 + 1] + 1, Z > A && (Z = A, V++), $[L * 2 + 1] = Z, !(L > U) && (_.bl_count[Z]++, H = 0, L >= o && (H = e[L - o]), z = $[L * 2], _.opt_len += z * (Z + H), N && (_.static_len += z * (R[L * 2 + 1] + H)));
4624
- if (V !== 0) {
4628
+ L = _.heap[M], Z = $[$[L * 2 + 1] * 2 + 1] + 1, Z > A && (Z = A, Y++), $[L * 2 + 1] = Z, !(L > U) && (_.bl_count[Z]++, H = 0, L >= o && (H = e[L - o]), z = $[L * 2], _.opt_len += z * (Z + H), N && (_.static_len += z * (R[L * 2 + 1] + H)));
4629
+ if (Y !== 0) {
4625
4630
  do {
4626
4631
  for (Z = A - 1; _.bl_count[Z] === 0; )
4627
4632
  Z--;
4628
- _.bl_count[Z]--, _.bl_count[Z + 1] += 2, _.bl_count[A]--, V -= 2;
4629
- } while (V > 0);
4633
+ _.bl_count[Z]--, _.bl_count[Z + 1] += 2, _.bl_count[A]--, Y -= 2;
4634
+ } while (Y > 0);
4630
4635
  for (Z = A; Z !== 0; Z--)
4631
4636
  for (L = _.bl_count[Z]; L !== 0; )
4632
4637
  F = _.heap[--M], !(F > U) && ($[F * 2 + 1] !== Z && (_.opt_len += (Z - $[F * 2 + 1]) * $[F * 2], $[F * 2 + 1] = Z), L--);
@@ -5411,71 +5416,71 @@ var Deflate_1$1 = Deflate$1, deflate_2 = deflate$1, deflateRaw_1$1 = deflateRaw$
5411
5416
  };
5412
5417
  const BAD$1 = 16209, TYPE$1 = 16191;
5413
5418
  var inffast = function _(D, $) {
5414
- let U, R, N, e, o, A, M, L, F, Z, H, z, V, K, J, G, tt, Y, nt, st, et, at, ct, ot;
5419
+ let U, R, N, e, o, A, M, L, F, Z, H, z, Y, W, J, V, tt, X, nt, lt, et, at, ct, ot;
5415
5420
  const rt = D.state;
5416
- U = D.next_in, ct = D.input, R = U + (D.avail_in - 5), N = D.next_out, ot = D.output, e = N - ($ - D.avail_out), o = N + (D.avail_out - 257), A = rt.dmax, M = rt.wsize, L = rt.whave, F = rt.wnext, Z = rt.window, H = rt.hold, z = rt.bits, V = rt.lencode, K = rt.distcode, J = (1 << rt.lenbits) - 1, G = (1 << rt.distbits) - 1;
5421
+ U = D.next_in, ct = D.input, R = U + (D.avail_in - 5), N = D.next_out, ot = D.output, e = N - ($ - D.avail_out), o = N + (D.avail_out - 257), A = rt.dmax, M = rt.wsize, L = rt.whave, F = rt.wnext, Z = rt.window, H = rt.hold, z = rt.bits, Y = rt.lencode, W = rt.distcode, J = (1 << rt.lenbits) - 1, V = (1 << rt.distbits) - 1;
5417
5422
  t:
5418
5423
  do {
5419
- z < 15 && (H += ct[U++] << z, z += 8, H += ct[U++] << z, z += 8), tt = V[H & J];
5424
+ z < 15 && (H += ct[U++] << z, z += 8, H += ct[U++] << z, z += 8), tt = Y[H & J];
5420
5425
  e:
5421
5426
  for (; ; ) {
5422
- if (Y = tt >>> 24, H >>>= Y, z -= Y, Y = tt >>> 16 & 255, Y === 0)
5427
+ if (X = tt >>> 24, H >>>= X, z -= X, X = tt >>> 16 & 255, X === 0)
5423
5428
  ot[N++] = tt & 65535;
5424
- else if (Y & 16) {
5425
- nt = tt & 65535, Y &= 15, Y && (z < Y && (H += ct[U++] << z, z += 8), nt += H & (1 << Y) - 1, H >>>= Y, z -= Y), z < 15 && (H += ct[U++] << z, z += 8, H += ct[U++] << z, z += 8), tt = K[H & G];
5429
+ else if (X & 16) {
5430
+ nt = tt & 65535, X &= 15, X && (z < X && (H += ct[U++] << z, z += 8), nt += H & (1 << X) - 1, H >>>= X, z -= X), z < 15 && (H += ct[U++] << z, z += 8, H += ct[U++] << z, z += 8), tt = W[H & V];
5426
5431
  i:
5427
5432
  for (; ; ) {
5428
- if (Y = tt >>> 24, H >>>= Y, z -= Y, Y = tt >>> 16 & 255, Y & 16) {
5429
- if (st = tt & 65535, Y &= 15, z < Y && (H += ct[U++] << z, z += 8, z < Y && (H += ct[U++] << z, z += 8)), st += H & (1 << Y) - 1, st > A) {
5433
+ if (X = tt >>> 24, H >>>= X, z -= X, X = tt >>> 16 & 255, X & 16) {
5434
+ if (lt = tt & 65535, X &= 15, z < X && (H += ct[U++] << z, z += 8, z < X && (H += ct[U++] << z, z += 8)), lt += H & (1 << X) - 1, lt > A) {
5430
5435
  D.msg = "invalid distance too far back", rt.mode = BAD$1;
5431
5436
  break t;
5432
5437
  }
5433
- if (H >>>= Y, z -= Y, Y = N - e, st > Y) {
5434
- if (Y = st - Y, Y > L && rt.sane) {
5438
+ if (H >>>= X, z -= X, X = N - e, lt > X) {
5439
+ if (X = lt - X, X > L && rt.sane) {
5435
5440
  D.msg = "invalid distance too far back", rt.mode = BAD$1;
5436
5441
  break t;
5437
5442
  }
5438
5443
  if (et = 0, at = Z, F === 0) {
5439
- if (et += M - Y, Y < nt) {
5440
- nt -= Y;
5444
+ if (et += M - X, X < nt) {
5445
+ nt -= X;
5441
5446
  do
5442
5447
  ot[N++] = Z[et++];
5443
- while (--Y);
5444
- et = N - st, at = ot;
5448
+ while (--X);
5449
+ et = N - lt, at = ot;
5445
5450
  }
5446
- } else if (F < Y) {
5447
- if (et += M + F - Y, Y -= F, Y < nt) {
5448
- nt -= Y;
5451
+ } else if (F < X) {
5452
+ if (et += M + F - X, X -= F, X < nt) {
5453
+ nt -= X;
5449
5454
  do
5450
5455
  ot[N++] = Z[et++];
5451
- while (--Y);
5456
+ while (--X);
5452
5457
  if (et = 0, F < nt) {
5453
- Y = F, nt -= Y;
5458
+ X = F, nt -= X;
5454
5459
  do
5455
5460
  ot[N++] = Z[et++];
5456
- while (--Y);
5457
- et = N - st, at = ot;
5461
+ while (--X);
5462
+ et = N - lt, at = ot;
5458
5463
  }
5459
5464
  }
5460
- } else if (et += F - Y, Y < nt) {
5461
- nt -= Y;
5465
+ } else if (et += F - X, X < nt) {
5466
+ nt -= X;
5462
5467
  do
5463
5468
  ot[N++] = Z[et++];
5464
- while (--Y);
5465
- et = N - st, at = ot;
5469
+ while (--X);
5470
+ et = N - lt, at = ot;
5466
5471
  }
5467
5472
  for (; nt > 2; )
5468
5473
  ot[N++] = at[et++], ot[N++] = at[et++], ot[N++] = at[et++], nt -= 3;
5469
5474
  nt && (ot[N++] = at[et++], nt > 1 && (ot[N++] = at[et++]));
5470
5475
  } else {
5471
- et = N - st;
5476
+ et = N - lt;
5472
5477
  do
5473
5478
  ot[N++] = ot[et++], ot[N++] = ot[et++], ot[N++] = ot[et++], nt -= 3;
5474
5479
  while (nt > 2);
5475
5480
  nt && (ot[N++] = ot[et++], nt > 1 && (ot[N++] = ot[et++]));
5476
5481
  }
5477
- } else if ((Y & 64) === 0) {
5478
- tt = K[(tt & 65535) + (H & (1 << Y) - 1)];
5482
+ } else if ((X & 64) === 0) {
5483
+ tt = W[(tt & 65535) + (H & (1 << X) - 1)];
5479
5484
  continue i;
5480
5485
  } else {
5481
5486
  D.msg = "invalid distance code", rt.mode = BAD$1;
@@ -5483,10 +5488,10 @@ var inffast = function _(D, $) {
5483
5488
  }
5484
5489
  break;
5485
5490
  }
5486
- } else if ((Y & 64) === 0) {
5487
- tt = V[(tt & 65535) + (H & (1 << Y) - 1)];
5491
+ } else if ((X & 64) === 0) {
5492
+ tt = Y[(tt & 65535) + (H & (1 << X) - 1)];
5488
5493
  continue e;
5489
- } else if (Y & 32) {
5494
+ } else if (X & 32) {
5490
5495
  rt.mode = TYPE$1;
5491
5496
  break t;
5492
5497
  } else {
@@ -5634,9 +5639,9 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
5634
5639
  64
5635
5640
  ]), inflate_table = (_, D, $, U, R, N, e, o) => {
5636
5641
  const A = o.bits;
5637
- let M = 0, L = 0, F = 0, Z = 0, H = 0, z = 0, V = 0, K = 0, J = 0, G = 0, tt, Y, nt, st, et, at = null, ct;
5642
+ let M = 0, L = 0, F = 0, Z = 0, H = 0, z = 0, Y = 0, W = 0, J = 0, V = 0, tt, X, nt, lt, et, at = null, ct;
5638
5643
  const ot = new Uint16Array(MAXBITS + 1), rt = new Uint16Array(MAXBITS + 1);
5639
- let bt = null, Zt, It, Rt;
5644
+ let St = null, Gt, Nt, At;
5640
5645
  for (M = 0; M <= MAXBITS; M++)
5641
5646
  ot[M] = 0;
5642
5647
  for (L = 0; L < U; L++)
@@ -5647,38 +5652,38 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
5647
5652
  return R[N++] = 1 << 24 | 64 << 16 | 0, R[N++] = 1 << 24 | 64 << 16 | 0, o.bits = 1, 0;
5648
5653
  for (F = 1; F < Z && ot[F] === 0; F++)
5649
5654
  ;
5650
- for (H < F && (H = F), K = 1, M = 1; M <= MAXBITS; M++)
5651
- if (K <<= 1, K -= ot[M], K < 0)
5655
+ for (H < F && (H = F), W = 1, M = 1; M <= MAXBITS; M++)
5656
+ if (W <<= 1, W -= ot[M], W < 0)
5652
5657
  return -1;
5653
- if (K > 0 && (_ === CODES$1 || Z !== 1))
5658
+ if (W > 0 && (_ === CODES$1 || Z !== 1))
5654
5659
  return -1;
5655
5660
  for (rt[1] = 0, M = 1; M < MAXBITS; M++)
5656
5661
  rt[M + 1] = rt[M] + ot[M];
5657
5662
  for (L = 0; L < U; L++)
5658
5663
  D[$ + L] !== 0 && (e[rt[D[$ + L]]++] = L);
5659
- if (_ === CODES$1 ? (at = bt = e, ct = 20) : _ === LENS$1 ? (at = lbase, bt = lext, ct = 257) : (at = dbase, bt = dext, ct = 0), G = 0, L = 0, M = F, et = N, z = H, V = 0, nt = -1, J = 1 << H, st = J - 1, _ === LENS$1 && J > ENOUGH_LENS$1 || _ === DISTS$1 && J > ENOUGH_DISTS$1)
5664
+ if (_ === CODES$1 ? (at = St = e, ct = 20) : _ === LENS$1 ? (at = lbase, St = lext, ct = 257) : (at = dbase, St = dext, ct = 0), V = 0, L = 0, M = F, et = N, z = H, Y = 0, nt = -1, J = 1 << H, lt = J - 1, _ === LENS$1 && J > ENOUGH_LENS$1 || _ === DISTS$1 && J > ENOUGH_DISTS$1)
5660
5665
  return 1;
5661
5666
  for (; ; ) {
5662
- Zt = M - V, e[L] + 1 < ct ? (It = 0, Rt = e[L]) : e[L] >= ct ? (It = bt[e[L] - ct], Rt = at[e[L] - ct]) : (It = 96, Rt = 0), tt = 1 << M - V, Y = 1 << z, F = Y;
5667
+ Gt = M - Y, e[L] + 1 < ct ? (Nt = 0, At = e[L]) : e[L] >= ct ? (Nt = St[e[L] - ct], At = at[e[L] - ct]) : (Nt = 96, At = 0), tt = 1 << M - Y, X = 1 << z, F = X;
5663
5668
  do
5664
- Y -= tt, R[et + (G >> V) + Y] = Zt << 24 | It << 16 | Rt | 0;
5665
- while (Y !== 0);
5666
- for (tt = 1 << M - 1; G & tt; )
5669
+ X -= tt, R[et + (V >> Y) + X] = Gt << 24 | Nt << 16 | At | 0;
5670
+ while (X !== 0);
5671
+ for (tt = 1 << M - 1; V & tt; )
5667
5672
  tt >>= 1;
5668
- if (tt !== 0 ? (G &= tt - 1, G += tt) : G = 0, L++, --ot[M] === 0) {
5673
+ if (tt !== 0 ? (V &= tt - 1, V += tt) : V = 0, L++, --ot[M] === 0) {
5669
5674
  if (M === Z)
5670
5675
  break;
5671
5676
  M = D[$ + e[L]];
5672
5677
  }
5673
- if (M > H && (G & st) !== nt) {
5674
- for (V === 0 && (V = H), et += F, z = M - V, K = 1 << z; z + V < Z && (K -= ot[z + V], !(K <= 0)); )
5675
- z++, K <<= 1;
5678
+ if (M > H && (V & lt) !== nt) {
5679
+ for (Y === 0 && (Y = H), et += F, z = M - Y, W = 1 << z; z + Y < Z && (W -= ot[z + Y], !(W <= 0)); )
5680
+ z++, W <<= 1;
5676
5681
  if (J += 1 << z, _ === LENS$1 && J > ENOUGH_LENS$1 || _ === DISTS$1 && J > ENOUGH_DISTS$1)
5677
5682
  return 1;
5678
- nt = G & st, R[nt] = H << 24 | z << 16 | et - N | 0;
5683
+ nt = V & lt, R[nt] = H << 24 | z << 16 | et - N | 0;
5679
5684
  }
5680
5685
  }
5681
- return G !== 0 && (R[et + G] = M - V << 24 | 64 << 16 | 0), o.bits = H, 0;
5686
+ return V !== 0 && (R[et + V] = M - Y << 24 | 64 << 16 | 0), o.bits = H, 0;
5682
5687
  };
5683
5688
  var inftrees = inflate_table;
5684
5689
  const CODES = 0, LENS = 1, DISTS = 2, {
@@ -5749,10 +5754,10 @@ const fixedtables = (_) => {
5749
5754
  const N = _.state;
5750
5755
  return N.window === null && (N.wsize = 1 << N.wbits, N.wnext = 0, N.whave = 0, N.window = new Uint8Array(N.wsize)), U >= N.wsize ? (N.window.set(D.subarray($ - N.wsize, $), 0), N.wnext = 0, N.whave = N.wsize) : (R = N.wsize - N.wnext, R > U && (R = U), N.window.set(D.subarray($ - U, $ - U + R), N.wnext), U -= R, U ? (N.window.set(D.subarray($ - U, $), 0), N.wnext = U, N.whave = N.wsize) : (N.wnext += R, N.wnext === N.wsize && (N.wnext = 0), N.whave < N.wsize && (N.whave += R))), 0;
5751
5756
  }, inflate$2 = (_, D) => {
5752
- let $, U, R, N, e, o, A, M, L, F, Z, H, z, V, K = 0, J, G, tt, Y, nt, st, et, at;
5757
+ let $, U, R, N, e, o, A, M, L, F, Z, H, z, Y, W = 0, J, V, tt, X, nt, lt, et, at;
5753
5758
  const ct = new Uint8Array(4);
5754
5759
  let ot, rt;
5755
- const bt = (
5760
+ const St = (
5756
5761
  /* permutation of code lengths */
5757
5762
  new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])
5758
5763
  );
@@ -5978,10 +5983,10 @@ const fixedtables = (_) => {
5978
5983
  break t;
5979
5984
  o--, M += U[N++] << L, L += 8;
5980
5985
  }
5981
- $.lens[bt[$.have++]] = M & 7, M >>>= 3, L -= 3;
5986
+ $.lens[St[$.have++]] = M & 7, M >>>= 3, L -= 3;
5982
5987
  }
5983
5988
  for (; $.have < 19; )
5984
- $.lens[bt[$.have++]] = 0;
5989
+ $.lens[St[$.have++]] = 0;
5985
5990
  if ($.lencode = $.lendyn, $.lenbits = 7, ot = { bits: $.lenbits }, at = inftrees(CODES, $.lens, 0, 19, $.lencode, 0, $.work, ot), $.lenbits = ot.bits, at) {
5986
5991
  _.msg = "invalid code lengths set", $.mode = BAD;
5987
5992
  break;
@@ -5990,7 +5995,7 @@ const fixedtables = (_) => {
5990
5995
  /* falls through */
5991
5996
  case CODELENS:
5992
5997
  for (; $.have < $.nlen + $.ndist; ) {
5993
- for (; K = $.lencode[M & (1 << $.lenbits) - 1], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(J <= L); ) {
5998
+ for (; W = $.lencode[M & (1 << $.lenbits) - 1], J = W >>> 24, V = W >>> 16 & 255, tt = W & 65535, !(J <= L); ) {
5994
5999
  if (o === 0)
5995
6000
  break t;
5996
6001
  o--, M += U[N++] << L, L += 8;
@@ -6057,32 +6062,32 @@ const fixedtables = (_) => {
6057
6062
  _.next_out = e, _.avail_out = A, _.next_in = N, _.avail_in = o, $.hold = M, $.bits = L, inffast(_, Z), e = _.next_out, R = _.output, A = _.avail_out, N = _.next_in, U = _.input, o = _.avail_in, M = $.hold, L = $.bits, $.mode === TYPE && ($.back = -1);
6058
6063
  break;
6059
6064
  }
6060
- for ($.back = 0; K = $.lencode[M & (1 << $.lenbits) - 1], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(J <= L); ) {
6065
+ for ($.back = 0; W = $.lencode[M & (1 << $.lenbits) - 1], J = W >>> 24, V = W >>> 16 & 255, tt = W & 65535, !(J <= L); ) {
6061
6066
  if (o === 0)
6062
6067
  break t;
6063
6068
  o--, M += U[N++] << L, L += 8;
6064
6069
  }
6065
- if (G && (G & 240) === 0) {
6066
- for (Y = J, nt = G, st = tt; K = $.lencode[st + ((M & (1 << Y + nt) - 1) >> Y)], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(Y + J <= L); ) {
6070
+ if (V && (V & 240) === 0) {
6071
+ for (X = J, nt = V, lt = tt; W = $.lencode[lt + ((M & (1 << X + nt) - 1) >> X)], J = W >>> 24, V = W >>> 16 & 255, tt = W & 65535, !(X + J <= L); ) {
6067
6072
  if (o === 0)
6068
6073
  break t;
6069
6074
  o--, M += U[N++] << L, L += 8;
6070
6075
  }
6071
- M >>>= Y, L -= Y, $.back += Y;
6076
+ M >>>= X, L -= X, $.back += X;
6072
6077
  }
6073
- if (M >>>= J, L -= J, $.back += J, $.length = tt, G === 0) {
6078
+ if (M >>>= J, L -= J, $.back += J, $.length = tt, V === 0) {
6074
6079
  $.mode = LIT;
6075
6080
  break;
6076
6081
  }
6077
- if (G & 32) {
6082
+ if (V & 32) {
6078
6083
  $.back = -1, $.mode = TYPE;
6079
6084
  break;
6080
6085
  }
6081
- if (G & 64) {
6086
+ if (V & 64) {
6082
6087
  _.msg = "invalid literal/length code", $.mode = BAD;
6083
6088
  break;
6084
6089
  }
6085
- $.extra = G & 15, $.mode = LENEXT;
6090
+ $.extra = V & 15, $.mode = LENEXT;
6086
6091
  /* falls through */
6087
6092
  case LENEXT:
6088
6093
  if ($.extra) {
@@ -6096,24 +6101,24 @@ const fixedtables = (_) => {
6096
6101
  $.was = $.length, $.mode = DIST;
6097
6102
  /* falls through */
6098
6103
  case DIST:
6099
- for (; K = $.distcode[M & (1 << $.distbits) - 1], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(J <= L); ) {
6104
+ for (; W = $.distcode[M & (1 << $.distbits) - 1], J = W >>> 24, V = W >>> 16 & 255, tt = W & 65535, !(J <= L); ) {
6100
6105
  if (o === 0)
6101
6106
  break t;
6102
6107
  o--, M += U[N++] << L, L += 8;
6103
6108
  }
6104
- if ((G & 240) === 0) {
6105
- for (Y = J, nt = G, st = tt; K = $.distcode[st + ((M & (1 << Y + nt) - 1) >> Y)], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(Y + J <= L); ) {
6109
+ if ((V & 240) === 0) {
6110
+ for (X = J, nt = V, lt = tt; W = $.distcode[lt + ((M & (1 << X + nt) - 1) >> X)], J = W >>> 24, V = W >>> 16 & 255, tt = W & 65535, !(X + J <= L); ) {
6106
6111
  if (o === 0)
6107
6112
  break t;
6108
6113
  o--, M += U[N++] << L, L += 8;
6109
6114
  }
6110
- M >>>= Y, L -= Y, $.back += Y;
6115
+ M >>>= X, L -= X, $.back += X;
6111
6116
  }
6112
- if (M >>>= J, L -= J, $.back += J, G & 64) {
6117
+ if (M >>>= J, L -= J, $.back += J, V & 64) {
6113
6118
  _.msg = "invalid distance code", $.mode = BAD;
6114
6119
  break;
6115
6120
  }
6116
- $.offset = tt, $.extra = G & 15, $.mode = DISTEXT;
6121
+ $.offset = tt, $.extra = V & 15, $.mode = DISTEXT;
6117
6122
  /* falls through */
6118
6123
  case DISTEXT:
6119
6124
  if ($.extra) {
@@ -6138,12 +6143,12 @@ const fixedtables = (_) => {
6138
6143
  _.msg = "invalid distance too far back", $.mode = BAD;
6139
6144
  break;
6140
6145
  }
6141
- H > $.wnext ? (H -= $.wnext, z = $.wsize - H) : z = $.wnext - H, H > $.length && (H = $.length), V = $.window;
6146
+ H > $.wnext ? (H -= $.wnext, z = $.wsize - H) : z = $.wnext - H, H > $.length && (H = $.length), Y = $.window;
6142
6147
  } else
6143
- V = R, z = e - $.offset, H = $.length;
6148
+ Y = R, z = e - $.offset, H = $.length;
6144
6149
  H > A && (H = A), A -= H, $.length -= H;
6145
6150
  do
6146
- R[e++] = V[z++];
6151
+ R[e++] = Y[z++];
6147
6152
  while (--H);
6148
6153
  $.length === 0 && ($.mode = LEN);
6149
6154
  break;
@@ -6423,12 +6428,12 @@ const compressArrayBuffer = (_) => {
6423
6428
  }
6424
6429
  return _;
6425
6430
  }, checkReconnect = (_) => !0;
6426
- var _t, ft, gt, St, kt, dt, ht, Et, $t, Tt, xt, Nt, At, qt;
6431
+ var yt, ft, Rt, $t, bt, dt, ht, qt, Et, xt, Dt, Ct, Ut, Mt;
6427
6432
  class CallsWebSocket {
6428
6433
  // 重连停止的回调
6429
6434
  constructor(D) {
6430
- lt(this, _t);
6431
- lt(this, ft, {
6435
+ st(this, yt);
6436
+ st(this, ft, {
6432
6437
  url: "wss://demo.putplay.cc/websocket",
6433
6438
  // 地址
6434
6439
  debug: !1,
@@ -6437,29 +6442,29 @@ class CallsWebSocket {
6437
6442
  // 最大重连次数
6438
6443
  timeout: 30 * 1e3
6439
6444
  });
6440
- lt(this, gt, "");
6445
+ st(this, Rt, "");
6441
6446
  // 缓存登录凭证
6442
- lt(this, St, !1);
6447
+ st(this, $t, !1);
6443
6448
  // 是否在房间内
6444
- lt(this, kt, 0);
6449
+ st(this, bt, 0);
6445
6450
  // 活性时间戳 根据服务端的响应来更新当前连接活性 活性为0 说明连接已经存在异常进行重连
6446
- lt(this, dt, {});
6447
- lt(this, ht, {});
6448
- W(this, "onReconnectSuccess", async (D) => {
6451
+ st(this, dt, {});
6452
+ st(this, ht, {});
6453
+ K(this, "onReconnectSuccess", async (D) => {
6449
6454
  });
6450
6455
  // 重连成功的回调
6451
- W(this, "onReconnectStop", async (D) => {
6456
+ K(this, "onReconnectStop", async (D) => {
6452
6457
  });
6453
6458
  // 自定义心跳规则
6454
- lt(this, Et, () => X(this, St) ? com.quick.voice.proto.CommonReq.encode({ event: "heartbeat", sn: +`${O(1e5, 999999)}` }).finish() : "");
6459
+ st(this, qt, () => G(this, $t) ? com.quick.voice.proto.CommonReq.encode({ event: "heartbeat", sn: +`${O(1e5, 999999)}` }).finish() : "");
6455
6460
  // 更新日志
6456
- lt(this, $t, (D, $ = {}) => {
6461
+ st(this, Et, (D, $ = {}) => {
6457
6462
  try {
6458
6463
  const { time: U, event: R, data: N = {}, data_original: e = {}, data_remote: o, ...A } = $, M = E(U, "YYYY-MM-DD hh:mm:ss", { offset: 480 });
6459
6464
  let L = {};
6460
- const F = (G = {}) => {
6461
- const tt = JSON.parse(JSON.stringify(G)), Y = Object.keys(tt);
6462
- for (const nt of Y)
6465
+ const F = (V = {}) => {
6466
+ const tt = JSON.parse(JSON.stringify(V)), X = Object.keys(tt);
6467
+ for (const nt of X)
6463
6468
  (nt.includes("sdp") || nt.includes("Sdp")) && (tt[nt] = "");
6464
6469
  return tt;
6465
6470
  };
@@ -6474,105 +6479,105 @@ class CallsWebSocket {
6474
6479
  }
6475
6480
  let H = "#quickvo.logs";
6476
6481
  ignoreEvent.includes(R) && (H = "#quickvo.ignoreEvents");
6477
- const z = { "#action": Z, timeStr: M, event: R, data: L, time: U, ...A }, V = localStorage.getItem(H) || JSON.stringify([]), K = JSON.parse(V), J = [z, ...K].slice(0, 500);
6482
+ const z = { "#action": Z, timeStr: M, event: R, data: L, time: U, ...A }, Y = localStorage.getItem(H) || JSON.stringify([]), W = JSON.parse(Y), J = [z, ...W].slice(0, 500);
6478
6483
  localStorage.setItem(H, JSON.stringify(J));
6479
6484
  } catch (U) {
6480
6485
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: updataLogs is error", U);
6481
6486
  }
6482
6487
  });
6483
6488
  // 活性检查器 每次发送消息前 、 接收消息后 都会调用进行检查
6484
- lt(this, Tt, (D) => new Promise(async ($) => {
6489
+ st(this, xt, (D) => new Promise(async ($) => {
6485
6490
  const { event: U } = D, R = Date.now();
6486
- U === "healthCheck" && (yt(this, kt, R), X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 刷新活性", { activetimeStamp: X(this, kt), activetimeStampStr: E(X(this, kt)) }));
6487
- const N = 30 * 1e3 + X(this, ft).timeout;
6488
- R - X(this, kt) >= N && X(this, _t) && (X(this, ft).debug && console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 活性超时, 尝试重新建立连接", X(this, _t)), await this.connect()), $(X(this, _t));
6491
+ U === "healthCheck" && (_t(this, bt, R), G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 刷新活性", { activetimeStamp: G(this, bt), activetimeStampStr: E(G(this, bt)) }));
6492
+ const N = 30 * 1e3 + G(this, ft).timeout;
6493
+ R - G(this, bt) >= N && G(this, yt) && (G(this, ft).debug && console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 活性超时, 尝试重新建立连接", G(this, yt)), await this.connect()), $(G(this, yt));
6489
6494
  }));
6490
6495
  // 清除事件
6491
- W(this, "clearEvents", (D = []) => {
6492
- const $ = Object.keys(X(this, dt));
6496
+ K(this, "clearEvents", (D = []) => {
6497
+ const $ = Object.keys(G(this, dt));
6493
6498
  D.length === 0 && (D = $);
6494
6499
  for (const U of $) {
6495
6500
  if (!D.includes(U)) continue;
6496
- const R = X(this, dt)[U];
6497
- clearTimeout(R.destructionTimer), delete X(this, dt)[U];
6501
+ const R = G(this, dt)[U];
6502
+ clearTimeout(R.destructionTimer), delete G(this, dt)[U];
6498
6503
  }
6499
6504
  });
6500
6505
  // 创建事件
6501
- lt(this, xt, (D, { resolve: $, reject: U }) => {
6506
+ st(this, Dt, (D, { resolve: $, reject: U }) => {
6502
6507
  const { sn: R } = D, N = () => {
6503
- const o = X(this, dt)[R];
6504
- clearTimeout(o.destructionTimer), delete X(this, dt)[R];
6508
+ const o = G(this, dt)[R];
6509
+ clearTimeout(o.destructionTimer), delete G(this, dt)[R];
6505
6510
  }, e = setTimeout(() => {
6506
- const o = X(this, dt)[R];
6511
+ const o = G(this, dt)[R];
6507
6512
  console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo:event is timeout", o.message), N(), U("event is timeout");
6508
- }, X(this, ft).timeout);
6509
- X(this, dt)[R] = { message: D, resolve: $, reject: U, destruction: N, destructionTimer: e };
6513
+ }, G(this, ft).timeout);
6514
+ G(this, dt)[R] = { message: D, resolve: $, reject: U, destruction: N, destructionTimer: e };
6510
6515
  });
6511
6516
  // 获取事件
6512
- lt(this, Nt, (D) => X(this, dt)[D]);
6517
+ st(this, Ct, (D) => G(this, dt)[D]);
6513
6518
  // 重连成功
6514
- lt(this, At, async (D) => {
6519
+ st(this, Ut, async (D) => {
6515
6520
  const $ = Date.now();
6516
- yt(this, kt, $), X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重置活性", { activetimeStamp: X(this, kt), activetimeStampStr: E(X(this, kt)) }), await this.onReconnectSuccess(D);
6521
+ _t(this, bt, $), G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重置活性", { activetimeStamp: G(this, bt), activetimeStampStr: E(G(this, bt)) }), await this.onReconnectSuccess(D);
6517
6522
  });
6518
6523
  /**
6519
6524
  * 连接
6520
6525
  * @param session
6521
6526
  * @returns
6522
6527
  */
6523
- W(this, "connect", async (D = "") => {
6524
- D && yt(this, gt, D), X(this, _t) && await X(this, _t).close();
6525
- const $ = `${X(this, ft).url}?s=${X(this, gt)}&t=${Date.now()}`;
6526
- return yt(this, _t, new k$1({
6527
- ...X(this, ft),
6528
+ K(this, "connect", async (D = "") => {
6529
+ D && _t(this, Rt, D), G(this, yt) && await G(this, yt).close();
6530
+ const $ = `${G(this, ft).url}?s=${G(this, Rt)}&t=${Date.now()}`;
6531
+ return _t(this, yt, new k$1({
6532
+ ...G(this, ft),
6528
6533
  url: $,
6529
6534
  binaryType: "arraybuffer",
6530
- onMessage: X(this, qt),
6535
+ onMessage: G(this, Mt),
6531
6536
  checkReconnect,
6532
- getHeartbeatMsg: X(this, Et),
6533
- onReconnectSuccess: X(this, At),
6537
+ getHeartbeatMsg: G(this, qt),
6538
+ onReconnectSuccess: G(this, Ut),
6534
6539
  onReconnectStop: (U) => this.onReconnectStop(U)
6535
- })), await X(this, _t).connect(), yt(this, kt, Date.now()), X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", X(this, ht)), X(this, _t);
6540
+ })), await G(this, yt).connect(), _t(this, bt, Date.now()), G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", G(this, ht)), G(this, yt);
6536
6541
  });
6537
6542
  /**
6538
6543
  * 关闭
6539
6544
  */
6540
- W(this, "close", async () => {
6545
+ K(this, "close", async () => {
6541
6546
  var $;
6542
- X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: cws is close.");
6543
- const D = Object.keys(X(this, dt));
6547
+ G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: cws is close.");
6548
+ const D = Object.keys(G(this, dt));
6544
6549
  for (const U of D) {
6545
- const { destructionTimer: R } = X(this, dt)[U];
6550
+ const { destructionTimer: R } = G(this, dt)[U];
6546
6551
  clearTimeout(R);
6547
6552
  }
6548
- yt(this, dt, {}), yt(this, ht, {}), await (($ = X(this, _t)) == null ? void 0 : $.close());
6553
+ _t(this, dt, {}), _t(this, ht, {}), await (($ = G(this, yt)) == null ? void 0 : $.close());
6549
6554
  });
6550
6555
  /**
6551
6556
  * 发送消息
6552
6557
  * @param message Message
6553
6558
  */
6554
- W(this, "sendMessage", (D, $ = !0) => new Promise(async (U, R) => {
6559
+ K(this, "sendMessage", (D, $ = !0) => new Promise(async (U, R) => {
6555
6560
  var L;
6556
6561
  const { event: N, ...e } = D, o = Date.now(), A = sendMessageFormat({
6557
6562
  event: N,
6558
6563
  sn: +`${o}${O(1e3, 9999)}`,
6559
6564
  time: o,
6560
- valid: X(this, ft).timeout,
6565
+ valid: G(this, ft).timeout,
6561
6566
  version: 1,
6562
6567
  compress: !1,
6563
6568
  ...e
6564
6569
  });
6565
- X(this, ft).debug && (X(this, $t).call(this, "req", A), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", A)), await X(this, Tt).call(this, A), N === "joinRoom" && yt(this, St, !1), $ && X(this, xt).call(this, A, { resolve: U, reject: R });
6570
+ G(this, ft).debug && (G(this, Et).call(this, "req", A), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", A)), await G(this, xt).call(this, A), N === "joinRoom" && _t(this, $t, !1), $ && G(this, Dt).call(this, A, { resolve: U, reject: R });
6566
6571
  const M = com.quick.voice.proto.CommonReq.encode(A).finish();
6567
- (L = X(this, _t)) == null || L.sendMessage(M);
6572
+ (L = G(this, yt)) == null || L.sendMessage(M);
6568
6573
  }));
6569
6574
  // 接收消息
6570
- lt(this, qt, async (D) => {
6575
+ st(this, Mt, async (D) => {
6571
6576
  const $ = new Uint8Array(D), U = com.quick.voice.proto.CommonRsp.decode($), { sn: R, event: N } = U, e = onMessageFormat(U);
6572
- if (X(this, ft).debug && (X(this, $t).call(this, "res", e), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e)), await X(this, Tt).call(this, e), N === "joinRoom" && yt(this, St, !0), ignoreEvent.includes(N)) return;
6577
+ if (G(this, ft).debug && (G(this, Et).call(this, "res", e), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e)), await G(this, xt).call(this, e), N === "joinRoom" && _t(this, $t, !0), ignoreEvent.includes(N)) return;
6573
6578
  if (notifyName_keys.includes(N))
6574
6579
  return this.emitNotify(N, v$1(e, ["code", "data", "desc"]));
6575
- const A = X(this, Nt).call(this, R);
6580
+ const A = G(this, Ct).call(this, R);
6576
6581
  if (A) {
6577
6582
  const { resolve: M = (F) => {
6578
6583
  }, destruction: L = () => {
@@ -6585,8 +6590,8 @@ class CallsWebSocket {
6585
6590
  * @param event 事件名称
6586
6591
  * @param data 事件响应值
6587
6592
  */
6588
- W(this, "emitNotify", async (D, $) => {
6589
- const U = X(this, ht)[D] || [];
6593
+ K(this, "emitNotify", async (D, $) => {
6594
+ const U = G(this, ht)[D] || [];
6590
6595
  for (const R of U) {
6591
6596
  const { callback: N = async () => {
6592
6597
  } } = R;
@@ -6599,64 +6604,29 @@ class CallsWebSocket {
6599
6604
  * @param _private
6600
6605
  * @returns sn
6601
6606
  */
6602
- W(this, "addNotify", (D, $ = !1) => {
6607
+ K(this, "addNotify", (D, $ = !1) => {
6603
6608
  const { event: U, sn: R = pt(32) } = D;
6604
- X(this, ht)[U] || (X(this, ht)[U] = []);
6605
- const N = X(this, ht)[U], e = N.findIndex((o) => o.sn === R);
6609
+ G(this, ht)[U] || (G(this, ht)[U] = []);
6610
+ const N = G(this, ht)[U], e = N.findIndex((o) => o.sn === R);
6606
6611
  return e !== -1 && N.splice(e, 1), $ ? N.unshift(D) : N.push(D), R;
6607
6612
  });
6608
6613
  /**
6609
6614
  * 移除广播
6610
6615
  */
6611
- W(this, "removeNotify", (D = []) => {
6616
+ K(this, "removeNotify", (D = []) => {
6612
6617
  if (D.length === 0)
6613
- yt(this, ht, {});
6618
+ _t(this, ht, {});
6614
6619
  else {
6615
- const $ = Object.keys(X(this, ht));
6620
+ const $ = Object.keys(G(this, ht));
6616
6621
  for (const U of $)
6617
- X(this, ht)[U] = X(this, ht)[U].filter((R) => !D.includes(R.sn || ""));
6622
+ G(this, ht)[U] = G(this, ht)[U].filter((R) => !D.includes(R.sn || ""));
6618
6623
  }
6619
- X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", X(this, ht));
6624
+ G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", G(this, ht));
6620
6625
  });
6621
- yt(this, ft, { ...X(this, ft), ...D });
6626
+ _t(this, ft, { ...G(this, ft), ...D });
6622
6627
  }
6623
6628
  }
6624
- _t = new WeakMap(), ft = new WeakMap(), gt = new WeakMap(), St = new WeakMap(), kt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), Et = new WeakMap(), $t = new WeakMap(), Tt = new WeakMap(), xt = new WeakMap(), Nt = new WeakMap(), At = new WeakMap(), qt = new WeakMap();
6625
- const getTrackNamesFormTracks = (_, D = [], $ = "trackName") => {
6626
- const U = [];
6627
- for (const R of _) {
6628
- const { type: N } = R;
6629
- if (D.length === 0 || D.includes(N)) {
6630
- const e = R[$];
6631
- e && U.push(`${e}`);
6632
- }
6633
- }
6634
- return U;
6635
- }, getAverageVolume = (_, D) => {
6636
- _.getByteFrequencyData(D);
6637
- let $ = 0;
6638
- for (let R = 0; R < D.length; R++)
6639
- $ += D[R];
6640
- return Math.ceil($ / D.length);
6641
- }, getCallAction = async (_) => {
6642
- let D = "";
6643
- const $ = (R) => _.findIndex(({ type: e, enabled: o = !0 }) => e === R && o) === -1 ? "0" : "1";
6644
- return D = `${$(0)}${D}`, D = `${$(1)}${D}`, D = `${$(2)}${D}`, D = `${$(3)}${D}`, parseInt(D, 2);
6645
- }, getCallActionMap = (_ = 0) => {
6646
- const $ = Number(_).toString(2).padStart(4, "0").split(""), [U, R, N, e] = $;
6647
- return {
6648
- microphoneCamera_audio: !!Number(e),
6649
- microphoneCamera_video: !!Number(N),
6650
- screenSharing_video: !!Number(R),
6651
- screenSharing_audio: !!Number(U)
6652
- };
6653
- }, tools = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6654
- __proto__: null,
6655
- getAverageVolume,
6656
- getCallAction,
6657
- getCallActionMap,
6658
- getTrackNamesFormTracks
6659
- }, Symbol.toStringTag, { value: "Module" }));
6629
+ yt = new WeakMap(), ft = new WeakMap(), Rt = new WeakMap(), $t = new WeakMap(), bt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), qt = new WeakMap(), Et = new WeakMap(), xt = new WeakMap(), Dt = new WeakMap(), Ct = new WeakMap(), Ut = new WeakMap(), Mt = new WeakMap();
6660
6630
  var l = Object.defineProperty, y = (_) => {
6661
6631
  throw TypeError(_);
6662
6632
  }, q = (_, D, $) => D in _ ? l(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $, s = (_, D, $) => q(_, typeof D != "symbol" ? D + "" : D, $), P = (_, D, $) => D.has(_) || y("Cannot " + $), n = (_, D, $) => (P(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), m = (_, D, $) => D.has(_) ? y("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), a, d, u;
@@ -6691,7 +6661,7 @@ class k {
6691
6661
  a = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap();
6692
6662
  class RoomBase {
6693
6663
  constructor() {
6694
- W(this, "options", {
6664
+ K(this, "options", {
6695
6665
  appid: "",
6696
6666
  sdkToken: "",
6697
6667
  roomId: "",
@@ -6700,18 +6670,21 @@ class RoomBase {
6700
6670
  debug: !1,
6701
6671
  newPublishAutoSubscribe: !0
6702
6672
  });
6703
- W(this, "tools", tools);
6704
- W(this, "asyncQueue", new k());
6705
- W(this, "state", "ready");
6673
+ K(this, "prohibitNotify", !1);
6674
+ // 是否禁止通知
6675
+ K(this, "asyncQueue", new k());
6676
+ // 异步队列
6677
+ K(this, "state", "ready");
6706
6678
  // 房间状态
6707
- W(this, "createAt", Date.now());
6679
+ K(this, "createAt", Date.now());
6708
6680
  // 创建时间
6709
- W(this, "cwsIns", new CallsWebSocket());
6681
+ K(this, "cwsIns", new CallsWebSocket());
6710
6682
  // SDK通讯实例 // SDK通讯实例
6711
- W(this, "audioOutput", "default");
6712
- // 音频默认播放设备
6683
+ K(this, "peerIns", new RTCPeerConnection({ bundlePolicy: "max-bundle" }));
6684
+ K(this, "userMap", /* @__PURE__ */ new Map());
6685
+ // 用户
6713
6686
  // 设备错误信息
6714
- W(this, "mediaDevicesErrInfo", {
6687
+ K(this, "mediaDevicesErrInfo", {
6715
6688
  microphoneCamera_audio: "",
6716
6689
  microphoneCamera_video: "",
6717
6690
  screenSharing_video: "",
@@ -6720,14 +6693,14 @@ class RoomBase {
6720
6693
  /**
6721
6694
  * 获取房间信息
6722
6695
  */
6723
- W(this, "getRoomInfo", () => {
6696
+ K(this, "getRoomInfo", () => {
6724
6697
  const { options: D, state: $, createAt: U } = this;
6725
6698
  return { ...D, state: $, createAt: U };
6726
6699
  });
6727
6700
  /**
6728
6701
  * 设置房间状态
6729
6702
  */
6730
- W(this, "setRoomState", (D) => {
6703
+ K(this, "setRoomState", (D) => {
6731
6704
  this.state = D;
6732
6705
  const $ = enum_roomState[D], U = { state: D, stateStr: $ };
6733
6706
  this.cwsIns.emitNotify("onRoomState", { code: 200, data: U });
@@ -6735,20 +6708,20 @@ class RoomBase {
6735
6708
  /**
6736
6709
  * 设置属性
6737
6710
  */
6738
- W(this, "setOptions", async (D) => {
6711
+ K(this, "setOptions", async (D) => {
6739
6712
  const $ = { ...this.options, ...D };
6740
6713
  this.options = $;
6741
6714
  });
6742
6715
  /**
6743
6716
  * 初始化通讯实例
6744
6717
  */
6745
- W(this, "initCwsCall", () => {
6718
+ K(this, "initCwsCall", () => {
6746
6719
  this.cwsIns = new CallsWebSocket({ ...this.options });
6747
6720
  });
6748
6721
  /**
6749
6722
  * 获取媒体设备错误信息
6750
6723
  */
6751
- W(this, "getMediaDevicesErrInfo", async () => {
6724
+ K(this, "getMediaDevicesErrInfo", async () => {
6752
6725
  try {
6753
6726
  const D = await navigator.mediaDevices.enumerateDevices();
6754
6727
  D.find((U) => U.kind === "audioinput") || (this.mediaDevicesErrInfo.microphoneCamera_audio = "audioinput is not available."), D.find((U) => U.kind === "videoinput") || (this.mediaDevicesErrInfo.microphoneCamera_video = "videoinput is not available.");
@@ -6757,207 +6730,350 @@ class RoomBase {
6757
6730
  }
6758
6731
  return this.mediaDevicesErrInfo;
6759
6732
  });
6760
- }
6761
- }
6762
- class MediaStreams extends RoomBase {
6763
- constructor() {
6764
- super();
6765
- W(this, "audioMediaStreamContextMap", /* @__PURE__ */ new Map());
6766
- // 音频媒体流上下文
6767
- W(this, "videoMediaStreamContextMap", /* @__PURE__ */ new Map());
6768
- // 视频媒体流上下文
6769
- W(this, "mediaDevices", []);
6770
6733
  /**
6771
- * 获取key
6734
+ * 获取MediaKey
6772
6735
  */
6773
- W(this, "getUserMediaKey", ($, U) => `${$}-${U}`);
6736
+ K(this, "getUserMediaKey", (D, $) => `${D}-${$}`);
6774
6737
  /**
6775
- * 判断用户媒体类型
6738
+ * 获取 CallAction map
6776
6739
  */
6777
- W(this, "getUserMediaKind", ($) => {
6778
- let U = "";
6779
- switch ($) {
6780
- // 音频媒体处理
6781
- case "microphoneCamera_audio":
6782
- case "screenSharing_audio":
6783
- U = "audio";
6784
- break;
6785
- // 视频媒体处理
6786
- case "microphoneCamera_video":
6787
- case "screenSharing_video":
6788
- U = "video";
6789
- break;
6790
- }
6791
- return U;
6740
+ K(this, "getCallActionMap", (D = 0) => {
6741
+ const U = Number(D).toString(2).padStart(4, "0").split(""), [R, N, e, o] = U;
6742
+ return {
6743
+ microphoneCamera_audio: !!Number(o),
6744
+ microphoneCamera_video: !!Number(e),
6745
+ screenSharing_video: !!Number(N),
6746
+ screenSharing_audio: !!Number(R)
6747
+ };
6792
6748
  });
6793
6749
  /**
6794
- * 设置媒体参数
6750
+ * 获取音量
6795
6751
  */
6796
- W(this, "setConstraints", async ($, U, R) => {
6797
- const N = await this.getUserStream($, U), e = N.getTracks();
6798
- if (e.length !== 0) {
6799
- for (const o of e) {
6800
- const M = { ...o.getConstraints(), ...R };
6801
- await o.applyConstraints(M);
6752
+ K(this, "getAverageVolume", (D, $) => {
6753
+ D.getByteFrequencyData($);
6754
+ let U = 0;
6755
+ for (let N = 0; N < $.length; N++)
6756
+ U += $[N];
6757
+ return Math.ceil(U / $.length);
6758
+ });
6759
+ /**
6760
+ * 通过轨道计算当前用户的通话状态
6761
+ */
6762
+ K(this, "getCallAction", async (D) => {
6763
+ let $ = "";
6764
+ const U = (N) => D.findIndex(({ type: o, enabled: A = !0 }) => o === N && A) === -1 ? "0" : "1";
6765
+ return $ = `${U(0)}${$}`, $ = `${U(1)}${$}`, $ = `${U(2)}${$}`, $ = `${U(3)}${$}`, parseInt($, 2);
6766
+ });
6767
+ /**
6768
+ * 获取指定轨道的名称数组
6769
+ * @param tracks 轨道
6770
+ * @param types number[] = []
6771
+ * @param keyName
6772
+ * @returns string[]
6773
+ */
6774
+ K(this, "getTrackNamesFormTracks", (D, $ = [], U = "trackName") => {
6775
+ const R = [];
6776
+ for (const N of D) {
6777
+ const { type: e } = N;
6778
+ if ($.length === 0 || $.includes(e)) {
6779
+ const o = N[U];
6780
+ o && R.push(`${o}`);
6802
6781
  }
6803
- await this.initUserMediaStreamContext($, U, N);
6804
6782
  }
6783
+ return R;
6784
+ });
6785
+ /**
6786
+ * 处理为应用层数据
6787
+ */
6788
+ K(this, "usersFilter", (D) => mt(D, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "updateStreams", "permissions", "isPublished"]).sort((R, N) => R.id.localeCompare(N.id, "en")));
6789
+ }
6790
+ }
6791
+ var wt, vt, kt, Pt, Bt, Tt, Lt;
6792
+ class RoomMedias extends RoomBase {
6793
+ // 媒体流上下文
6794
+ constructor() {
6795
+ super();
6796
+ K(this, "mediaDevices", []);
6797
+ // 可用媒体设备列表
6798
+ st(this, wt, /* @__PURE__ */ new Map());
6799
+ // 媒体流设备管理
6800
+ st(this, vt, /* @__PURE__ */ new Map());
6801
+ // 媒体轨道参数管理
6802
+ st(this, kt, /* @__PURE__ */ new Map());
6803
+ /**
6804
+ * 初始化媒体参数
6805
+ */
6806
+ st(this, Pt, () => {
6807
+ G(this, vt).set("microphoneCamera_audio", {}), G(this, vt).set("microphoneCamera_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), G(this, vt).set("screenSharing_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), G(this, vt).set("screenSharing_audio", {});
6808
+ });
6809
+ /**
6810
+ * 初始化媒体设备类型
6811
+ */
6812
+ st(this, Bt, () => {
6813
+ G(this, wt).set("audioinput", "default"), G(this, wt).set("videoinput", "default"), G(this, wt).set("audiooutput", "default");
6805
6814
  });
6806
6815
  /**
6807
6816
  * 初始化用户媒体上下文
6808
6817
  */
6809
- W(this, "initUserMediaStreamContext", async ($, U, R) => {
6818
+ K(this, "initUserMediaStreamContext", async ($, U, R) => {
6810
6819
  var A;
6811
- const N = this.getUserMediaKey($, U);
6812
- if (R.getTracks().length === 0) {
6820
+ const [N] = R.getTracks();
6821
+ if (!N) {
6813
6822
  console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: tracks.length is 0.", { userId: $, mediaType: U, stream: R });
6814
6823
  return;
6815
6824
  }
6816
- switch (this.getUserMediaKind(U)) {
6825
+ this.removeUserMediaStreamContext($, U);
6826
+ const e = this.getUserMediaKey($, U), { kind: o } = N;
6827
+ switch (o) {
6817
6828
  // 音频媒体处理
6818
6829
  case "audio":
6819
6830
  {
6820
- const M = new AudioMediaStreamContext(R);
6821
- try {
6822
- (A = M.audioContext) == null || A.setSinkId(this.audioOutput);
6823
- } catch (L) {
6824
- console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error", L);
6825
- }
6826
- this.audioMediaStreamContextMap.set(N, M);
6831
+ const M = new AudioMediaContext(N);
6832
+ G(this, kt).set(e, M);
6827
6833
  }
6828
6834
  break;
6829
6835
  // 视频媒体处理
6830
6836
  case "video":
6831
6837
  {
6832
- const M = new VideoMediaStreamContext(R);
6833
- this.videoMediaStreamContextMap.set(N, M);
6838
+ const M = new VideoMediaContext(R);
6839
+ G(this, kt).set(e, M);
6834
6840
  }
6835
6841
  break;
6836
6842
  }
6843
+ {
6844
+ const M = this.getUserMediaStreamContext($, U);
6845
+ if (M && M.kind === "audio")
6846
+ try {
6847
+ const L = G(this, wt).get("audiooutput");
6848
+ (A = M.audioContext) == null || A.setSinkId(L);
6849
+ } catch (L) {
6850
+ console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error", L);
6851
+ }
6852
+ }
6853
+ });
6854
+ /**
6855
+ * 获取用户媒体流上下文
6856
+ */
6857
+ K(this, "getUserMediaStreamContext", ($, U) => {
6858
+ const R = this.getUserMediaKey($, U);
6859
+ return G(this, kt).get(R);
6860
+ });
6861
+ /**
6862
+ * 获取用户音频媒体流上下文
6863
+ */
6864
+ K(this, "getUserAudioMediaStreamContext", ($, U) => {
6865
+ const R = this.getUserMediaKey($, U);
6866
+ return G(this, kt).get(R);
6867
+ });
6868
+ /**
6869
+ * 删除用户媒体流上下文
6870
+ */
6871
+ K(this, "removeUserMediaStreamContext", ($, U) => {
6872
+ const R = this.getUserMediaKey($, U), N = G(this, kt).get(R);
6873
+ N == null || N.stop(), G(this, kt).delete(R);
6837
6874
  });
6838
6875
  /**
6839
6876
  * 获取某个用户的某个数据流
6840
6877
  */
6841
- W(this, "getUserStream", async ($, U) => {
6842
- const R = this.getUserMediaKey($, U), N = this.getUserMediaKind(U);
6843
- let e;
6844
- switch (N) {
6845
- // 音频媒体处理
6846
- case "audio":
6878
+ K(this, "getUserStream", ($, U) => {
6879
+ const R = this.getUserMediaStreamContext($, U);
6880
+ return (R == null ? void 0 : R.getStream()) || new MediaStream();
6881
+ });
6882
+ /**
6883
+ * 获取某个用户的某些数据流
6884
+ */
6885
+ K(this, "getUserStreams", ($, U = []) => {
6886
+ U.length === 0 && (U = mediaType_keys);
6887
+ const R = {};
6888
+ for (const N of U) {
6889
+ const e = this.getUserStream($, N);
6890
+ R[N] = e;
6891
+ }
6892
+ return R;
6893
+ });
6894
+ /**
6895
+ * 删除某个用户的某些数据流
6896
+ */
6897
+ K(this, "removeUserStreams", async ($, U = []) => {
6898
+ U.length === 0 && (U = mediaType_keys);
6899
+ for (const R of U)
6900
+ this.removeUserMediaStreamContext($, R);
6901
+ });
6902
+ /**
6903
+ * 清除所有媒体流使用
6904
+ */
6905
+ K(this, "clearUserStreams", async () => {
6906
+ const $ = G(this, kt).values();
6907
+ for (const U of $)
6908
+ U.stop();
6909
+ _t(this, kt, /* @__PURE__ */ new Map());
6910
+ });
6911
+ /**
6912
+ * 设置轨道媒体参数
6913
+ */
6914
+ K(this, "setMediaTrackConstraints", async ($, U) => {
6915
+ G(this, vt).set($, U);
6916
+ const N = this.getUserStream(this.options.userId, $).getTracks();
6917
+ if (N.length !== 0)
6918
+ for (const e of N) {
6919
+ const A = { ...e.getConstraints(), ...U };
6920
+ await e.applyConstraints(A);
6921
+ }
6922
+ });
6923
+ /**
6924
+ * 改变本地流
6925
+ * @param mediaType MediaType
6926
+ * @param active 激活状态
6927
+ * @example quickvo.setLocalStream('microphoneCamera_audio', false)
6928
+ * @returns Promise<Streams>
6929
+ */
6930
+ K(this, "changeLocalStream", async ($) => {
6931
+ const { userId: U } = this.options, R = G(this, vt).get($);
6932
+ switch ($) {
6933
+ // 麦克风
6934
+ case "microphoneCamera_audio":
6847
6935
  {
6848
- const o = this.audioMediaStreamContextMap.get(R);
6849
- e = o == null ? void 0 : o.getStream();
6936
+ const N = G(this, wt).get("audioinput"), e = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: N, ...R }, video: !1 });
6937
+ await this.initUserMediaStreamContext(U, "microphoneCamera_audio", e);
6850
6938
  }
6851
6939
  break;
6852
- // 视频媒体处理
6853
- case "video":
6940
+ // 摄像头
6941
+ case "microphoneCamera_video":
6854
6942
  {
6855
- const o = this.videoMediaStreamContextMap.get(R);
6856
- e = o == null ? void 0 : o.getStream();
6943
+ const N = G(this, wt).get("videoinput"), e = await navigator.mediaDevices.getUserMedia({ audio: !1, video: { deviceId: N, ...R } });
6944
+ await this.initUserMediaStreamContext(U, "microphoneCamera_video", e);
6857
6945
  }
6858
6946
  break;
6947
+ // 屏幕共享 音频
6948
+ case "screenSharing_audio":
6949
+ {
6950
+ const N = await navigator.mediaDevices.getDisplayMedia({ audio: !0, video: !0, ...R }), e = N.getTracks();
6951
+ for (const o of e) {
6952
+ const { kind: A } = o, M = new MediaStream();
6953
+ M.addTrack(o), N.removeTrack(o), A === "audio" && await this.initUserMediaStreamContext(U, "screenSharing_audio", M), A === "video" && await this.initUserMediaStreamContext(U, "screenSharing_video", M);
6954
+ }
6955
+ }
6956
+ break;
6957
+ // 屏幕共享 视频
6958
+ case "screenSharing_video":
6959
+ {
6960
+ const N = await navigator.mediaDevices.getDisplayMedia({ audio: !1, video: !0, ...R });
6961
+ await this.initUserMediaStreamContext(U, "screenSharing_video", N);
6962
+ }
6963
+ break;
6964
+ }
6965
+ {
6966
+ const N = this.userMap.get(U);
6967
+ if (!N) return;
6968
+ N.updateStreams[$] = !0, this.cwsIns.emitNotify("onRoomUserStreams", { code: 200, data: { user: N } });
6859
6969
  }
6860
- return e || new MediaStream();
6861
6970
  });
6862
6971
  /**
6863
- * 获取某个用户的全部数据流
6972
+ * 获取媒体设备列表
6864
6973
  */
6865
- W(this, "getUserStreams", async ($) => {
6866
- const U = {};
6867
- for (const R of mediaType_keys) {
6868
- const N = await this.getUserStream($, R);
6869
- U[R] = N;
6870
- }
6871
- return U;
6872
- });
6974
+ st(this, Tt, async () => !navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices ? (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 不支持 enumerateDevices"), []) : (await navigator.mediaDevices.enumerateDevices().then(($) => {
6975
+ this.mediaDevices = $;
6976
+ }).catch(function($) {
6977
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", $);
6978
+ }), this.mediaDevices));
6873
6979
  /**
6874
- * 删除用户媒体流上下文
6980
+ * 媒体设备发生变化
6875
6981
  */
6876
- W(this, "removeUserMediaStreamContext", ($, U) => {
6877
- const R = this.getUserMediaKey($, U);
6878
- this.audioMediaStreamContextMap.delete(R), this.videoMediaStreamContextMap.delete(R);
6982
+ st(this, Lt, () => {
6983
+ navigator.mediaDevices.ondevicechange = () => {
6984
+ G(this, Tt).call(this);
6985
+ }, G(this, Tt).call(this);
6879
6986
  });
6880
6987
  /**
6881
- * 删除某个用户的某个数据流
6988
+ * 获取正在使用的媒体设备ID
6989
+ * @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
6990
+ * @returns deviceId 设备ID
6882
6991
  */
6883
- W(this, "removeUserStreams", async ($, U = []) => {
6884
- U.length === 0 && (U = mediaType_keys);
6885
- for (const R of U) {
6886
- const N = await this.getUserStream($, R);
6887
- await this.stopStream(N), this.removeUserMediaStreamContext($, R);
6992
+ K(this, "getMediaDeviceKind", ($) => G(this, wt).get($));
6993
+ /**
6994
+ * 替换发射器媒体流
6995
+ */
6996
+ K(this, "replaceSenderStream", async ($, U) => {
6997
+ var A;
6998
+ const R = this.userMap.get(this.options.userId);
6999
+ if (!R) return;
7000
+ const { mid: N } = R.tracks.find((M) => M.mediaType === $) || {};
7001
+ if (!N) return;
7002
+ const [e] = U.getTracks(), o = this.peerIns.getTransceivers();
7003
+ for (const M of o) {
7004
+ const { sender: L } = M;
7005
+ M.mid === N && ((A = L.track) == null || A.stop(), L.replaceTrack(e));
6888
7006
  }
6889
7007
  });
6890
7008
  /**
6891
- * 清除所有媒体流使用
7009
+ * 设置正在使用的媒体设备
7010
+ * @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
7011
+ * @param deviceId 设备ID
6892
7012
  */
6893
- W(this, "clearUserStreams", async () => {
6894
- {
6895
- const $ = this.audioMediaStreamContextMap.values();
6896
- for (const U of $)
6897
- U.stop();
6898
- this.audioMediaStreamContextMap = /* @__PURE__ */ new Map();
7013
+ K(this, "setMediaDeviceKind", async ($, U) => {
7014
+ var N;
7015
+ G(this, wt).set($, U);
7016
+ const { userId: R } = this.options;
7017
+ if ($ === "audioinput" && this.getUserMediaStreamContext(R, "microphoneCamera_audio")) {
7018
+ await this.changeLocalStream("microphoneCamera_audio");
7019
+ const o = this.getUserStream(this.options.userId, "microphoneCamera_audio");
7020
+ await this.replaceSenderStream("microphoneCamera_audio", o);
6899
7021
  }
6900
- {
6901
- const $ = this.videoMediaStreamContextMap.values();
6902
- for (const U of $)
6903
- U.stop();
6904
- this.videoMediaStreamContextMap = /* @__PURE__ */ new Map();
7022
+ if ($ === "videoinput" && this.getUserMediaStreamContext(R, "microphoneCamera_video")) {
7023
+ await this.changeLocalStream("microphoneCamera_video");
7024
+ const o = this.getUserStream(this.options.userId, "microphoneCamera_video");
7025
+ await this.replaceSenderStream("microphoneCamera_video", o);
7026
+ }
7027
+ if ($ === "audiooutput") {
7028
+ const e = G(this, kt).values();
7029
+ for (const o of e)
7030
+ (N = o.audioContext) == null || N.setSinkId(U);
6905
7031
  }
6906
7032
  });
6907
7033
  /**
6908
- * 停止媒体流
7034
+ * 设置音频输出设备
7035
+ * @param deviceId 设备ID
7036
+ * @returns
6909
7037
  */
6910
- W(this, "stopStream", async ($) => {
6911
- const U = $.getTracks();
6912
- for (const R of U)
6913
- R.enabled = !1, R.stop(), $.removeTrack(R);
6914
- $ = new MediaStream();
6915
- });
7038
+ K(this, "setAudioOutputDevice", ($) => this.setMediaDeviceKind("audiooutput", $));
6916
7039
  /**
6917
- * 获取可用音频输出媒体设备
7040
+ * 获取可用设备
7041
+ * @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
7042
+ * @returns MediaDeviceInfo[]
6918
7043
  */
6919
- W(this, "getEnumerateAudioOutputDevices", async () => !navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices ? (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 不支持 enumerateDevices"), []) : (await navigator.mediaDevices.enumerateDevices().then(($) => {
6920
- this.mediaDevices = $.filter((U) => U.kind === "audiooutput");
6921
- }).catch(function($) {
6922
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: err", $);
6923
- }), this.mediaDevices));
7044
+ K(this, "getEnumerateDevices", async ($) => (await G(this, Tt).call(this), this.mediaDevices.filter((R) => R.kind === $)));
6924
7045
  /**
6925
- * 设置音频输出设备
7046
+ * 获取可用音频输入设备
7047
+ * @returns MediaDeviceInfo[]
6926
7048
  */
6927
- W(this, "setAudioOutputDevice", ($) => {
6928
- var R;
6929
- const U = this.audioMediaStreamContextMap.values();
6930
- for (const N of U)
6931
- (R = N.audioContext) == null || R.setSinkId($);
6932
- });
6933
- // 获取当前音频输出设备
6934
- W(this, "getAudioOutputDevice", () => this.audioOutput);
7049
+ K(this, "getEnumerateAudioinputDevices", () => this.getEnumerateDevices("audioinput"));
7050
+ /**
7051
+ * 获取可用音频输出设备
7052
+ * @returns MediaDeviceInfo[]
7053
+ */
7054
+ K(this, "getEnumerateAudioOutputDevices", () => this.getEnumerateDevices("audiooutput"));
7055
+ /**
7056
+ * 获取可用视频输入设备
7057
+ * @returns MediaDeviceInfo[]
7058
+ */
7059
+ K(this, "getEnumerateVideoinputDevices", () => this.getEnumerateDevices("videoinput"));
7060
+ G(this, Lt).call(this), G(this, Bt).call(this), G(this, Pt).call(this);
6935
7061
  }
6936
7062
  }
6937
- class RoomUsers extends MediaStreams {
6938
- // 是否禁止通知
7063
+ wt = new WeakMap(), vt = new WeakMap(), kt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), Tt = new WeakMap(), Lt = new WeakMap();
7064
+ class RoomUsers extends RoomMedias {
6939
7065
  constructor() {
6940
7066
  super();
6941
- W(this, "userMap", /* @__PURE__ */ new Map());
6942
- // 用户
6943
- W(this, "prohibitNotify", !1);
6944
- /**
6945
- * 获取用户音频处理上下文
6946
- */
6947
- W(this, "getUserAudioMediaStreamContext", ($, U) => {
6948
- const R = this.getUserMediaKey($, U);
6949
- return this.audioMediaStreamContextMap.get(R);
6950
- });
6951
7067
  /**
6952
7068
  * 获取最大音量用户
6953
7069
  */
6954
- W(this, "getMaxVolumeUser", () => {
7070
+ K(this, "getMaxVolumeUser", () => {
6955
7071
  const $ = Array.from(this.userMap.values(), ({ id: R }) => R);
6956
7072
  if ($.length === 0) return;
6957
7073
  let U = [];
6958
7074
  for (const R of $) {
6959
- const N = this.getUserAudioMediaStreamContext(R, "microphoneCamera_audio");
6960
- if (!N) continue;
7075
+ const N = this.getUserMediaStreamContext(R, "microphoneCamera_audio");
7076
+ if (!N || N.kind !== "audio") continue;
6961
7077
  const e = N.getVolume();
6962
7078
  U.push({ id: R, volume: e });
6963
7079
  }
@@ -6966,16 +7082,16 @@ class RoomUsers extends MediaStreams {
6966
7082
  /**
6967
7083
  * 设置音频过滤
6968
7084
  */
6969
- W(this, "setAudioFilter", async ($ = {}) => {
7085
+ K(this, "setAudioFilter", async ($ = {}) => {
6970
7086
  const U = await this.getUsersId();
6971
7087
  for (const R of U) {
6972
7088
  {
6973
- const N = this.getUserAudioMediaStreamContext(R, "microphoneCamera_audio");
6974
- N == null || N.setFilter($);
7089
+ const N = this.getUserMediaStreamContext(R, "microphoneCamera_audio");
7090
+ (N == null ? void 0 : N.kind) === "audio" && (N == null || N.setFilter($));
6975
7091
  }
6976
7092
  {
6977
- const N = this.getUserAudioMediaStreamContext(R, "screenSharing_audio");
6978
- N == null || N.setFilter($);
7093
+ const N = this.getUserMediaStreamContext(R, "screenSharing_audio");
7094
+ (N == null ? void 0 : N.kind) === "audio" && (N == null || N.setFilter($));
6979
7095
  }
6980
7096
  }
6981
7097
  });
@@ -6984,9 +7100,9 @@ class RoomUsers extends MediaStreams {
6984
7100
  * @param userId
6985
7101
  * @param mediaType
6986
7102
  */
6987
- W(this, "setVolume", ($, U, R) => {
6988
- const N = this.getUserAudioMediaStreamContext($, U);
6989
- N == null || N.setVolumeGain(R);
7103
+ K(this, "setVolume", ($, U, R) => {
7104
+ const N = this.getUserMediaStreamContext($, U);
7105
+ (N == null ? void 0 : N.kind) === "audio" && (N == null || N.setVolumeGain(R));
6990
7106
  });
6991
7107
  /**
6992
7108
  * 获取声音大小
@@ -6994,27 +7110,28 @@ class RoomUsers extends MediaStreams {
6994
7110
  * @param mediaType
6995
7111
  * @returns volume
6996
7112
  */
6997
- W(this, "getVolume", ($, U) => {
6998
- const R = this.getUserAudioMediaStreamContext($, U);
6999
- return (R == null ? void 0 : R.getVolume()) || 0;
7113
+ K(this, "getVolume", ($, U) => {
7114
+ const R = this.getUserMediaStreamContext($, U);
7115
+ let N = 0;
7116
+ return (R == null ? void 0 : R.kind) === "audio" && (N = R == null ? void 0 : R.getVolume()), N;
7000
7117
  });
7001
7118
  /**
7002
7119
  * 清除房间所有用户
7003
7120
  */
7004
- W(this, "clearUsers", () => {
7121
+ K(this, "clearUsers", () => {
7005
7122
  this.userMap = /* @__PURE__ */ new Map();
7006
7123
  });
7007
7124
  /**
7008
7125
  * 删除用户
7009
7126
  */
7010
- W(this, "removeUsers", async ($) => {
7127
+ K(this, "removeUsers", async ($) => {
7011
7128
  for (const U of $)
7012
7129
  this.userMap.delete(U), await this.removeUserStreams(U);
7013
7130
  });
7014
7131
  /**
7015
7132
  * 创建一个用户
7016
7133
  */
7017
- W(this, "createUser", async ($) => {
7134
+ K(this, "createUser", async ($) => {
7018
7135
  const U = Date.now(), R = {
7019
7136
  id: $,
7020
7137
  permissions: 0,
@@ -7045,11 +7162,11 @@ class RoomUsers extends MediaStreams {
7045
7162
  /**
7046
7163
  * 获取某个用户
7047
7164
  */
7048
- W(this, "getUser", async ($) => (this.userMap.has($) || await this.createUser($), this.userMap.get($)));
7165
+ K(this, "getUser", async ($) => (this.userMap.has($) || await this.createUser($), this.userMap.get($)));
7049
7166
  /**
7050
7167
  * 获取某些用户
7051
7168
  */
7052
- W(this, "getUsers", async ($ = []) => {
7169
+ K(this, "getUsers", async ($ = []) => {
7053
7170
  $.length === 0 && ($ = [...this.userMap.keys()]);
7054
7171
  const U = [];
7055
7172
  for (const R of $) {
@@ -7061,7 +7178,7 @@ class RoomUsers extends MediaStreams {
7061
7178
  /**
7062
7179
  * 获取当前用户轨道所有mid
7063
7180
  */
7064
- W(this, "getAllUserTrackMids", async () => {
7181
+ K(this, "getAllUserTrackMids", async () => {
7065
7182
  const $ = await this.getUsers(), U = [];
7066
7183
  for (const R of $) {
7067
7184
  const { tracks: N = [] } = R;
@@ -7073,7 +7190,7 @@ class RoomUsers extends MediaStreams {
7073
7190
  /**
7074
7191
  * 通过 trackName 查询所属 UserTrack
7075
7192
  */
7076
- W(this, "getUserTrackByTrackName", async ($) => {
7193
+ K(this, "getUserTrackByTrackName", async ($) => {
7077
7194
  const U = await this.getUsers(), R = [];
7078
7195
  for (const N of U) {
7079
7196
  const { tracks: e = [] } = N;
@@ -7087,7 +7204,7 @@ class RoomUsers extends MediaStreams {
7087
7204
  /**
7088
7205
  * 通过 mid 查询所属 UserTrack
7089
7206
  */
7090
- W(this, "getUserTrackFromMid", async ($) => {
7207
+ K(this, "getUserTrackFromMid", async ($) => {
7091
7208
  const U = await this.getUsers();
7092
7209
  let R;
7093
7210
  for (const N of U) {
@@ -7103,24 +7220,24 @@ class RoomUsers extends MediaStreams {
7103
7220
  /**
7104
7221
  * 检查用户是否存在房间内
7105
7222
  */
7106
- W(this, "checkUserInRoom", ($) => this.userMap.has($));
7223
+ K(this, "checkUserInRoom", ($) => this.userMap.has($));
7107
7224
  /**
7108
7225
  * 获取房间全部用户id
7109
7226
  */
7110
- W(this, "getUsersId", async () => [...this.userMap.keys()]);
7227
+ K(this, "getUsersId", async () => [...this.userMap.keys()]);
7111
7228
  /**
7112
7229
  * 获取房间的访问者
7113
7230
  */
7114
- W(this, "getCaller", async () => await this.getUser(this.options.userId));
7231
+ K(this, "getCaller", async () => await this.getUser(this.options.userId));
7115
7232
  // 更新用户 isPublished 只有self 用户会用到
7116
- W(this, "updateIsPublished", async ($, U = !1) => {
7233
+ K(this, "updateIsPublished", async ($, U = !1) => {
7117
7234
  const R = await this.getUser($);
7118
7235
  R.isPublished = U;
7119
7236
  });
7120
7237
  /**
7121
7238
  * 设置用户流是否更新
7122
7239
  */
7123
- W(this, "setUserUpdateStreams", async ($, U, R = !0) => {
7240
+ K(this, "setUserUpdateStreams", async ($, U, R = !0) => {
7124
7241
  const N = await this.getUser($), e = {
7125
7242
  microphoneCamera_audio: !1,
7126
7243
  microphoneCamera_video: !1,
@@ -7132,7 +7249,7 @@ class RoomUsers extends MediaStreams {
7132
7249
  /**
7133
7250
  * 更新用户轨道
7134
7251
  */
7135
- W(this, "updateUsertracks", async ($, U = [], R) => {
7252
+ K(this, "updateUsertracks", async ($, U = [], R) => {
7136
7253
  const N = await this.getUser($);
7137
7254
  R && (U = [...N.tracks, ...U]), U = U.filter(({ mid: A = "" }) => A !== ""), U = it(U, ["type"]), U = U.sort((A, M) => A.type - M.type < 0 ? -1 : 1);
7138
7255
  for (const A of U)
@@ -7165,21 +7282,21 @@ class RoomUsers extends MediaStreams {
7165
7282
  /**
7166
7283
  * 更新用户会话状态
7167
7284
  */
7168
- W(this, "updateUserCallAction", async ($, U = 0) => {
7285
+ K(this, "updateUserCallAction", async ($, U = 0) => {
7169
7286
  const R = await this.getUser($);
7170
- R.callAction = U, R.callActionStr = U.toString(2).padStart(4, "0"), R.callActionMap = this.tools.getCallActionMap(U);
7287
+ R.callAction = U, R.callActionStr = U.toString(2).padStart(4, "0"), R.callActionMap = this.getCallActionMap(U);
7171
7288
  });
7172
7289
  /**
7173
7290
  * 更新用户网络信息
7174
7291
  */
7175
- W(this, "updateUserNetwork", async ($, U = { egress: 5, ingress: 5 }) => {
7292
+ K(this, "updateUserNetwork", async ($, U = { egress: 5, ingress: 5 }) => {
7176
7293
  const R = await this.getUser($);
7177
7294
  R.network = U;
7178
7295
  });
7179
7296
  /**
7180
7297
  * 更新用户权限
7181
7298
  */
7182
- W(this, "updateUserPermissions", async ($, U) => {
7299
+ K(this, "updateUserPermissions", async ($, U) => {
7183
7300
  if (U) {
7184
7301
  const R = await this.getUser($);
7185
7302
  R.permissions = U;
@@ -7188,14 +7305,14 @@ class RoomUsers extends MediaStreams {
7188
7305
  /**
7189
7306
  * 更新用户基本信息
7190
7307
  */
7191
- W(this, "updateUserBase", async ($) => {
7308
+ K(this, "updateUserBase", async ($) => {
7192
7309
  const U = await this.getUser($);
7193
7310
  U.isSelf = $ === this.options.userId, U.updateAt = Date.now();
7194
7311
  });
7195
7312
  /**
7196
7313
  * 更新多个用户信息
7197
7314
  */
7198
- W(this, "updateUsers", async ($) => {
7315
+ K(this, "updateUsers", async ($) => {
7199
7316
  for (const U of $) {
7200
7317
  const { id: R, tracks: N, callAction: e, permissions: o, isPublished: A } = U;
7201
7318
  await this.updateUserBase(R), await this.updateIsPublished(R, A), await this.updateUserPermissions(R, o), await this.updateUsertracks(R, N, !0), await this.updateUserCallAction(R, e), await this.updateUserNetwork(R);
@@ -7204,23 +7321,30 @@ class RoomUsers extends MediaStreams {
7204
7321
  /**
7205
7322
  * 广播用户变化
7206
7323
  */
7207
- W(this, "emitNotifyUpdateUsers", async () => {
7324
+ K(this, "emitNotifyUpdateUser", async ($) => {
7325
+ if (this.prohibitNotify) return;
7326
+ const U = await this.getUsers([$]), [R] = this.usersFilter(U);
7327
+ this.cwsIns.emitNotify("onRoomUser", { code: 200, data: R });
7328
+ });
7329
+ /**
7330
+ * 房间所有用户所有变化
7331
+ */
7332
+ K(this, "emitNotifyUpdateUsers", async () => {
7208
7333
  if (this.prohibitNotify) return;
7209
- const $ = await this.getUsers(), R = mt($, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "updateStreams", "permissions", "isPublished"]).sort((N, e) => N.id.localeCompare(e.id, "en"));
7210
- this.cwsIns.emitNotify("onRoomUsers", { code: 200, data: R });
7334
+ const $ = await this.getUsers(), U = this.usersFilter($);
7335
+ this.cwsIns.emitNotify("onRoomUsers", { code: 200, data: U });
7211
7336
  });
7212
7337
  }
7213
7338
  }
7214
- var Dt, Ct, Ut;
7339
+ var Zt, Ft, Ht, jt;
7215
7340
  class RoomPeer extends RoomUsers {
7216
7341
  constructor() {
7217
7342
  super();
7218
- W(this, "peerIns");
7219
- W(this, "getPeerStatsTimer", 0);
7343
+ K(this, "getPeerStatsTimer", 0);
7220
7344
  // 获取报告的定时器
7221
- W(this, "reports", []);
7345
+ K(this, "reports", []);
7222
7346
  // 通信网络质量
7223
- W(this, "peerNetwork", {
7347
+ K(this, "peerNetwork", {
7224
7348
  lostRate: "0",
7225
7349
  // 丢包率
7226
7350
  roundTripTime: "0",
@@ -7228,14 +7352,16 @@ class RoomPeer extends RoomUsers {
7228
7352
  jitter: "0"
7229
7353
  // 网络抖动
7230
7354
  });
7231
- W(this, "connectedResolveMap", /* @__PURE__ */ new Map());
7232
- W(this, "initPeer", () => {
7233
- this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), X(this, Dt).call(this), X(this, Ut).call(this);
7355
+ K(this, "connectedResolveMap", /* @__PURE__ */ new Map());
7356
+ K(this, "initPeer", () => {
7357
+ this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.peerIns.ontrack = async ($) => {
7358
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: e", $);
7359
+ }, G(this, Zt).call(this), G(this, jt).call(this);
7234
7360
  });
7235
7361
  /**
7236
7362
  * 初始化发射器
7237
7363
  */
7238
- W(this, "initSender", async () => {
7364
+ K(this, "initSender", async () => {
7239
7365
  this.peerIns.addTransceiver("audio", { direction: "sendonly" });
7240
7366
  const $ = await this.peerIns.createOffer();
7241
7367
  if (this.options.debug) {
@@ -7247,18 +7373,18 @@ class RoomPeer extends RoomUsers {
7247
7373
  /**
7248
7374
  * 添加发射器
7249
7375
  */
7250
- W(this, "addSender", async ($, U) => {
7251
- const R = this.peerIns.addTransceiver(U, { direction: "sendonly" }), N = await this.peerIns.createOffer();
7252
- await this.peerIns.setLocalDescription(N);
7253
- const { mid: e, sender: o } = R, { track: A } = o;
7254
- if (!A) return;
7255
- const { id: M, enabled: L } = A;
7256
- return { type: mediaType_keys.findIndex((H) => H === $), enabled: L, trackName: M, location: "local", mid: e, userId: this.options.userId };
7376
+ K(this, "addSender", async ($, U) => {
7377
+ const { userId: R } = this.options, N = this.peerIns.addTransceiver(U, { direction: "sendonly" }), e = await this.peerIns.createOffer();
7378
+ await this.peerIns.setLocalDescription(e);
7379
+ const { mid: o, sender: A } = N, { track: M } = A;
7380
+ if (!M) return;
7381
+ const { enabled: L } = M, F = mediaType_keys.findIndex((H) => H === $);
7382
+ return { type: F, enabled: L, trackName: `${R}_${F}`, location: "local", mid: o, userId: this.options.userId };
7257
7383
  });
7258
7384
  /**
7259
7385
  * 清理收发器
7260
7386
  */
7261
- W(this, "clearTransceivers", async () => {
7387
+ K(this, "clearTransceivers", async () => {
7262
7388
  const $ = await this.getAllUserTrackMids(), U = this.peerIns.getTransceivers();
7263
7389
  for (const R of U) {
7264
7390
  const { mid: N } = R;
@@ -7266,7 +7392,7 @@ class RoomPeer extends RoomUsers {
7266
7392
  }
7267
7393
  });
7268
7394
  // 等待ice连接
7269
- W(this, "connectionICE", () => new Promise(async ($) => {
7395
+ K(this, "connectionICE", () => new Promise(async ($) => {
7270
7396
  if (this.peerIns.connectionState === "connected") return $(!0);
7271
7397
  const U = pt();
7272
7398
  this.connectedResolveMap.set(U, $);
@@ -7274,7 +7400,7 @@ class RoomPeer extends RoomUsers {
7274
7400
  /**
7275
7401
  * 监听订阅轨道结果
7276
7402
  */
7277
- W(this, "onSubscribeUserTracks", ($) => {
7403
+ K(this, "onSubscribeUserTracks", ($) => {
7278
7404
  let U = 0;
7279
7405
  return new Promise(async (R) => {
7280
7406
  const N = [];
@@ -7289,37 +7415,37 @@ class RoomPeer extends RoomUsers {
7289
7415
  let e = [];
7290
7416
  const o = async () => {
7291
7417
  clearTimeout(U);
7292
- const A = Object.groupBy(e, ({ userId: L = "" }) => L), M = Object.keys(A);
7293
- for (const L of M) {
7294
- const F = A[L];
7295
- await this.updateUsertracks(L, F, !0);
7418
+ const M = Object.groupBy(e, ({ userId: F = "" }) => F), L = Object.keys(M);
7419
+ for (const F of L) {
7420
+ const Z = M[F];
7421
+ await this.updateUsertracks(F, Z, !0);
7296
7422
  }
7297
- this.peerIns.ontrack = null, R(!0);
7298
- };
7299
- this.peerIns.ontrack = async (A) => {
7423
+ this.peerIns.removeEventListener("track", A), R(!0);
7424
+ }, A = async (M) => {
7300
7425
  await this.connectionICE();
7301
- const { streams: M, transceiver: L } = A, [F] = M, { mid: Z, receiver: H } = L, { track: z } = H, { id: V, kind: K } = z, J = N.find((Y) => Y.mid === `${Z}`);
7302
- if (!J) return;
7303
- const { userId: G, mediaType: tt } = J;
7304
- if (!(!G || !tt)) {
7305
- if (await this.initUserMediaStreamContext(G, tt, F), K === "audio") {
7306
- const Y = this.getUserAudioMediaStreamContext(G, tt);
7307
- Y && Y.setMute(!1);
7426
+ const { streams: L, transceiver: F } = M, [Z] = L, { mid: H, receiver: z } = F, { track: Y } = z, { id: W, kind: J } = Y, V = N.find((nt) => nt.mid === `${H}`);
7427
+ if (!V) return;
7428
+ const { userId: tt, mediaType: X } = V;
7429
+ if (!(!tt || !X)) {
7430
+ if (await this.initUserMediaStreamContext(tt, X, Z), J === "audio") {
7431
+ const nt = this.getUserMediaStreamContext(tt, X);
7432
+ (nt == null ? void 0 : nt.kind) === "audio" && nt.setMute(!1);
7308
7433
  }
7309
7434
  {
7310
- const Y = { ...J, mid: Z, msid: V };
7311
- e.push(Y);
7435
+ const nt = { ...V, mid: H, msid: W };
7436
+ e.push(nt);
7312
7437
  }
7313
- this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->Breathe: await subscribe ${e.length}/${N.length}`, { mediaType: tt, mid: Z, userTrack: J }), N.length === e.length && o();
7438
+ this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->Breathe: await subscribe ${e.length}/${N.length}`, { mediaType: X, mid: H, userTrack: V, e: M }), N.length === e.length && o();
7314
7439
  }
7315
- }, U = setTimeout(() => o(), 5 * 1e3);
7440
+ };
7441
+ this.peerIns.addEventListener("track", A), U = setTimeout(() => o(), 5 * 1e3);
7316
7442
  }
7317
7443
  });
7318
7444
  });
7319
7445
  /**
7320
7446
  * 监听webrtc ice通讯连接
7321
7447
  */
7322
- lt(this, Dt, async () => {
7448
+ st(this, Zt, async () => {
7323
7449
  let $ = 0;
7324
7450
  const U = () => {
7325
7451
  this.setRoomState("disconnected"), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} });
@@ -7357,7 +7483,7 @@ class RoomPeer extends RoomUsers {
7357
7483
  /**
7358
7484
  * 关闭某个用户的某些轨道
7359
7485
  */
7360
- W(this, "closeUserTracks", async ($, U = [], R = !1) => {
7486
+ K(this, "closeUserTracks", async ($, U = [], R = !1) => {
7361
7487
  const N = [];
7362
7488
  for (const M of U) {
7363
7489
  const { trackName: L, msid: F } = M;
@@ -7367,7 +7493,7 @@ class RoomPeer extends RoomUsers {
7367
7493
  if (!o) return;
7368
7494
  for (const M of o.tracks) {
7369
7495
  const { trackName: L, msid: F, userId: Z, mediaType: H } = M;
7370
- !Z || !H || !e(F || L) || (await this.removeUserStreams(Z, [H]), F && delete M.msid);
7496
+ !Z || !H || !e(F || L) || (this.removeUserMediaStreamContext(Z, H), F && delete M.msid);
7371
7497
  }
7372
7498
  if (R) {
7373
7499
  const M = o.tracks.filter(({ trackName: L }) => !e(L));
@@ -7379,7 +7505,7 @@ class RoomPeer extends RoomUsers {
7379
7505
  L.track && e(L.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->Breathe: sender: ${L.track.id} is stop.`, M), L.track.enabled = !1, L.track.stop(), L.replaceTrack(null), this.peerIns.removeTrack(L), M.stop()), F.track && e(F.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->Breathe: receiver: ${F.track.id} is stop.`, M), F.track.enabled = !1, F.track.stop(), M.stop());
7380
7506
  }
7381
7507
  });
7382
- W(this, "createOffer", async () => {
7508
+ K(this, "createOffer", async () => {
7383
7509
  const $ = await this.peerIns.createOffer();
7384
7510
  if (this.options.debug) {
7385
7511
  const U = libExports.parse($.sdp), R = mt(U.media, ["mid", "msid", "type"]);
@@ -7387,7 +7513,7 @@ class RoomPeer extends RoomUsers {
7387
7513
  }
7388
7514
  await this.peerIns.setLocalDescription($);
7389
7515
  });
7390
- W(this, "createAnswer", async () => {
7516
+ K(this, "createAnswer", async () => {
7391
7517
  const $ = await this.peerIns.createAnswer();
7392
7518
  if (this.options.debug) {
7393
7519
  const U = libExports.parse($.sdp), R = mt(U.media, ["mid", "msid", "type"]);
@@ -7398,14 +7524,14 @@ class RoomPeer extends RoomUsers {
7398
7524
  /**
7399
7525
  * 生成本地sdp
7400
7526
  */
7401
- W(this, "getSdp", () => {
7527
+ K(this, "getSdp", () => {
7402
7528
  var $;
7403
7529
  return ($ = this.peerIns.localDescription) == null ? void 0 : $.sdp;
7404
7530
  });
7405
7531
  /**
7406
7532
  * 设置远程描述协议
7407
7533
  */
7408
- W(this, "setRemoteDescription", async ($) => {
7534
+ K(this, "setRemoteDescription", async ($) => {
7409
7535
  if (this.options.debug) {
7410
7536
  const U = libExports.parse($.sdp), R = mt(U.media, ["mid", "msid", "type"]);
7411
7537
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->Breathe: setRemoteDescription", { msidArr: R, sdpJson: U, description: $ });
@@ -7415,14 +7541,14 @@ class RoomPeer extends RoomUsers {
7415
7541
  /**
7416
7542
  * 获取peer网络情况
7417
7543
  */
7418
- W(this, "getPeerNetwork", () => this.peerNetwork);
7544
+ K(this, "getPeerNetwork", () => this.peerNetwork);
7419
7545
  /**
7420
7546
  * 设置通讯策略
7421
7547
  * @param callStrategy "fixedPictureQuality" | "qualityPriority" | "fluencyPriority" | "balancedDowngrade"
7422
7548
  * @param mediaTypes mediaType[] "microphoneCamera_audio" | "microphoneCamera_video" | "screenSharing_video" | "screenSharing_audio"
7423
7549
  * @example quickvo.setCallStrategy('fixedPictureQuality')
7424
7550
  */
7425
- W(this, "setCallStrategy", async ($, U = []) => {
7551
+ K(this, "setCallStrategy", async ($, U = []) => {
7426
7552
  U.length === 0 && (U = mediaType_keys);
7427
7553
  let R = "balanced";
7428
7554
  switch ($) {
@@ -7451,7 +7577,7 @@ class RoomPeer extends RoomUsers {
7451
7577
  * 设置 RTCRtpSender 参数
7452
7578
  * @param parameters RTCRtpSendParameters
7453
7579
  */
7454
- W(this, "setRTCRtpSenderParameters", ($) => {
7580
+ K(this, "setRTCRtpSenderParameters", ($) => {
7455
7581
  try {
7456
7582
  const U = this.peerIns.getSenders();
7457
7583
  for (const R of U) {
@@ -7465,33 +7591,33 @@ class RoomPeer extends RoomUsers {
7465
7591
  /**
7466
7592
  * 设置并分析报告
7467
7593
  */
7468
- lt(this, Ct, async ($) => {
7594
+ st(this, Ft, async ($) => {
7469
7595
  try {
7470
7596
  let U = 0, R = 0, N = 0, e = 0, o = [], A = [];
7471
7597
  for (const J of this.reports) {
7472
- const { packetsSent: G, packetsLost: tt } = J;
7473
- G && (U += G), tt && (R += tt);
7598
+ const { packetsSent: V, packetsLost: tt } = J;
7599
+ V && (U += V), tt && (R += tt);
7474
7600
  }
7475
7601
  for (const J of $) {
7476
- const { packetsSent: G, packetsLost: tt, jitter: Y, roundTripTime: nt } = J;
7477
- G && (N += G), tt && (e += tt), Y && A.push(Y.toFixed(2)), nt && o.push((nt * 100).toFixed(2));
7602
+ const { packetsSent: V, packetsLost: tt, jitter: X, roundTripTime: nt } = J;
7603
+ V && (N += V), tt && (e += tt), X && A.push(X.toFixed(2)), nt && o.push((nt * 100).toFixed(2));
7478
7604
  }
7479
7605
  this.reports = $, A.sort().reverse(), o.sort().reverse();
7480
7606
  const M = N - U, L = e - R;
7481
7607
  if (M === 0) return;
7482
7608
  const F = (L / M).toFixed(2), [Z = "0"] = o, [H = "0"] = A, z = { lostRate: F, roundTripTime: Z, jitter: H };
7483
7609
  JSON.stringify(z) !== JSON.stringify(this.peerNetwork) && this.cwsIns.emitNotify("onRoomNetwork", { code: 200, data: z }), this.peerNetwork = z;
7484
- const K = (J, G, tt) => {
7485
- const Y = Number(J), nt = Number(G), st = Number(tt);
7610
+ const W = (J, V, tt) => {
7611
+ const X = Number(J), nt = Number(V), lt = Number(tt);
7486
7612
  let et = "0";
7487
- return Y < 0.03 && nt < 100 && st < 0.05 ? et = "5" : Y < 0.06 && nt < 160 && st < 0.1 ? et = "4" : Y < 0.1 && nt < 250 && st < 0.15 ? et = "3" : Y < 0.15 && nt < 400 && st < 0.2 ? et = "2" : et = "1", Number(et);
7613
+ return X < 0.03 && nt < 100 && lt < 0.05 ? et = "5" : X < 0.06 && nt < 160 && lt < 0.1 ? et = "4" : X < 0.1 && nt < 250 && lt < 0.15 ? et = "3" : X < 0.15 && nt < 400 && lt < 0.2 ? et = "2" : et = "1", Number(et);
7488
7614
  };
7489
7615
  {
7490
- const J = K(F, Z, H), G = await this.getCaller(), { network: tt } = G, Y = { egress: J, ingress: J }, nt = JSON.stringify(tt) !== JSON.stringify(Y);
7491
- if (await this.updateUserNetwork(this.options.userId, Y), nt) {
7616
+ const J = W(F, Z, H), V = await this.getCaller(), { network: tt } = V, X = { egress: J, ingress: J }, nt = JSON.stringify(tt) !== JSON.stringify(X);
7617
+ if (await this.updateUserNetwork(this.options.userId, X), nt) {
7492
7618
  this.emitNotifyUpdateUsers();
7493
- const { userId: st, roomId: et } = this.options;
7494
- this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...Y, userId: st, roomId: et } }, !1);
7619
+ const { userId: lt, roomId: et } = this.options;
7620
+ this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...X, userId: lt, roomId: et } }, !1);
7495
7621
  }
7496
7622
  }
7497
7623
  } catch (U) {
@@ -7499,55 +7625,50 @@ class RoomPeer extends RoomUsers {
7499
7625
  }
7500
7626
  });
7501
7627
  /**
7502
- * 获取连接的所有状态数据
7628
+ * 获取分析报告
7503
7629
  */
7504
- lt(this, Ut, () => {
7505
- const $ = (R) => {
7506
- const N = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"];
7507
- return new Promise(async (e) => {
7508
- let o = [];
7509
- try {
7510
- await this.peerIns.getStats(R).then((A) => {
7511
- o = [...A.values()].filter((L) => N.includes(L.type));
7512
- });
7513
- } catch {
7514
- }
7515
- e(o);
7516
- });
7517
- }, U = async () => {
7518
- if (this.peerIns.connectionState !== "connected") return;
7519
- const R = this.peerIns.getSenders();
7630
+ K(this, "getReportsByMid", async ($ = []) => $.length === 0 ? this.reports : this.reports.filter((U) => $.includes(U.mid)));
7631
+ /**
7632
+ * 获取轨道分析数据
7633
+ */
7634
+ st(this, Ht, async ($) => {
7635
+ const U = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"];
7636
+ return new Promise(async (R) => {
7520
7637
  let N = [];
7521
- for (const e of R) {
7522
- const { track: o } = e;
7523
- if (!o) continue;
7524
- const A = await $(o);
7525
- N = [...N, ...A];
7638
+ try {
7639
+ await this.peerIns.getStats($).then((e) => {
7640
+ N = [...e.values()].filter((A) => U.includes(A.type));
7641
+ });
7642
+ } catch {
7526
7643
  }
7527
- X(this, Ct).call(this, N);
7644
+ R(N);
7645
+ });
7646
+ });
7647
+ /**
7648
+ * 获取连接的所有轨道分析数据
7649
+ */
7650
+ st(this, jt, () => {
7651
+ const $ = async () => {
7652
+ if (this.peerIns.connectionState !== "connected") return;
7653
+ const U = await G(this, Ht).call(this);
7654
+ G(this, Ft).call(this, U);
7528
7655
  };
7529
- this.getPeerStatsTimer = setInterval(U, 1 * 1e3);
7656
+ this.getPeerStatsTimer = setInterval($, 1 * 1e3);
7530
7657
  });
7531
7658
  /**
7532
7659
  * 停止网络报告分析
7533
7660
  */
7534
- W(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
7661
+ K(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
7535
7662
  }
7536
7663
  }
7537
- Dt = new WeakMap(), Ct = new WeakMap(), Ut = new WeakMap();
7538
- var wt, Ot, Mt;
7664
+ Zt = new WeakMap(), Ft = new WeakMap(), Ht = new WeakMap(), jt = new WeakMap();
7665
+ var gt, It, zt;
7539
7666
  class RoomCalls extends RoomPeer {
7540
7667
  constructor() {
7541
7668
  super();
7542
7669
  // sdk服务版本
7543
- W(this, "sdk_service_version", "1.0.3");
7544
- lt(this, wt, !0);
7545
- /**
7546
- * 添加广播事件
7547
- * @param notify Notify
7548
- * @returns sn
7549
- */
7550
- W(this, "addNotify", ($) => this.cwsIns.addNotify($));
7670
+ K(this, "sdk_service_version", "1.0.3");
7671
+ st(this, gt, !0);
7551
7672
  /**
7552
7673
  * 设置本地流
7553
7674
  * @param mediaType MediaType
@@ -7555,64 +7676,35 @@ class RoomCalls extends RoomPeer {
7555
7676
  * @example quickvo.setLocalStream('microphoneCamera_audio', false)
7556
7677
  * @returns Promise<Streams>
7557
7678
  */
7558
- W(this, "setLocalStream", ($, U) => new Promise(async (R, N) => {
7679
+ K(this, "setLocalStream", ($, U) => new Promise(async (R, N) => {
7559
7680
  try {
7560
- const { userId: e } = this.options, o = {
7561
- autoGainControl: !1,
7562
- noiseSuppression: !1,
7563
- echoCancellation: !1
7564
- };
7565
- if (U)
7566
- switch ($) {
7567
- // 麦克风
7568
- case "microphoneCamera_audio":
7569
- {
7570
- const M = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1, ...o });
7571
- await this.initUserMediaStreamContext(e, "microphoneCamera_audio", M);
7572
- }
7573
- break;
7574
- // 摄像头
7575
- case "microphoneCamera_video":
7576
- {
7577
- const M = await navigator.mediaDevices.getUserMedia({ audio: !1, video: { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }, ...o });
7578
- await this.initUserMediaStreamContext(e, "microphoneCamera_video", M);
7579
- }
7580
- break;
7581
- // 屏幕共享 音频
7582
- case "screenSharing_audio":
7583
- {
7584
- const M = await navigator.mediaDevices.getDisplayMedia({ audio: !0, video: !0, ...o }), L = M.getTracks();
7585
- for (const F of L) {
7586
- const { kind: Z } = F, H = new MediaStream();
7587
- H.addTrack(F), M.removeTrack(F), Z === "audio" && await this.initUserMediaStreamContext(e, "screenSharing_audio", H), Z === "video" && await this.initUserMediaStreamContext(e, "screenSharing_video", H), F.onended = () => this.stopPublish(["screenSharing_audio", "screenSharing_video"]);
7588
- }
7589
- }
7590
- break;
7591
- // 屏幕共享 视频
7592
- case "screenSharing_video":
7593
- {
7594
- const M = await navigator.mediaDevices.getDisplayMedia({ audio: !1, video: !0, ...o });
7595
- await this.initUserMediaStreamContext(e, "screenSharing_video", M);
7596
- }
7597
- break;
7598
- }
7599
- else
7600
- await this.removeUserStreams(e, [$]);
7601
- const A = await this.getUserStreams(e);
7602
- this.cwsIns.emitNotify("onLocalStream", { code: 200, data: A }), R(A);
7681
+ const { userId: e } = this.options;
7682
+ if (U ? await this.changeLocalStream($) : this.removeUserMediaStreamContext(e, $), $ === "screenSharing_audio" || $ === "screenSharing_video") {
7683
+ const M = this.getUserStream(e, $).getTracks();
7684
+ for (const L of M)
7685
+ L.onended = () => this.stopPublish(["screenSharing_audio", "screenSharing_video"]);
7686
+ }
7687
+ const o = this.getUserStreams(e);
7688
+ this.cwsIns.emitNotify("onLocalStream", { code: 200, data: o }), R(o);
7603
7689
  } catch (e) {
7604
7690
  N(e);
7605
7691
  }
7606
7692
  }));
7693
+ /**
7694
+ * 添加广播事件
7695
+ * @param notify Notify
7696
+ * @returns sn
7697
+ */
7698
+ K(this, "addNotify", ($) => this.cwsIns.addNotify($));
7607
7699
  /**
7608
7700
  * 加入房间
7609
7701
  * @param roomOptions RoomOptions
7610
7702
  * @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' , newPublishAutoSubscribe: true })
7611
7703
  * @returns Promise<boolean>
7612
7704
  */
7613
- W(this, "joinRoom", async ($) => new Promise(async (U, R) => {
7705
+ K(this, "joinRoom", async ($) => new Promise(async (U, R) => {
7614
7706
  try {
7615
- this.setOptions($), this.clearUsers(), this.clearUserStreams(), this.initPeer(), this.cwsIns.clearEvents(), await X(this, Mt).call(this), this.setRoomState("connect");
7707
+ this.setOptions($), this.clearUsers(), this.clearUserStreams(), this.initPeer(), this.cwsIns.clearEvents(), await G(this, zt).call(this), this.setRoomState("connect");
7616
7708
  const { roomId: N, userId: e, callType: o } = this.options;
7617
7709
  await this.cwsIns.sendMessage({
7618
7710
  event: "joinRoom",
@@ -7622,7 +7714,7 @@ class RoomCalls extends RoomPeer {
7622
7714
  if (M !== 200) return R(L);
7623
7715
  const { roomId: Z = "", roomUsers: H = [] } = F;
7624
7716
  if (Z !== N) return R("加入的房间不匹配");
7625
- X(this, wt) && this.createSession(), await this.updateUsers(H), this.setRoomState("connected"), await this.emitNotifyUpdateUsers();
7717
+ G(this, gt) && this.createSession(), await this.updateUsers(H), this.setRoomState("connected"), await this.emitNotifyUpdateUsers();
7626
7718
  const z = await this.getUsers();
7627
7719
  U(z);
7628
7720
  });
@@ -7635,25 +7727,20 @@ class RoomCalls extends RoomPeer {
7635
7727
  * @example quickvo.quitRoom()
7636
7728
  * @returns Promise<boolean>
7637
7729
  */
7638
- W(this, "quitRoom", async () => new Promise(async ($) => {
7639
- try {
7640
- this.stopPublish();
7641
- } catch (e) {
7642
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", e);
7643
- }
7730
+ K(this, "quitRoom", async () => new Promise(async ($) => {
7644
7731
  const { roomId: U, userId: R } = this.options, N = { roomId: U, user: { id: R } };
7645
- await this.cwsIns.sendMessage({ event: "quitRoom", data: N }), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} }), $(!0);
7732
+ this.cwsIns.sendMessage({ event: "quitRoom", data: N }), await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} }), $(!0);
7646
7733
  }));
7647
7734
  /**
7648
7735
  * 同步房间信息
7649
7736
  * @example quickvo.syncRoomInfo()
7650
7737
  */
7651
- W(this, "syncRoomInfo", async () => new Promise(async ($, U) => {
7738
+ K(this, "syncRoomInfo", async () => new Promise(async ($, U) => {
7652
7739
  const { userId: R } = this.options, N = await this.getUser(R), { id: e = R, callAction: o = 0 } = N;
7653
7740
  await this.cwsIns.sendMessage({ event: "syncRoomInfo", data: { user: { id: e, callAction: o } } }).then(async (A) => {
7654
7741
  if (A.code !== 200) return U(A.desc);
7655
7742
  const M = A.data.users;
7656
- this.clearUsers(), this.clearUserStreams(), await this.updateUsers(M), await this.updateUsertracks(N.id, N.tracks, !1), await this.subscribe();
7743
+ this.clearUsers(), await this.updateUsers(M), await this.updateUsertracks(N.id, N.tracks, !1), await this.subscribe();
7657
7744
  {
7658
7745
  const L = await this.getUsers();
7659
7746
  $(L);
@@ -7667,34 +7754,34 @@ class RoomCalls extends RoomPeer {
7667
7754
  * @example quickvo.publish(['microphoneCamera_audio', 'microphoneCamera_video'], 3)
7668
7755
  * @returns Promise<RoomUser>
7669
7756
  */
7670
- W(this, "publish", async ($, U = 3) => {
7671
- X(this, wt) && await this.connectionICE();
7757
+ K(this, "publish", async ($, U = 3) => {
7758
+ G(this, gt) && await this.connectionICE();
7672
7759
  const R = () => new Promise(async (N, e) => {
7673
7760
  try {
7674
7761
  $.includes("screenSharing_audio") && !$.includes("screenSharing_video") && ($ = [...$, "screenSharing_video"]);
7675
7762
  const o = await this.getCaller(), A = [];
7676
7763
  for (const Z of $) {
7677
- (await this.getUserStream(o.id, Z)).getTracks().length === 0 && await this.setLocalStream(Z, !0);
7764
+ this.getUserStream(o.id, Z).getTracks().length === 0 && await this.setLocalStream(Z, !0);
7678
7765
  {
7679
- const V = await this.getUserStream(o.id, Z), [K] = V.getTracks();
7680
- if (!K) continue;
7681
- const J = await this.addSender(Z, K);
7766
+ const Y = this.getUserStream(o.id, Z), [W] = Y.getTracks();
7767
+ if (!W) continue;
7768
+ const J = await this.addSender(Z, W);
7682
7769
  J && A.push(J);
7683
7770
  }
7684
7771
  }
7685
- const M = [...o.tracks, ...A], L = await this.tools.getCallAction(M), F = async () => {
7772
+ const M = [...o.tracks, ...A], L = await this.getCallAction(M), F = async () => {
7686
7773
  this.options.debug && console.info("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: surplus publish count is ${U}`), await this.cwsIns.sendMessage({
7687
7774
  event: "publish",
7688
7775
  data: { sdp: this.getSdp(), tracks: A, callAction: L }
7689
7776
  }).then(async (Z) => {
7690
- const { code: H = 0, desc: z, data: V } = Z;
7777
+ const { code: H = 0, desc: z, data: Y } = Z;
7691
7778
  if (H !== 200) {
7692
7779
  if (U > 0)
7693
7780
  return await new Promise((J) => setTimeout(() => J(!0), 300)), U = U - 1, F();
7694
7781
  throw this.options.debug && console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: publish is error. count 0", { mediaTypes: $ }), new Error(z);
7695
7782
  }
7696
- const { remoteSdp: K } = V;
7697
- await this.setRemoteDescription({ type: "answer", sdp: K }), await this.connectionICE(), await this.updateUsertracks(o.id, M, !0), await X(this, Ot).call(this, L), X(this, wt) || this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: "", user: { id: o.id, tracks: A } } });
7783
+ const { remoteSdp: W } = Y;
7784
+ await this.setRemoteDescription({ type: "answer", sdp: W }), await this.connectionICE(), await this.updateUsertracks(o.id, M, !0), await G(this, It).call(this, L), G(this, gt) || this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: "", user: { id: o.id, tracks: A } } });
7698
7785
  {
7699
7786
  await this.emitNotifyUpdateUsers();
7700
7787
  const J = await this.getCaller();
@@ -7715,7 +7802,7 @@ class RoomCalls extends RoomPeer {
7715
7802
  * @example quickvo.stopPublish(['microphoneCamera_audio'])
7716
7803
  * @returns Promise<RoomUser>
7717
7804
  */
7718
- W(this, "stopPublish", async ($ = []) => {
7805
+ K(this, "stopPublish", async ($ = []) => {
7719
7806
  const U = () => new Promise(async (R, N) => {
7720
7807
  try {
7721
7808
  const e = await this.getCaller();
@@ -7727,8 +7814,8 @@ class RoomCalls extends RoomPeer {
7727
7814
  if (o.length === 0) return A();
7728
7815
  await this.closeUserTracks(e.id, o, !0);
7729
7816
  {
7730
- const M = await this.tools.getCallAction(e.tracks);
7731
- await X(this, Ot).call(this, M);
7817
+ const M = await this.getCallAction(e.tracks);
7818
+ await G(this, It).call(this, M);
7732
7819
  }
7733
7820
  await this.createOffer(), await this.cwsIns.sendMessage({
7734
7821
  event: "closeTrack",
@@ -7750,8 +7837,8 @@ class RoomCalls extends RoomPeer {
7750
7837
  * @example quickvo.subscribe(['trackName1','trackName2'])
7751
7838
  * @returns Promise<RoomUser[]>
7752
7839
  */
7753
- W(this, "subscribe", async ($ = [], U = 3) => {
7754
- X(this, wt) && await this.connectionICE();
7840
+ K(this, "subscribe", async ($ = [], U = 3) => {
7841
+ G(this, gt) && await this.connectionICE();
7755
7842
  const R = () => new Promise(async (N, e) => {
7756
7843
  try {
7757
7844
  this.prohibitNotify = !0;
@@ -7760,8 +7847,8 @@ class RoomCalls extends RoomPeer {
7760
7847
  for (const Z of o) {
7761
7848
  const { isSelf: H, tracks: z = [] } = Z;
7762
7849
  if (!H) {
7763
- const V = z.filter(({ trackName: K, mid: J = "" }) => J !== "" && ($.includes(K) || $.length === 0));
7764
- V.length !== 0 && A.push({ ...Z, tracks: V });
7850
+ const Y = z.filter(({ trackName: W, mid: J = "" }) => J !== "" && ($.includes(W) || $.length === 0));
7851
+ Y.length !== 0 && A.push({ ...Z, tracks: Y });
7765
7852
  }
7766
7853
  }
7767
7854
  const M = async () => {
@@ -7772,22 +7859,22 @@ class RoomCalls extends RoomPeer {
7772
7859
  if (A.length === 0) return M();
7773
7860
  const L = [];
7774
7861
  for (const Z of A) {
7775
- const { id: H, tracks: z } = Z, V = mt(z, ["type", "trackName"]), K = { id: H, tracks: V };
7776
- L.push(K);
7862
+ const { id: H, tracks: z } = Z, Y = mt(z, ["type", "trackName"]), W = { id: H, tracks: Y };
7863
+ L.push(W);
7777
7864
  }
7778
7865
  const F = async () => {
7779
7866
  this.options.debug && console.info("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: surplus subscribe count is ${U}`), await this.cwsIns.sendMessage({
7780
7867
  event: "subscribe",
7781
7868
  data: { users: L }
7782
7869
  }).then(async (Z) => {
7783
- const { code: H = 0, data: z, desc: V } = Z;
7870
+ const { code: H = 0, data: z, desc: Y } = Z;
7784
7871
  if (H !== 200) {
7785
7872
  if (U > 0)
7786
- return await new Promise((G) => setTimeout(() => G(!0), 300)), U = U - 1, F();
7787
- throw this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: subscribe is error. count 0", { trackNames: $ }), new Error(V);
7873
+ return await new Promise((V) => setTimeout(() => V(!0), 300)), U = U - 1, F();
7874
+ throw this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: subscribe is error. count 0", { trackNames: $ }), new Error(Y);
7788
7875
  }
7789
- const { remoteSdp: K, users: J = [] } = z;
7790
- this.onSubscribeUserTracks(J).then(() => M()), await this.setRemoteDescription({ type: "offer", sdp: K }), await this.renegotiate();
7876
+ const { remoteSdp: W, users: J = [] } = z;
7877
+ this.onSubscribeUserTracks(J).then(() => M()), await this.setRemoteDescription({ type: "offer", sdp: W }), await this.renegotiate();
7791
7878
  });
7792
7879
  };
7793
7880
  await F();
@@ -7802,17 +7889,17 @@ class RoomCalls extends RoomPeer {
7802
7889
  * @param trackNames string[] = []
7803
7890
  * @example quickvo.subscribe(['trackName1'])
7804
7891
  */
7805
- W(this, "stopSubscribe", async ($ = []) => {
7892
+ K(this, "stopSubscribe", async ($ = []) => {
7806
7893
  const U = () => new Promise(async (R, N) => {
7807
7894
  try {
7808
7895
  const e = await this.getUsers(), o = [];
7809
7896
  for (const A of e) {
7810
7897
  const { tracks: M = [] } = A;
7811
7898
  for (const L of M) {
7812
- const { type: F, mid: Z, trackName: H, mediaType: z, msid: V } = L;
7813
- if (!(!z || !V) && ($.length === 0 || $.includes(H))) {
7814
- const K = { type: F, mid: Z, trackName: V };
7815
- o.push(K), await this.closeUserTracks(A.id, [L]);
7899
+ const { type: F, mid: Z, trackName: H, mediaType: z, msid: Y } = L;
7900
+ if (!(!z || !Y) && ($.length === 0 || $.includes(H))) {
7901
+ const W = { type: F, mid: Z, trackName: Y };
7902
+ o.push(W), await this.closeUserTracks(A.id, [L]);
7816
7903
  }
7817
7904
  }
7818
7905
  }
@@ -7836,7 +7923,7 @@ class RoomCalls extends RoomPeer {
7836
7923
  * @param enabled 是否冻结
7837
7924
  * @example quickvo.inactiveTracks(['microphoneCamera_audio'], false)
7838
7925
  */
7839
- W(this, "inactiveTracks", async ($, U) => {
7926
+ K(this, "inactiveTracks", async ($, U) => {
7840
7927
  const R = async () => {
7841
7928
  const N = await this.getCaller();
7842
7929
  if (!N) return;
@@ -7850,15 +7937,15 @@ class RoomCalls extends RoomPeer {
7850
7937
  H.enabled = U;
7851
7938
  }
7852
7939
  }
7853
- const A = await this.tools.getCallAction(o);
7854
- await X(this, Ot).call(this, A), await this.emitNotifyUpdateUsers();
7940
+ const A = await this.getCallAction(o);
7941
+ await G(this, It).call(this, A), await this.emitNotifyUpdateUsers();
7855
7942
  };
7856
7943
  return this.asyncQueue.add(R, { key: "inactiveTracks" });
7857
7944
  });
7858
7945
  /**
7859
7946
  * 远端调试
7860
7947
  */
7861
- W(this, "debugger", () => new Promise(async ($, U) => {
7948
+ K(this, "debugger", () => new Promise(async ($, U) => {
7862
7949
  await this.cwsIns.sendMessage({ event: "debugger" }, !1).then(async (R) => {
7863
7950
  if (R.code !== 200) return U(R.desc);
7864
7951
  $(!0);
@@ -7869,7 +7956,7 @@ class RoomCalls extends RoomPeer {
7869
7956
  /**
7870
7957
  * 更新自己通话状态
7871
7958
  */
7872
- lt(this, Ot, async ($) => new Promise(async (U, R) => {
7959
+ st(this, It, async ($) => new Promise(async (U, R) => {
7873
7960
  const { roomId: N, userId: e } = this.options, o = { roomId: N, user: { id: e, callAction: $ } };
7874
7961
  await this.cwsIns.sendMessage({ event: "updateCall", data: o }).then(async (A) => {
7875
7962
  const { code: M = 0 } = A;
@@ -7880,7 +7967,7 @@ class RoomCalls extends RoomPeer {
7880
7967
  /**
7881
7968
  * 创建cf会话
7882
7969
  */
7883
- W(this, "createSession", async () => (await this.initSender(), new Promise(async ($, U) => await this.cwsIns.sendMessage({
7970
+ K(this, "createSession", async () => (await this.initSender(), new Promise(async ($, U) => await this.cwsIns.sendMessage({
7884
7971
  event: "connectCF",
7885
7972
  data: { sdp: this.getSdp() }
7886
7973
  }).then(async (R) => {
@@ -7892,7 +7979,7 @@ class RoomCalls extends RoomPeer {
7892
7979
  /**
7893
7980
  * 协商流
7894
7981
  */
7895
- W(this, "renegotiate", async () => new Promise(async ($, U) => {
7982
+ K(this, "renegotiate", async () => new Promise(async ($, U) => {
7896
7983
  await this.createAnswer(), await this.cwsIns.sendMessage({ event: "renegotiate", data: { sdp: this.getSdp() } }).then(async (R) => {
7897
7984
  if (R.code !== 200) return U("协商流错误");
7898
7985
  $(!0);
@@ -7903,16 +7990,17 @@ class RoomCalls extends RoomPeer {
7903
7990
  /**
7904
7991
  * 登录
7905
7992
  */
7906
- lt(this, Mt, async () => new Promise(async ($, U) => {
7993
+ st(this, zt, async () => new Promise(async ($, U) => {
7907
7994
  try {
7908
7995
  this.setRoomState("checkAuth");
7909
- const { appid: R } = this.options, { userId: N, sdkToken: e } = this.options, o = {
7996
+ const { appid: R } = this.options, { userId: N, sdkToken: e, roomId: o } = this.options, A = {
7997
+ a: e,
7910
7998
  b: N,
7911
7999
  c: R,
7912
- a: e,
8000
+ r: o,
7913
8001
  v: this.sdk_service_version
7914
- }, A = btoa(encodeURI(JSON.stringify(o)));
7915
- await this.cwsIns.connect(A), $(!0);
8002
+ }, M = btoa(encodeURI(JSON.stringify(A)));
8003
+ await this.cwsIns.connect(M), $(!0);
7916
8004
  } catch (R) {
7917
8005
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe:error", R), U(R);
7918
8006
  }
@@ -7920,39 +8008,21 @@ class RoomCalls extends RoomPeer {
7920
8008
  this.setRoomState("ready");
7921
8009
  }
7922
8010
  }
7923
- wt = new WeakMap(), Ot = new WeakMap(), Mt = new WeakMap();
8011
+ gt = new WeakMap(), It = new WeakMap(), zt = new WeakMap();
7924
8012
  class Room extends RoomCalls {
7925
8013
  constructor() {
7926
8014
  super();
7927
- /**
7928
- * 获取指定轨道的名称数组
7929
- * @param tracks 轨道
7930
- * @param types number[] = []
7931
- * @param keyName
7932
- * @returns string[]
7933
- */
7934
- W(this, "getTrackNamesFormTracks", ($, U = [], R = "trackName") => {
7935
- const N = [];
7936
- for (const e of $) {
7937
- const { type: o } = e;
7938
- if (U.length === 0 || U.includes(o)) {
7939
- const A = e[R];
7940
- A && N.push(`${A}`);
7941
- }
7942
- }
7943
- return N;
7944
- });
7945
8015
  }
7946
8016
  }
7947
- var vt, Pt, Bt, Lt;
8017
+ var Ot, Jt, Kt, Wt;
7948
8018
  class QuickVO extends Room {
7949
8019
  constructor($) {
7950
8020
  super();
7951
- lt(this, vt, /* @__PURE__ */ new Map());
8021
+ st(this, Ot, /* @__PURE__ */ new Map());
7952
8022
  /**
7953
8023
  * 添加内部监听事件
7954
8024
  */
7955
- lt(this, Pt, () => {
8025
+ st(this, Jt, () => {
7956
8026
  {
7957
8027
  const $ = async (U) => {
7958
8028
  const { qualities: R } = U.data;
@@ -7986,7 +8056,7 @@ class QuickVO extends Room {
7986
8056
  await this.updateUsertracks(N, e, !0);
7987
8057
  }
7988
8058
  if (this.options.newPublishAutoSubscribe) {
7989
- const R = this.tools.getTrackNamesFormTracks(U.data.user.tracks);
8059
+ const R = this.getTrackNamesFormTracks(U.data.user.tracks);
7990
8060
  await this.subscribe(R);
7991
8061
  } else
7992
8062
  await this.emitNotifyUpdateUsers();
@@ -8004,31 +8074,31 @@ class QuickVO extends Room {
8004
8074
  const $ = async (U) => {
8005
8075
  const { id: R, callAction: N } = U.data.user;
8006
8076
  if (!this.checkUserInRoom(R)) return;
8007
- const e = await this.getUser(R), { tracks: o = [] } = e, A = await this.getUserStreams(R), M = this.tools.getCallActionMap(N), L = [];
8077
+ const e = await this.getUser(R), { tracks: o = [] } = e, A = this.getUserStreams(R), M = this.getCallActionMap(N), L = [];
8008
8078
  for (const F of o) {
8009
8079
  const { type: Z } = F, H = mediaType_keys[Z], z = M[H];
8010
8080
  if (Z === 0) {
8011
- const { microphoneCamera_audio: K } = A, J = K.getTracks();
8012
- for (const G of J)
8013
- G.enabled = z;
8081
+ const { microphoneCamera_audio: W } = A, J = W.getTracks();
8082
+ for (const V of J)
8083
+ V.enabled = z;
8014
8084
  }
8015
8085
  if (Z === 1) {
8016
- const { microphoneCamera_video: K } = A, J = K.getTracks();
8017
- for (const G of J)
8018
- G.enabled = z;
8086
+ const { microphoneCamera_video: W } = A, J = W.getTracks();
8087
+ for (const V of J)
8088
+ V.enabled = z;
8019
8089
  }
8020
8090
  if (Z === 2) {
8021
- const { screenSharing_video: K } = A, J = K.getTracks();
8022
- for (const G of J)
8023
- G.enabled = z;
8091
+ const { screenSharing_video: W } = A, J = W.getTracks();
8092
+ for (const V of J)
8093
+ V.enabled = z;
8024
8094
  }
8025
8095
  if (Z === 3) {
8026
- const { screenSharing_audio: K } = A, J = K.getTracks();
8027
- for (const G of J)
8028
- G.enabled = z;
8096
+ const { screenSharing_audio: W } = A, J = W.getTracks();
8097
+ for (const V of J)
8098
+ V.enabled = z;
8029
8099
  }
8030
- const V = { ...F, enabled: z };
8031
- L.push(V);
8100
+ const Y = { ...F, enabled: z };
8101
+ L.push(Y);
8032
8102
  }
8033
8103
  await this.updateUsertracks(R, L, !0), await this.updateUserCallAction(R, N), this.emitNotifyUpdateUsers();
8034
8104
  };
@@ -8046,7 +8116,7 @@ class QuickVO extends Room {
8046
8116
  /**
8047
8117
  * 重连成功
8048
8118
  */
8049
- lt(this, Bt, () => {
8119
+ st(this, Kt, () => {
8050
8120
  this.cwsIns.onReconnectSuccess = async () => {
8051
8121
  this.syncRoomInfo();
8052
8122
  };
@@ -8054,7 +8124,7 @@ class QuickVO extends Room {
8054
8124
  /**
8055
8125
  * 重连停止
8056
8126
  */
8057
- lt(this, Lt, async () => {
8127
+ st(this, Wt, async () => {
8058
8128
  this.cwsIns.onReconnectStop = async () => {
8059
8129
  this.destroy();
8060
8130
  };
@@ -8064,15 +8134,15 @@ class QuickVO extends Room {
8064
8134
  * @param key string
8065
8135
  * @param func FrameRequestCallback
8066
8136
  */
8067
- W(this, "addRequestAnimationFrame", async ($, U) => {
8137
+ K(this, "addRequestAnimationFrame", async ($, U) => {
8068
8138
  {
8069
- const N = X(this, vt).get($);
8139
+ const N = G(this, Ot).get($);
8070
8140
  N && cancelAnimationFrame(N);
8071
8141
  }
8072
8142
  const R = (N = Date.now()) => {
8073
8143
  U(N);
8074
8144
  const e = requestAnimationFrame(R);
8075
- X(this, vt).set($, e);
8145
+ G(this, Ot).set($, e);
8076
8146
  };
8077
8147
  R();
8078
8148
  });
@@ -8080,11 +8150,11 @@ class QuickVO extends Room {
8080
8150
  * 清理 FrameRequestCallback
8081
8151
  * @param keys string[] = []
8082
8152
  */
8083
- W(this, "clearRequestAnimationFrame", async ($ = []) => {
8084
- $.length === 0 && ($ = [...X(this, vt).keys()]);
8153
+ K(this, "clearRequestAnimationFrame", async ($ = []) => {
8154
+ $.length === 0 && ($ = [...G(this, Ot).keys()]);
8085
8155
  const U = [];
8086
8156
  for (const R of $) {
8087
- const N = X(this, vt).get(R);
8157
+ const N = G(this, Ot).get(R);
8088
8158
  N && (cancelAnimationFrame(N), U.push(N));
8089
8159
  }
8090
8160
  return U;
@@ -8093,18 +8163,14 @@ class QuickVO extends Room {
8093
8163
  * 销毁
8094
8164
  * @example quickvo.destroy()
8095
8165
  */
8096
- W(this, "destroy", async () => {
8166
+ K(this, "destroy", async () => {
8097
8167
  this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 销毁SDK"), this.stopGetPeerStats(), this.asyncQueue.clear(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), await this.cwsIns.close();
8098
8168
  });
8099
- this.setOptions($), this.initCwsCall(), X(this, Bt).call(this), X(this, Lt).call(this), X(this, Pt).call(this);
8169
+ this.setOptions($), this.initCwsCall(), G(this, Kt).call(this), G(this, Wt).call(this), G(this, Jt).call(this);
8100
8170
  }
8101
8171
  }
8102
- vt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), Lt = new WeakMap();
8172
+ Ot = new WeakMap(), Jt = new WeakMap(), Kt = new WeakMap(), Wt = new WeakMap();
8103
8173
  export {
8104
8174
  QuickVO,
8105
- getAverageVolume,
8106
- getCallAction,
8107
- getCallActionMap,
8108
- getTrackNamesFormTracks,
8109
8175
  ignoreEvent
8110
8176
  };