quickvo-sdk-js 0.7.4 → 0.7.6

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 ce = Object.defineProperty;
2
- var oe = (u) => {
1
+ var se = Object.defineProperty;
2
+ var re = (u) => {
3
3
  throw TypeError(u);
4
4
  };
5
- var se = (u, I, a) => I in u ? ce(u, I, { enumerable: !0, configurable: !0, writable: !0, value: a }) : u[I] = a;
6
- var Z = (u, I, a) => se(u, typeof I != "symbol" ? I + "" : I, a), re = (u, I, a) => I.has(u) || oe("Cannot " + a);
7
- var Q = (u, I, a) => (re(u, I, "read from private field"), a ? a.call(u) : I.get(u)), lt = (u, I, a) => I.has(u) ? oe("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(u) : I.set(u, a), St = (u, I, a, E) => (re(u, I, "write to private field"), E ? E.call(u, a) : I.set(u, a), a);
5
+ var ae = (u, I, a) => I in u ? se(u, I, { enumerable: !0, configurable: !0, writable: !0, value: a }) : u[I] = a;
6
+ var Z = (u, I, a) => ae(u, typeof I != "symbol" ? I + "" : I, a), ce = (u, I, a) => I.has(u) || re("Cannot " + a);
7
+ var Q = (u, I, a) => (ce(u, I, "read from private field"), a ? a.call(u) : I.get(u)), at = (u, I, a) => I.has(u) ? re("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(u) : I.set(u, a), St = (u, I, a, E) => (ce(u, I, "write to private field"), E ? E.call(u, a) : I.set(u, a), a);
8
8
  const ot = (u, I = {}) => {
9
9
  const a = { unit: "B", splitStr: " ", ...I };
10
10
  let { unit: E, splitStr: _ } = a;
@@ -717,7 +717,7 @@ function requireLib() {
717
717
  }
718
718
  var libExports = requireLib();
719
719
  class AudioMediaContext {
720
- constructor(I) {
720
+ constructor(I, a) {
721
721
  Z(this, "options", {
722
722
  autoGainControl: !1,
723
723
  // 自动增益
@@ -728,31 +728,38 @@ class AudioMediaContext {
728
728
  });
729
729
  Z(this, "kind", "audio");
730
730
  Z(this, "stream", new MediaStream());
731
- Z(this, "gain", 1);
732
- // 音量
731
+ Z(this, "inputGain", 1);
732
+ // 麦克风音量
733
+ Z(this, "outputGain", 1);
734
+ // 扬声器音量
733
735
  Z(this, "enhanceGain", 0);
734
- // 音量增强
736
+ // 麦克风增强音量
735
737
  Z(this, "audio", new Audio());
736
- // @ts-ignore 音频上下文
737
- Z(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
738
- // 媒体流音频源节点
739
- Z(this, "mediaStreamAudioSourceNode");
738
+ // 音频上下文实例
739
+ Z(this, "audioContext");
740
+ // 音源节点
741
+ Z(this, "sourceNode");
742
+ // 音量输入控制节点
743
+ Z(this, "inputGainNode");
744
+ // 音量输出控制节点
745
+ Z(this, "outputGainNode");
740
746
  // 增益节点 (自动增益)
741
- Z(this, "autoGainNode");
747
+ // autoGainNode!: GainNode
742
748
  // 滤波器节点 (噪声抑制)
743
- Z(this, "biquadFilterNode");
749
+ // biquadFilterNode!: BiquadFilterNode
744
750
  // 延迟节点 (回声消除)
745
- Z(this, "delayNode");
746
- // 增益节点 (音量控制)
747
- Z(this, "gainNode");
751
+ // delayNode!: DelayNode
748
752
  // 音频分析节点
749
753
  Z(this, "analyserNode");
750
754
  // 缓冲区 存储分析节点的时域数据
751
755
  Z(this, "analyserArrayData");
752
- Z(this, "initNode", () => {
753
- 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(this.gain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
754
- const { gainNode: I, analyserNode: a } = this;
755
- I.connect(a), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
756
+ Z(this, "initNodes", () => {
757
+ this.audio.srcObject = this.stream, this.sourceNode = this.audioContext.createMediaStreamSource(this.stream), this.inputGainNode = this.audioContext.createGain(), this.inputGainNode.gain.setValueAtTime(this.inputGain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount), this.outputGainNode = this.audioContext.createGain(), this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
758
+ {
759
+ const { sourceNode: I, inputGainNode: a, analyserNode: E, outputGainNode: _ } = this;
760
+ I.connect(a), a.connect(E), E.connect(_), _.connect(this.audioContext.destination);
761
+ }
762
+ this.setMute(!0);
756
763
  });
757
764
  /**
758
765
  * 停止
@@ -768,44 +775,40 @@ class AudioMediaContext {
768
775
  * 替换媒体
769
776
  */
770
777
  Z(this, "replaceStream", (I) => {
771
- const a = this.stream, E = a.getTracks();
772
- for (const k of E)
773
- a.removeTrack(k);
774
- const [_] = I.getAudioTracks();
775
- _ && a.addTrack(_), this.initNode();
778
+ const a = this.stream.getTracks();
779
+ for (const _ of a)
780
+ this.stream.removeTrack(_);
781
+ const [E] = I.getAudioTracks();
782
+ E && this.stream.addTrack(E), this.initNodes();
776
783
  });
777
784
  /**
778
785
  * 获取数据流
779
786
  */
780
- Z(this, "getStream", () => this.mediaStreamAudioSourceNode.mediaStream);
787
+ Z(this, "getStream", () => this.stream);
781
788
  /**
782
789
  * 静音
783
790
  */
784
791
  Z(this, "setMute", (I = !0) => {
785
- I ? this.gainNode.disconnect(this.audioContext.destination) : this.gainNode.connect(this.audioContext.destination);
792
+ I ? this.analyserNode.disconnect(this.outputGainNode) : this.analyserNode.connect(this.outputGainNode);
786
793
  });
787
794
  /**
788
- * 设置音量
789
- */
790
- Z(this, "setGain", () => {
791
- const I = (1 + this.enhanceGain) * this.gain;
792
- this.gainNode.gain.setValueAtTime(I, this.audioContext.currentTime);
793
- });
794
- /**
795
- * 设置增强音量
795
+ * 设置麦克风增强音量
796
796
  */
797
797
  Z(this, "setEnhanceGain", async (I) => {
798
- let a = Math.max(0, I);
799
- a = Math.min(a, 1), this.enhanceGain = a, this.setGain();
798
+ this.enhanceGain = I;
799
+ const a = this.inputGain + this.enhanceGain;
800
+ this.inputGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
800
801
  });
801
802
  /**
802
- * 设置基础音量
803
+ * 设置扬声器音量
803
804
  */
804
805
  Z(this, "setVolumeGain", (I) => {
805
- this.gain = I, this.setGain();
806
+ this.outputGain = I, this.outputGainNode.gain.setValueAtTime(I, this.audioContext.currentTime);
807
+ const a = I === 0;
808
+ this.setMute(a);
806
809
  });
807
810
  /**
808
- * 获取音量
811
+ * 获取输入音量
809
812
  */
810
813
  Z(this, "getVolume", () => {
811
814
  const { analyserNode: I, analyserArrayData: a } = this;
@@ -818,13 +821,8 @@ class AudioMediaContext {
818
821
  /**
819
822
  * 设置音频过滤
820
823
  */
821
- Z(this, "setFilter", (I = {}) => {
822
- this.options = { ...this.options, ...I };
823
- const { autoGainControl: a, noiseSuppression: E, echoCancellation: _ } = this.options, { mediaStreamAudioSourceNode: k, autoGainNode: e, biquadFilterNode: n, delayNode: O, gainNode: $ } = this;
824
- let N = k;
825
- return a && N.connect(e), E && N.connect(n), _ && N.connect(O), N.connect($), I;
826
- });
827
- this.stream.addTrack(I), this.initNode();
824
+ Z(this, "setFilter", (I = {}) => (this.options = { ...this.options, ...I }, I));
825
+ this.stream.addTrack(I), this.audioContext = a, this.initNodes(), this.audioContext.resume();
828
826
  }
829
827
  }
830
828
  class VideoMediaContext {
@@ -6165,7 +6163,7 @@ var Deflate_1$1 = Deflate$1, deflate_2 = deflate$1, deflateRaw_1$1 = deflateRaw$
6165
6163
  };
6166
6164
  const BAD$1 = 16209, TYPE$1 = 16191;
6167
6165
  var inffast = function u(I, a) {
6168
- let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, ut, it, at, st, rt;
6166
+ let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, ut, it, lt, st, rt;
6169
6167
  const ct = I.state;
6170
6168
  E = I.next_in, st = I.input, _ = E + (I.avail_in - 5), k = I.next_out, rt = I.output, e = k - (a - I.avail_out), n = k + (I.avail_out - 257), O = ct.dmax, $ = ct.wsize, N = ct.whave, D = ct.wnext, q = ct.window, P = ct.hold, j = ct.bits, V = ct.lencode, J = ct.distcode, z = (1 << ct.lenbits) - 1, Y = (1 << ct.distbits) - 1;
6171
6169
  t:
@@ -6189,13 +6187,13 @@ var inffast = function u(I, a) {
6189
6187
  I.msg = "invalid distance too far back", ct.mode = BAD$1;
6190
6188
  break t;
6191
6189
  }
6192
- if (it = 0, at = q, D === 0) {
6190
+ if (it = 0, lt = q, D === 0) {
6193
6191
  if (it += $ - tt, tt < nt) {
6194
6192
  nt -= tt;
6195
6193
  do
6196
6194
  rt[k++] = q[it++];
6197
6195
  while (--tt);
6198
- it = k - ut, at = rt;
6196
+ it = k - ut, lt = rt;
6199
6197
  }
6200
6198
  } else if (D < tt) {
6201
6199
  if (it += $ + D - tt, tt -= D, tt < nt) {
@@ -6208,7 +6206,7 @@ var inffast = function u(I, a) {
6208
6206
  do
6209
6207
  rt[k++] = q[it++];
6210
6208
  while (--tt);
6211
- it = k - ut, at = rt;
6209
+ it = k - ut, lt = rt;
6212
6210
  }
6213
6211
  }
6214
6212
  } else if (it += D - tt, tt < nt) {
@@ -6216,11 +6214,11 @@ var inffast = function u(I, a) {
6216
6214
  do
6217
6215
  rt[k++] = q[it++];
6218
6216
  while (--tt);
6219
- it = k - ut, at = rt;
6217
+ it = k - ut, lt = rt;
6220
6218
  }
6221
6219
  for (; nt > 2; )
6222
- rt[k++] = at[it++], rt[k++] = at[it++], rt[k++] = at[it++], nt -= 3;
6223
- nt && (rt[k++] = at[it++], nt > 1 && (rt[k++] = at[it++]));
6220
+ rt[k++] = lt[it++], rt[k++] = lt[it++], rt[k++] = lt[it++], nt -= 3;
6221
+ nt && (rt[k++] = lt[it++], nt > 1 && (rt[k++] = lt[it++]));
6224
6222
  } else {
6225
6223
  it = k - ut;
6226
6224
  do
@@ -6388,9 +6386,9 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
6388
6386
  64
6389
6387
  ]), inflate_table = (u, I, a, E, _, k, e, n) => {
6390
6388
  const O = n.bits;
6391
- let $ = 0, N = 0, D = 0, q = 0, P = 0, j = 0, V = 0, J = 0, z = 0, Y = 0, et, tt, nt, ut, it, at = null, st;
6389
+ let $ = 0, N = 0, D = 0, q = 0, P = 0, j = 0, V = 0, J = 0, z = 0, Y = 0, et, tt, nt, ut, it, lt = null, st;
6392
6390
  const rt = new Uint16Array(MAXBITS + 1), ct = new Uint16Array(MAXBITS + 1);
6393
- let $t = null, ne, Ct, Ut;
6391
+ let $t = null, oe, Ut, Mt;
6394
6392
  for ($ = 0; $ <= MAXBITS; $++)
6395
6393
  rt[$] = 0;
6396
6394
  for (N = 0; N < E; N++)
@@ -6410,12 +6408,12 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
6410
6408
  ct[$ + 1] = ct[$] + rt[$];
6411
6409
  for (N = 0; N < E; N++)
6412
6410
  I[a + N] !== 0 && (e[ct[I[a + N]]++] = N);
6413
- if (u === CODES$1 ? (at = $t = e, st = 20) : u === LENS$1 ? (at = lbase, $t = lext, st = 257) : (at = dbase, $t = dext, st = 0), Y = 0, N = 0, $ = D, it = k, j = P, V = 0, nt = -1, z = 1 << P, ut = z - 1, u === LENS$1 && z > ENOUGH_LENS$1 || u === DISTS$1 && z > ENOUGH_DISTS$1)
6411
+ if (u === CODES$1 ? (lt = $t = e, st = 20) : u === LENS$1 ? (lt = lbase, $t = lext, st = 257) : (lt = dbase, $t = dext, st = 0), Y = 0, N = 0, $ = D, it = k, j = P, V = 0, nt = -1, z = 1 << P, ut = z - 1, u === LENS$1 && z > ENOUGH_LENS$1 || u === DISTS$1 && z > ENOUGH_DISTS$1)
6414
6412
  return 1;
6415
6413
  for (; ; ) {
6416
- ne = $ - V, e[N] + 1 < st ? (Ct = 0, Ut = e[N]) : e[N] >= st ? (Ct = $t[e[N] - st], Ut = at[e[N] - st]) : (Ct = 96, Ut = 0), et = 1 << $ - V, tt = 1 << j, D = tt;
6414
+ oe = $ - V, e[N] + 1 < st ? (Ut = 0, Mt = e[N]) : e[N] >= st ? (Ut = $t[e[N] - st], Mt = lt[e[N] - st]) : (Ut = 96, Mt = 0), et = 1 << $ - V, tt = 1 << j, D = tt;
6417
6415
  do
6418
- tt -= et, _[it + (Y >> V) + tt] = ne << 24 | Ct << 16 | Ut | 0;
6416
+ tt -= et, _[it + (Y >> V) + tt] = oe << 24 | Ut << 16 | Mt | 0;
6419
6417
  while (tt !== 0);
6420
6418
  for (et = 1 << $ - 1; Y & et; )
6421
6419
  et >>= 1;
@@ -6503,7 +6501,7 @@ const fixedtables = (u) => {
6503
6501
  const k = u.state;
6504
6502
  return k.window === null && (k.wsize = 1 << k.wbits, k.wnext = 0, k.whave = 0, k.window = new Uint8Array(k.wsize)), E >= k.wsize ? (k.window.set(I.subarray(a - k.wsize, a), 0), k.wnext = 0, k.whave = k.wsize) : (_ = k.wsize - k.wnext, _ > E && (_ = E), k.window.set(I.subarray(a - E, a - E + _), k.wnext), E -= _, E ? (k.window.set(I.subarray(a - E, a), 0), k.wnext = E, k.whave = k.wsize) : (k.wnext += _, k.wnext === k.wsize && (k.wnext = 0), k.whave < k.wsize && (k.whave += _))), 0;
6505
6503
  }, inflate$2 = (u, I) => {
6506
- let a, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, ut, it, at;
6504
+ let a, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, ut, it, lt;
6507
6505
  const st = new Uint8Array(4);
6508
6506
  let rt, ct;
6509
6507
  const $t = (
@@ -6512,7 +6510,7 @@ const fixedtables = (u) => {
6512
6510
  );
6513
6511
  if (inflateStateCheck(u) || !u.output || !u.input && u.avail_in !== 0)
6514
6512
  return Z_STREAM_ERROR$1;
6515
- a = u.state, a.mode === TYPE && (a.mode = TYPEDO), e = u.next_out, _ = u.output, O = u.avail_out, k = u.next_in, E = u.input, n = u.avail_in, $ = a.hold, N = a.bits, D = n, q = O, at = Z_OK$1;
6513
+ a = u.state, a.mode === TYPE && (a.mode = TYPEDO), e = u.next_out, _ = u.output, O = u.avail_out, k = u.next_in, E = u.input, n = u.avail_in, $ = a.hold, N = a.bits, D = n, q = O, lt = Z_OK$1;
6516
6514
  t:
6517
6515
  for (; ; )
6518
6516
  switch (a.mode) {
@@ -6736,7 +6734,7 @@ const fixedtables = (u) => {
6736
6734
  }
6737
6735
  for (; a.have < 19; )
6738
6736
  a.lens[$t[a.have++]] = 0;
6739
- if (a.lencode = a.lendyn, a.lenbits = 7, rt = { bits: a.lenbits }, at = inftrees(CODES, a.lens, 0, 19, a.lencode, 0, a.work, rt), a.lenbits = rt.bits, at) {
6737
+ if (a.lencode = a.lendyn, a.lenbits = 7, rt = { bits: a.lenbits }, lt = inftrees(CODES, a.lens, 0, 19, a.lencode, 0, a.work, rt), a.lenbits = rt.bits, lt) {
6740
6738
  u.msg = "invalid code lengths set", a.mode = BAD;
6741
6739
  break;
6742
6740
  }
@@ -6792,11 +6790,11 @@ const fixedtables = (u) => {
6792
6790
  u.msg = "invalid code -- missing end-of-block", a.mode = BAD;
6793
6791
  break;
6794
6792
  }
6795
- if (a.lenbits = 9, rt = { bits: a.lenbits }, at = inftrees(LENS, a.lens, 0, a.nlen, a.lencode, 0, a.work, rt), a.lenbits = rt.bits, at) {
6793
+ if (a.lenbits = 9, rt = { bits: a.lenbits }, lt = inftrees(LENS, a.lens, 0, a.nlen, a.lencode, 0, a.work, rt), a.lenbits = rt.bits, lt) {
6796
6794
  u.msg = "invalid literal/lengths set", a.mode = BAD;
6797
6795
  break;
6798
6796
  }
6799
- if (a.distbits = 6, a.distcode = a.distdyn, rt = { bits: a.distbits }, at = inftrees(DISTS, a.lens, a.nlen, a.ndist, a.distcode, 0, a.work, rt), a.distbits = rt.bits, at) {
6797
+ if (a.distbits = 6, a.distcode = a.distdyn, rt = { bits: a.distbits }, lt = inftrees(DISTS, a.lens, a.nlen, a.ndist, a.distcode, 0, a.work, rt), a.distbits = rt.bits, lt) {
6800
6798
  u.msg = "invalid distances set", a.mode = BAD;
6801
6799
  break;
6802
6800
  }
@@ -6938,10 +6936,10 @@ const fixedtables = (u) => {
6938
6936
  a.mode = DONE;
6939
6937
  /* falls through */
6940
6938
  case DONE:
6941
- at = Z_STREAM_END$1;
6939
+ lt = Z_STREAM_END$1;
6942
6940
  break t;
6943
6941
  case BAD:
6944
- at = Z_DATA_ERROR$1;
6942
+ lt = Z_DATA_ERROR$1;
6945
6943
  break t;
6946
6944
  case MEM:
6947
6945
  return Z_MEM_ERROR$1;
@@ -6951,7 +6949,7 @@ const fixedtables = (u) => {
6951
6949
  return Z_STREAM_ERROR$1;
6952
6950
  }
6953
6951
  return u.next_out = e, u.avail_out = O, u.next_in = k, u.avail_in = n, a.hold = $, a.bits = N, (a.wsize || q !== u.avail_out && a.mode < BAD && (a.mode < CHECK || I !== Z_FINISH$1)) && updatewindow(u, u.output, u.next_out, q - u.avail_out), D -= u.avail_in, q -= u.avail_out, u.total_in += D, u.total_out += q, a.total += q, a.wrap & 4 && q && (u.adler = a.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/
6954
- a.flags ? crc32_1(a.check, _, q, u.next_out - q) : adler32_1(a.check, _, q, u.next_out - q)), u.data_type = a.bits + (a.last ? 64 : 0) + (a.mode === TYPE ? 128 : 0) + (a.mode === LEN_ || a.mode === COPY_ ? 256 : 0), (D === 0 && q === 0 || I === Z_FINISH$1) && at === Z_OK$1 && (at = Z_BUF_ERROR), at;
6952
+ a.flags ? crc32_1(a.check, _, q, u.next_out - q) : adler32_1(a.check, _, q, u.next_out - q)), u.data_type = a.bits + (a.last ? 64 : 0) + (a.mode === TYPE ? 128 : 0) + (a.mode === LEN_ || a.mode === COPY_ ? 256 : 0), (D === 0 && q === 0 || I === Z_FINISH$1) && lt === Z_OK$1 && (lt = Z_BUF_ERROR), lt;
6955
6953
  }, inflateEnd = (u) => {
6956
6954
  if (inflateStateCheck(u))
6957
6955
  return Z_STREAM_ERROR$1;
@@ -7185,12 +7183,12 @@ const noLogEvents = ["heartbeat", "onNetQuality", "networkQualityChange"], compr
7185
7183
  }
7186
7184
  return u;
7187
7185
  };
7188
- var wt, dt, xt, yt, bt, Mt, Pt, Lt, Bt, Nt, jt, Zt, Ft;
7186
+ var wt, dt, Nt, yt, bt, Pt, Lt, Bt, jt, At, Zt, Ft, Ht;
7189
7187
  class CallsWebSocket {
7190
7188
  // 状态
7191
7189
  constructor(I) {
7192
- lt(this, wt);
7193
- lt(this, dt, {
7190
+ at(this, wt);
7191
+ at(this, dt, {
7194
7192
  url: "wss://demo.putplay.cc/websocket",
7195
7193
  // 地址
7196
7194
  debug: !1,
@@ -7199,10 +7197,10 @@ class CallsWebSocket {
7199
7197
  // 最大重连次数
7200
7198
  timeout: 30 * 1e3
7201
7199
  });
7202
- lt(this, xt, "");
7200
+ at(this, Nt, "");
7203
7201
  // 缓存登录凭证
7204
- lt(this, yt, {});
7205
- lt(this, bt, {});
7202
+ at(this, yt, {});
7203
+ at(this, bt, {});
7206
7204
  Z(this, "state", "closed");
7207
7205
  // 外部 发送消息之前
7208
7206
  Z(this, "sendMessageBefore", async () => {
@@ -7214,26 +7212,26 @@ class CallsWebSocket {
7214
7212
  Z(this, "onReconnectStop", (I) => {
7215
7213
  });
7216
7214
  // 是否需要重连
7217
- lt(this, Mt, (I) => {
7215
+ at(this, Pt, (I) => {
7218
7216
  let a = !0;
7219
7217
  const { code: E = 1e3, reason: _ = "" } = I;
7220
7218
  return E === 1e3 && (_ === "quit success!" || _ === "replace old connection!") && (a = !1), a;
7221
7219
  });
7222
7220
  // 重连成功
7223
- lt(this, Pt, async (I) => {
7221
+ at(this, Lt, async (I) => {
7224
7222
  Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重连成功", I), this.state = "connected", this.onReconnectSuccess(I);
7225
7223
  });
7226
7224
  // 重连停止
7227
- lt(this, Lt, async (I) => {
7225
+ at(this, Bt, async (I) => {
7228
7226
  Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重连停止", I), this.close(), this.state = "closed", this.onReconnectStop(I);
7229
7227
  });
7230
7228
  // 自定义心跳规则
7231
- lt(this, Bt, () => {
7229
+ at(this, jt, () => {
7232
7230
  const I = { event: "heartbeat", sn: +`${F(1e5, 999999)}` };
7233
7231
  return com.quick.voice.proto.CommonReq.encode(I).finish();
7234
7232
  });
7235
7233
  // 更新日志
7236
- lt(this, Nt, (I, a = {}) => {
7234
+ at(this, At, (I, a = {}) => {
7237
7235
  try {
7238
7236
  const { time: E, event: _, data: k = {}, data_original: e = {}, data_remote: n, ...O } = a, $ = U(E, "YYYY-MM-DD hh:mm:ss", { offset: 480 });
7239
7237
  let N = {};
@@ -7272,7 +7270,7 @@ class CallsWebSocket {
7272
7270
  }
7273
7271
  });
7274
7272
  // 创建事件
7275
- lt(this, jt, (I, { resolve: a, reject: E }) => {
7273
+ at(this, Zt, (I, { resolve: a, reject: E }) => {
7276
7274
  const { sn: _ } = I, k = () => {
7277
7275
  const n = Q(this, yt)[_];
7278
7276
  clearTimeout(n.destructionTimer), delete Q(this, yt)[_];
@@ -7283,13 +7281,13 @@ class CallsWebSocket {
7283
7281
  Q(this, yt)[_] = { message: I, resolve: a, reject: E, destruction: k, destructionTimer: e };
7284
7282
  });
7285
7283
  // 获取事件
7286
- lt(this, Zt, (I) => Q(this, yt)[I]);
7284
+ at(this, Ft, (I) => Q(this, yt)[I]);
7287
7285
  // 接收消息
7288
- lt(this, Ft, async (I) => {
7286
+ at(this, Ht, async (I) => {
7289
7287
  const a = new Uint8Array(I), E = com.quick.voice.proto.CommonRsp.decode(a), { sn: _, event: k } = E, e = onMessageFormat(E);
7290
- if (Q(this, dt).debug && (noLogEvents.includes(k) || console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e), ignoreEvent.includes(k) || Q(this, Nt).call(this, "res", e)), notifyName_keys.includes(k))
7288
+ if (Q(this, dt).debug && (noLogEvents.includes(k) || console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e), ignoreEvent.includes(k) || Q(this, At).call(this, "res", e)), notifyName_keys.includes(k))
7291
7289
  return this.emitNotify(k, L(e, ["code", "data", "desc"]));
7292
- const O = Q(this, Zt).call(this, _);
7290
+ const O = Q(this, Ft).call(this, _);
7293
7291
  if (O) {
7294
7292
  const { resolve: $ = (D) => {
7295
7293
  }, destruction: N = () => {
@@ -7313,17 +7311,17 @@ class CallsWebSocket {
7313
7311
  * @returns
7314
7312
  */
7315
7313
  Z(this, "connect", async (I = "") => new Promise(async (a) => {
7316
- I && St(this, xt, I), Q(this, wt) && (await Q(this, wt).close(), this.state = "closed");
7317
- const E = `${Q(this, dt).url}?s=${Q(this, xt)}&t=${Date.now()}`;
7314
+ I && St(this, Nt, I), Q(this, wt) && (await Q(this, wt).close(), this.state = "closed");
7315
+ const E = `${Q(this, dt).url}?s=${Q(this, Nt)}&t=${Date.now()}`;
7318
7316
  St(this, wt, new M({
7319
7317
  ...Q(this, dt),
7320
7318
  url: E,
7321
7319
  binaryType: "arraybuffer",
7322
- onMessage: Q(this, Ft),
7323
- checkReconnect: Q(this, Mt),
7324
- getHeartbeatMsg: Q(this, Bt),
7325
- onReconnectSuccess: Q(this, Pt),
7326
- onReconnectStop: Q(this, Lt)
7320
+ onMessage: Q(this, Ht),
7321
+ checkReconnect: Q(this, Pt),
7322
+ getHeartbeatMsg: Q(this, jt),
7323
+ onReconnectSuccess: Q(this, Lt),
7324
+ onReconnectStop: Q(this, Bt)
7327
7325
  })), this.state = "connecting", await Q(this, wt).connect(), this.state = "connected", Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", Q(this, bt)), a(Q(this, wt));
7328
7326
  }));
7329
7327
  /**
@@ -7355,7 +7353,7 @@ class CallsWebSocket {
7355
7353
  compress: !1,
7356
7354
  ...e
7357
7355
  });
7358
- Q(this, dt).debug && (noLogEvents.includes(k) || console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", O), ignoreEvent.includes(k) || Q(this, Nt).call(this, "req", O)), a && Q(this, jt).call(this, O, { resolve: E, reject: _ });
7356
+ Q(this, dt).debug && (noLogEvents.includes(k) || console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", O), ignoreEvent.includes(k) || Q(this, At).call(this, "req", O)), a && Q(this, Zt).call(this, O, { resolve: E, reject: _ });
7359
7357
  const $ = com.quick.voice.proto.CommonReq.encode(O).finish();
7360
7358
  (N = Q(this, wt)) == null || N.sendMessage($);
7361
7359
  }));
@@ -7400,7 +7398,7 @@ class CallsWebSocket {
7400
7398
  St(this, dt, { ...Q(this, dt), ...I });
7401
7399
  }
7402
7400
  }
7403
- wt = new WeakMap(), dt = new WeakMap(), xt = new WeakMap(), yt = new WeakMap(), bt = new WeakMap(), Mt = new WeakMap(), Pt = new WeakMap(), Lt = new WeakMap(), Bt = new WeakMap(), Nt = new WeakMap(), jt = new WeakMap(), Zt = new WeakMap(), Ft = new WeakMap();
7401
+ wt = new WeakMap(), dt = new WeakMap(), Nt = new WeakMap(), yt = new WeakMap(), bt = new WeakMap(), Pt = new WeakMap(), Lt = new WeakMap(), Bt = new WeakMap(), jt = new WeakMap(), At = new WeakMap(), Zt = new WeakMap(), Ft = new WeakMap(), Ht = new WeakMap();
7404
7402
  var y = Object.defineProperty, x = (u) => {
7405
7403
  throw TypeError(u);
7406
7404
  }, g = (u, I, a) => I in u ? y(u, I, { enumerable: !0, configurable: !0, writable: !0, value: a }) : u[I] = a, h = (u, I, a) => g(u, typeof I != "symbol" ? I + "" : I, a), b = (u, I, a) => I.has(u) || x("Cannot " + a), o = (u, I, a) => (b(u, I, "read from private field"), a ? a.call(u) : I.get(u)), f = (u, I, a) => I.has(u) ? x("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(u) : I.set(u, a), p = (u, I, a, E) => (b(u, I, "write to private field"), I.set(u, a), a), d, c, l;
@@ -7456,7 +7454,7 @@ class K {
7456
7454
  }
7457
7455
  }
7458
7456
  d = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
7459
- var Ht;
7457
+ var zt;
7460
7458
  class RoomBase {
7461
7459
  constructor(I) {
7462
7460
  Z(this, "options", {
@@ -7532,7 +7530,7 @@ class RoomBase {
7532
7530
  }
7533
7531
  }
7534
7532
  });
7535
- lt(this, Ht, () => {
7533
+ at(this, zt, () => {
7536
7534
  this.taskQueue.setCondition("createWs", !0), this.taskQueue.setCondition("createSession", !1), this.taskQueue.setCondition("ice", !1);
7537
7535
  });
7538
7536
  /**
@@ -7633,36 +7631,44 @@ class RoomBase {
7633
7631
  * 处理为应用层数据
7634
7632
  */
7635
7633
  Z(this, "usersFilter", (I) => ft(I, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "permissions", "isPublished", "updateStreams"]).sort((_, k) => _.id.localeCompare(k.id, "en")));
7636
- this.setOptions(I), this.cwsIns = new CallsWebSocket({ ...I }), Q(this, Ht).call(this);
7634
+ this.setOptions(I), this.cwsIns = new CallsWebSocket({ ...I }), Q(this, zt).call(this);
7637
7635
  }
7638
7636
  }
7639
- Ht = new WeakMap();
7640
- var It, kt, _t, vt, gt, zt, Jt, Rt, Wt;
7637
+ zt = new WeakMap();
7638
+ var Rt, kt, _t, vt, gt, Tt, Jt, Wt, Et, Gt;
7641
7639
  class RoomMedias extends RoomBase {
7642
- // 本地流活动状态管理
7643
7640
  constructor(a) {
7644
7641
  super(a);
7645
- lt(this, It, []);
7642
+ at(this, Rt, []);
7646
7643
  // 可用媒体设备列表
7647
- lt(this, kt, /* @__PURE__ */ new Map());
7644
+ at(this, kt, /* @__PURE__ */ new Map());
7648
7645
  // 媒体流设备管理
7649
- lt(this, _t, /* @__PURE__ */ new Map());
7646
+ at(this, _t, /* @__PURE__ */ new Map());
7650
7647
  // 媒体轨道参数管理
7651
- lt(this, vt, /* @__PURE__ */ new Map());
7648
+ at(this, vt, /* @__PURE__ */ new Map());
7652
7649
  // 媒体流上下文
7653
- lt(this, gt, /* @__PURE__ */ new Map());
7650
+ at(this, gt, /* @__PURE__ */ new Map());
7654
7651
  // 本地流管理
7655
7652
  Z(this, "localStreamsActionMap", /* @__PURE__ */ new Map());
7653
+ // 本地流活动状态管理
7654
+ // @ts-ignore 音频上下文
7655
+ at(this, Tt, new (window.AudioContext || window.webkitAudioContext)());
7656
+ /**
7657
+ * 播放所有音频
7658
+ */
7659
+ Z(this, "resume", () => {
7660
+ Q(this, Tt).resume();
7661
+ });
7656
7662
  /**
7657
7663
  * 初始化媒体参数
7658
7664
  */
7659
- lt(this, zt, () => {
7660
- Q(this, _t).set("microphoneCamera_audio", {}), Q(this, _t).set("microphoneCamera_video", { frameRate: { min: 10, ideal: 30 } }), Q(this, _t).set("screenSharing_video", { frameRate: { min: 10, ideal: 30 } }), Q(this, _t).set("screenSharing_audio", {});
7665
+ at(this, Jt, () => {
7666
+ Q(this, _t).set("microphoneCamera_audio", { autoGainControl: !1, echoCancellation: !1, noiseSuppression: !1 }), Q(this, _t).set("microphoneCamera_video", { frameRate: { min: 10, ideal: 30 } }), Q(this, _t).set("screenSharing_video", { frameRate: { min: 10, ideal: 30 } }), Q(this, _t).set("screenSharing_audio", { autoGainControl: !1, echoCancellation: !1, noiseSuppression: !1 });
7661
7667
  });
7662
7668
  /**
7663
7669
  * 初始化媒体设备类型
7664
7670
  */
7665
- lt(this, Jt, () => {
7671
+ at(this, Wt, () => {
7666
7672
  Q(this, kt).set("audioinput", "default"), Q(this, kt).set("videoinput", "default"), Q(this, kt).set("audiooutput", "default");
7667
7673
  });
7668
7674
  /**
@@ -7687,7 +7693,7 @@ class RoomMedias extends RoomBase {
7687
7693
  // 音频媒体处理
7688
7694
  case "audio":
7689
7695
  {
7690
- const $ = new AudioMediaContext(k);
7696
+ const $ = new AudioMediaContext(k, Q(this, Tt));
7691
7697
  Q(this, vt).set(e, $);
7692
7698
  }
7693
7699
  break;
@@ -7775,7 +7781,7 @@ class RoomMedias extends RoomBase {
7775
7781
  const k = this.getUserStream(this.options.userId, a).getTracks();
7776
7782
  if (k.length !== 0)
7777
7783
  for (const e of k) {
7778
- const O = { ...e.getConstraints(), ...E };
7784
+ const O = { echoCancellation: !1, noiseSuppression: !1, autoGainControl: !1, ...e.getConstraints(), ...E };
7779
7785
  await e.applyConstraints(O);
7780
7786
  }
7781
7787
  });
@@ -7892,18 +7898,18 @@ class RoomMedias extends RoomBase {
7892
7898
  /**
7893
7899
  * 获取媒体设备列表
7894
7900
  */
7895
- lt(this, Rt, 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((a) => {
7896
- St(this, It, a.sort((E, _) => E.label.localeCompare(_.label, "zh-Hans-CN", { sensitivity: "accent" })));
7901
+ at(this, Et, 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((a) => {
7902
+ St(this, Rt, a.sort((E, _) => E.label.localeCompare(_.label, "zh-Hans-CN", { sensitivity: "accent" })));
7897
7903
  }).catch(function(a) {
7898
7904
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", a);
7899
- }), Q(this, It)));
7905
+ }), Q(this, Rt)));
7900
7906
  /**
7901
7907
  * 媒体设备发生变化
7902
7908
  */
7903
- lt(this, Wt, () => {
7909
+ at(this, Gt, () => {
7904
7910
  navigator.mediaDevices && (navigator.mediaDevices.ondevicechange = async () => {
7905
- await Q(this, Rt).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
7906
- }), Q(this, Rt).call(this);
7911
+ await Q(this, Et).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
7912
+ }), Q(this, Et).call(this);
7907
7913
  });
7908
7914
  /**
7909
7915
  * 获取正在使用的媒体设备ID
@@ -7943,7 +7949,7 @@ class RoomMedias extends RoomBase {
7943
7949
  * @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
7944
7950
  * @returns MediaDeviceInfo[]
7945
7951
  */
7946
- Z(this, "getEnumerateDevices", async (a) => (await Q(this, Rt).call(this), Q(this, It).filter((_) => _.kind === a)));
7952
+ Z(this, "getEnumerateDevices", async (a) => (await Q(this, Et).call(this), Q(this, Rt).filter((_) => _.kind === a)));
7947
7953
  /**
7948
7954
  * 获取可用音频输入设备
7949
7955
  * @returns MediaDeviceInfo[]
@@ -7959,10 +7965,13 @@ class RoomMedias extends RoomBase {
7959
7965
  * @returns MediaDeviceInfo[]
7960
7966
  */
7961
7967
  Z(this, "getEnumerateVideoinputDevices", () => this.getEnumerateDevices("videoinput"));
7962
- Q(this, Wt).call(this), Q(this, Jt).call(this), Q(this, zt).call(this);
7968
+ Q(this, Gt).call(this), Q(this, Wt).call(this), Q(this, Jt).call(this), document.addEventListener("click", () => {
7969
+ var E;
7970
+ ((E = Q(this, Tt)) == null ? void 0 : E.state) === "suspended" && Q(this, Tt).resume();
7971
+ });
7963
7972
  }
7964
7973
  }
7965
- It = new WeakMap(), kt = new WeakMap(), _t = new WeakMap(), vt = new WeakMap(), gt = new WeakMap(), zt = new WeakMap(), Jt = new WeakMap(), Rt = new WeakMap(), Wt = new WeakMap();
7974
+ Rt = new WeakMap(), kt = new WeakMap(), _t = new WeakMap(), vt = new WeakMap(), gt = new WeakMap(), Tt = new WeakMap(), Jt = new WeakMap(), Wt = new WeakMap(), Et = new WeakMap(), Gt = new WeakMap();
7966
7975
  class RoomUsers extends RoomMedias {
7967
7976
  constructor(a) {
7968
7977
  super(a);
@@ -8266,11 +8275,11 @@ const createMutedAudioStream = () => {
8266
8275
  O.addColorStop(0, `hsla(${k}, 100%, 50%, 0)`), O.addColorStop(1, `hsla(${k + 120}, 100%, 50%, 0)`), _.fillStyle = O, _.fillRect(0, 0, E.width, E.height), k = (k + 1) % 360;
8267
8276
  }, 100), E.captureStream(a);
8268
8277
  };
8269
- var Ot, Kt, Gt, Qt, Vt;
8278
+ var Ot, Kt, Qt, Vt, Yt;
8270
8279
  class RoomPeer extends RoomUsers {
8271
8280
  constructor(a) {
8272
8281
  super(a);
8273
- lt(this, Ot, /* @__PURE__ */ new Map());
8282
+ at(this, Ot, /* @__PURE__ */ new Map());
8274
8283
  // 假媒体流 (创建轨道用)
8275
8284
  Z(this, "getPeerStatsTimer", 0);
8276
8285
  // 获取报告的定时器
@@ -8289,10 +8298,10 @@ class RoomPeer extends RoomUsers {
8289
8298
  // 网络抖动
8290
8299
  });
8291
8300
  Z(this, "initPeer", () => {
8292
- this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this, Gt).call(this), Q(this, Vt).call(this);
8301
+ this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this, Qt).call(this), Q(this, Yt).call(this);
8293
8302
  });
8294
8303
  // 初始化假数据流
8295
- lt(this, Kt, () => {
8304
+ at(this, Kt, () => {
8296
8305
  for (const a of mediaType_keys) {
8297
8306
  const E = Q(this, Ot).get(a);
8298
8307
  if (E) {
@@ -8345,7 +8354,7 @@ class RoomPeer extends RoomUsers {
8345
8354
  if (!k) continue;
8346
8355
  const { mid: e, sender: n } = k, { track: O } = n;
8347
8356
  if (!O) continue;
8348
- const { id: $, enabled: N } = O, q = { type: mediaType_keys.findIndex((P) => P === _), enabled: N, trackName: $, location: "local", mid: e };
8357
+ const { id: $, enabled: N } = O, D = mediaType_keys.findIndex((P) => P === _), q = { type: D, enabled: N, trackName: `web-${D}-${$}`, location: "local", mid: e };
8349
8358
  E.push(q);
8350
8359
  }
8351
8360
  return E;
@@ -8416,15 +8425,15 @@ class RoomPeer extends RoomUsers {
8416
8425
  if (!Y) return;
8417
8426
  const { userId: et, mediaType: tt } = Y;
8418
8427
  if (!(!et || !tt)) {
8419
- if (await this.initUserMediaStreamContext(et, tt, q), z === "audio") {
8420
- const nt = this.getUserMediaStreamContext(et, tt);
8421
- (nt == null ? void 0 : nt.kind) === "audio" && nt.setMute(!1);
8422
- }
8423
8428
  {
8424
8429
  const nt = { ...Y, mid: P, msid: J };
8425
8430
  e.push(nt);
8426
8431
  }
8427
- this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->quickvo: await subscribe ${e.length}/${k.length}`, { mediaType: tt, mid: P, userTrack: Y, e: $ }), k.length === e.length && n();
8432
+ if (this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->quickvo: await subscribe ${e.length}/${k.length}`, { mediaType: tt, mid: P, userTrack: Y, e: $ }), await this.initUserMediaStreamContext(et, tt, q), z === "audio") {
8433
+ const nt = this.getUserMediaStreamContext(et, tt);
8434
+ (nt == null ? void 0 : nt.kind) === "audio" && nt.setMute(!1);
8435
+ }
8436
+ k.length === e.length && n();
8428
8437
  }
8429
8438
  };
8430
8439
  this.peerIns.addEventListener("track", O), E = setTimeout(() => n(), 5 * 1e3);
@@ -8434,7 +8443,7 @@ class RoomPeer extends RoomUsers {
8434
8443
  /**
8435
8444
  * 监听webrtc ice通讯连接
8436
8445
  */
8437
- lt(this, Gt, () => {
8446
+ at(this, Qt, () => {
8438
8447
  let a = 0;
8439
8448
  const E = () => {
8440
8449
  this.setRoomState("closed");
@@ -8584,7 +8593,7 @@ class RoomPeer extends RoomUsers {
8584
8593
  /**
8585
8594
  * 计算网络质量
8586
8595
  */
8587
- lt(this, Qt, async () => {
8596
+ at(this, Vt, async () => {
8588
8597
  try {
8589
8598
  const a = await this.peerIns.getStats(), E = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"], k = [...a.values()].filter((nt) => E.includes(nt.type));
8590
8599
  let e = 0, n = 0, O = 0, $ = 0, N = 0, D = 0, q = [], P = [];
@@ -8594,23 +8603,23 @@ class RoomPeer extends RoomUsers {
8594
8603
  }
8595
8604
  this.reports = k;
8596
8605
  for (const nt of this.reports) {
8597
- const { bytesReceived: ut, bytesSent: it, packetsSent: at, packetsLost: st, jitter: rt, roundTripTime: ct } = nt;
8598
- ut && (e = ut), it && (n = it), at && (N += at), st && (D += st), ct && q.push((ct * 100).toFixed(2)), rt && P.push(rt.toFixed(2));
8606
+ const { bytesReceived: ut, bytesSent: it, packetsSent: lt, packetsLost: st, jitter: rt, roundTripTime: ct } = nt;
8607
+ ut && (e = ut), it && (n = it), lt && (N += lt), st && (D += st), ct && q.push((ct * 100).toFixed(2)), rt && P.push(rt.toFixed(2));
8599
8608
  }
8600
8609
  P.sort().reverse(), q.sort().reverse();
8601
8610
  const j = N - O, V = D - $, J = j === 0 ? "0.00" : (V / j).toFixed(2), [z = "0"] = q, [Y = "0"] = P, et = { inboundBytes: e, outboundBytes: n, lostRate: J, roundTripTime: z, jitter: Y };
8602
8611
  this.peerNetwork = et;
8603
8612
  const tt = (nt, ut, it) => {
8604
- const at = Number(nt), st = Number(ut), rt = Number(it);
8613
+ const lt = Number(nt), st = Number(ut), rt = Number(it);
8605
8614
  let ct = "0";
8606
- return at < 0.03 && st < 100 && rt < 0.05 ? ct = "5" : at < 0.06 && st < 160 && rt < 0.1 ? ct = "4" : at < 0.1 && st < 250 && rt < 0.15 ? ct = "3" : at < 0.15 && st < 400 && rt < 0.2 ? ct = "2" : ct = "1", Number(ct);
8615
+ return lt < 0.03 && st < 100 && rt < 0.05 ? ct = "5" : lt < 0.06 && st < 160 && rt < 0.1 ? ct = "4" : lt < 0.1 && st < 250 && rt < 0.15 ? ct = "3" : lt < 0.15 && st < 400 && rt < 0.2 ? ct = "2" : ct = "1", Number(ct);
8607
8616
  };
8608
8617
  {
8609
- const nt = tt(J, z, Y), ut = await this.getCaller(), { network: it } = ut, at = { egress: nt, ingress: nt }, st = JSON.stringify(it) !== JSON.stringify(at);
8610
- if (await this.updateUserNetwork(this.options.userId, at), st) {
8618
+ const nt = tt(J, z, Y), ut = await this.getCaller(), { network: it } = ut, lt = { egress: nt, ingress: nt }, st = JSON.stringify(it) !== JSON.stringify(lt);
8619
+ if (await this.updateUserNetwork(this.options.userId, lt), st) {
8611
8620
  this.emitNotifyUpdateUsers();
8612
8621
  const { userId: rt, roomId: ct } = this.options;
8613
- this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...at, userId: rt, roomId: ct } }, !1);
8622
+ this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...lt, userId: rt, roomId: ct } }, !1);
8614
8623
  }
8615
8624
  }
8616
8625
  } catch (a) {
@@ -8620,9 +8629,9 @@ class RoomPeer extends RoomUsers {
8620
8629
  /**
8621
8630
  * 获取连接的所有轨道分析数据
8622
8631
  */
8623
- lt(this, Vt, () => {
8632
+ at(this, Yt, () => {
8624
8633
  const a = async () => {
8625
- this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this, Qt).call(this);
8634
+ this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this, Vt).call(this);
8626
8635
  };
8627
8636
  this.getPeerStatsTimer = setInterval(a, 1 * 1e3);
8628
8637
  });
@@ -8633,8 +8642,8 @@ class RoomPeer extends RoomUsers {
8633
8642
  Q(this, Kt).call(this);
8634
8643
  }
8635
8644
  }
8636
- Ot = new WeakMap(), Kt = new WeakMap(), Gt = new WeakMap(), Qt = new WeakMap(), Vt = new WeakMap();
8637
- var Yt, Et, At, qt, Dt;
8645
+ Ot = new WeakMap(), Kt = new WeakMap(), Qt = new WeakMap(), Vt = new WeakMap(), Yt = new WeakMap();
8646
+ var Xt, xt, qt, Dt, Ct;
8638
8647
  class RoomCalls extends RoomPeer {
8639
8648
  constructor(a) {
8640
8649
  super(a);
@@ -8644,18 +8653,16 @@ class RoomCalls extends RoomPeer {
8644
8653
  * 广播给房间其他人
8645
8654
  * 只有当自己建立了发射轨道 并且 加入房间后才进行广播
8646
8655
  */
8647
- lt(this, Yt, async (a) => {
8656
+ at(this, Xt, async (a) => {
8648
8657
  const { roomId: E } = this.options;
8649
8658
  if (!E) return;
8650
- const { id: _, tracks: k = [] } = await this.getCaller();
8651
- if (k.length === 0) return;
8652
- const e = k.filter((n) => n.mediaType && a.includes(n.mediaType));
8653
- this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: E, user: { id: _, tracks: e } } });
8659
+ const { id: _, tracks: k = [] } = await this.getCaller(), e = k.filter((n) => n.mediaType && a.includes(n.mediaType));
8660
+ e.length !== 0 && this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: E, user: { id: _, tracks: e } } });
8654
8661
  });
8655
8662
  /**
8656
8663
  * 更新自己通话状态
8657
8664
  */
8658
- lt(this, Et, async (a) => new Promise(async (E, _) => {
8665
+ at(this, xt, async (a) => new Promise(async (E, _) => {
8659
8666
  const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: a } };
8660
8667
  await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
8661
8668
  const { code: $ = 0 } = O;
@@ -8666,7 +8673,7 @@ class RoomCalls extends RoomPeer {
8666
8673
  /**
8667
8674
  * 创建连接
8668
8675
  */
8669
- lt(this, At, () => new Promise(async (a, E) => {
8676
+ at(this, qt, () => new Promise(async (a, E) => {
8670
8677
  try {
8671
8678
  if (["connecting", "connected"].includes(this.cwsIns.state)) return a(!0);
8672
8679
  this.taskQueue.setCondition("createWs", !1), this.cwsIns.clearEvents(), this.initPeer();
@@ -8693,7 +8700,7 @@ class RoomCalls extends RoomPeer {
8693
8700
  /**
8694
8701
  * 创建cf会话
8695
8702
  */
8696
- lt(this, qt, () => {
8703
+ at(this, Dt, () => {
8697
8704
  if (!["connecting", "connected"].includes(this.roomState))
8698
8705
  return this.setRoomState("connecting"), new Promise((a) => {
8699
8706
  const E = async () => {
@@ -8729,12 +8736,12 @@ class RoomCalls extends RoomPeer {
8729
8736
  * @example quickvo.earlyConnect(['microphoneCamera_audio', 'microphoneCamera_video'])
8730
8737
  */
8731
8738
  Z(this, "earlyConnect", (a = []) => {
8732
- this.isEarly = !0, Q(this, At).call(this), Q(this, qt).call(this), a.length === 0 && (a = ["microphoneCamera_audio", "microphoneCamera_video"]), Q(this, Dt).call(this, a);
8739
+ this.isEarly = !0, Q(this, qt).call(this), Q(this, Dt).call(this), a.length === 0 && (a = ["microphoneCamera_audio", "microphoneCamera_video"]), Q(this, Ct).call(this, a);
8733
8740
  });
8734
8741
  /**
8735
8742
  * 创建媒体轨道
8736
8743
  */
8737
- lt(this, Dt, async (a) => new Promise((E) => {
8744
+ at(this, Ct, async (a) => new Promise((E) => {
8738
8745
  const _ = async () => {
8739
8746
  try {
8740
8747
  this.taskQueue.setCondition("createTrack", !1);
@@ -8847,7 +8854,7 @@ class RoomCalls extends RoomPeer {
8847
8854
  * @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' , newPublishAutoSubscribe: true })
8848
8855
  * @returns Promise<boolean>
8849
8856
  */
8850
- Z(this, "joinRoom", async (a) => (this.setOptions(a), await Q(this, At).call(this), new Promise((E, _) => {
8857
+ Z(this, "joinRoom", async (a) => (this.setOptions(a), await Q(this, qt).call(this), new Promise((E, _) => {
8851
8858
  this.clearUsers();
8852
8859
  let k = "";
8853
8860
  const e = async () => {
@@ -8866,7 +8873,7 @@ class RoomCalls extends RoomPeer {
8866
8873
  if (q !== 200) return _(P);
8867
8874
  const { roomId: V = "", roomUsers: J = [] } = j;
8868
8875
  if (V !== O) return _("加入的房间不匹配");
8869
- this.isInRoom = !0, Q(this, qt).call(this), await this.updateUsers(J), e();
8876
+ this.isInRoom = !0, Q(this, Dt).call(this), await this.updateUsers(J), e();
8870
8877
  });
8871
8878
  } catch (O) {
8872
8879
  this.taskQueue.setCondition("joinRoom", !0), this.reportLogs("join_room_error", O.message || O), _(`加入房间失败: ${O.message || O || "服务器繁忙"}`);
@@ -8952,11 +8959,11 @@ class RoomCalls extends RoomPeer {
8952
8959
  }
8953
8960
  }
8954
8961
  const O = a.filter((q) => !n.includes(q) || ["microphoneCamera_audio", "microphoneCamera_video"].includes(q));
8955
- await this.replaceSenderStream(a, !1), await Q(this, Dt).call(this, O);
8962
+ await this.replaceSenderStream(a, !1), await Q(this, Ct).call(this, O);
8956
8963
  const $ = await this.getSenderTracks(O), N = [...e.tracks, ...$];
8957
8964
  await this.updateUsertracks(e.id, N, !0);
8958
8965
  const D = await this.getCallAction(N);
8959
- await Q(this, Et).call(this, D), n.length !== 0 && await this.inactiveTracks(n, !1), O.length !== 0 && await this.replaceSenderStream(O, !0), Q(this, Yt).call(this, a);
8966
+ await Q(this, xt).call(this, D), n.length !== 0 && await this.inactiveTracks(n, !1), O.length !== 0 && await this.replaceSenderStream(O, !0), Q(this, Xt).call(this, a);
8960
8967
  {
8961
8968
  await this.emitNotifyUpdateUsers();
8962
8969
  const q = await this.getCaller();
@@ -8989,7 +8996,7 @@ class RoomCalls extends RoomPeer {
8989
8996
  await this.replaceSenderStream(a, !0), await this.closeUserTracks(e.id, n, !0), await this.removeSenders(a);
8990
8997
  {
8991
8998
  const $ = await this.getCallAction(e.tracks);
8992
- await Q(this, Et).call(this, $);
8999
+ await Q(this, xt).call(this, $);
8993
9000
  }
8994
9001
  await this.createOffer(), await this.cwsIns.sendMessage({
8995
9002
  event: "closeTrack",
@@ -9048,6 +9055,8 @@ class RoomCalls extends RoomPeer {
9048
9055
  const { remoteSdp: J, users: z = [] } = j;
9049
9056
  this.onSubscribeUserTracks(z).then(async () => {
9050
9057
  await this.renegotiate(), $();
9058
+ }).catch((Y) => {
9059
+ throw new Error(Y);
9051
9060
  }), await this.setRemoteDescription({ type: "offer", sdp: J });
9052
9061
  });
9053
9062
  };
@@ -9128,7 +9137,7 @@ class RoomCalls extends RoomPeer {
9128
9137
  }
9129
9138
  }
9130
9139
  const O = await this.getCallAction(n);
9131
- await Q(this, Et).call(this, O), await this.replaceSenderStream(a, E), await this.emitNotifyUpdateUsers(), _(!0);
9140
+ await Q(this, xt).call(this, O), await this.replaceSenderStream(a, E), await this.emitNotifyUpdateUsers(), _(!0);
9132
9141
  }));
9133
9142
  /**
9134
9143
  * 远端调试
@@ -9143,21 +9152,31 @@ class RoomCalls extends RoomPeer {
9143
9152
  }));
9144
9153
  }
9145
9154
  }
9146
- Yt = new WeakMap(), Et = new WeakMap(), At = new WeakMap(), qt = new WeakMap(), Dt = new WeakMap();
9155
+ Xt = new WeakMap(), xt = new WeakMap(), qt = new WeakMap(), Dt = new WeakMap(), Ct = new WeakMap();
9147
9156
  class Room extends RoomCalls {
9148
9157
  constructor(I) {
9149
9158
  super(I);
9150
9159
  }
9151
9160
  }
9152
- var Tt, Xt, te, ee, ie;
9161
+ var It, te, ee, ie, ne;
9153
9162
  class QuickVO extends Room {
9154
9163
  constructor(a) {
9155
9164
  super(a);
9156
- lt(this, Tt, /* @__PURE__ */ new Map());
9165
+ at(this, It, /* @__PURE__ */ new Map());
9157
9166
  /**
9158
9167
  * 添加内部监听事件
9159
9168
  */
9160
- lt(this, Xt, () => {
9169
+ at(this, te, () => {
9170
+ {
9171
+ const a = async (E) => {
9172
+ const { state: _ } = E.data;
9173
+ if (_ === "closed") {
9174
+ const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e } };
9175
+ this.cwsIns.sendMessage({ event: "quitRoom", data: n }), this.cwsIns.close();
9176
+ }
9177
+ };
9178
+ this.cwsIns.addNotify({ event: "onRoomState", callback: a }, !0);
9179
+ }
9161
9180
  {
9162
9181
  const a = async (E) => {
9163
9182
  const { qualities: _ = [] } = E.data, [k] = _;
@@ -9238,12 +9257,12 @@ class QuickVO extends Room {
9238
9257
  /**
9239
9258
  * cwsIns 发送消息前
9240
9259
  */
9241
- lt(this, te, () => {
9260
+ at(this, ee, () => {
9242
9261
  });
9243
9262
  /**
9244
9263
  * 重连成功
9245
9264
  */
9246
- lt(this, ee, () => {
9265
+ at(this, ie, () => {
9247
9266
  this.cwsIns.onReconnectSuccess = async () => {
9248
9267
  await this.syncRoomInfo();
9249
9268
  };
@@ -9251,7 +9270,7 @@ class QuickVO extends Room {
9251
9270
  /**
9252
9271
  * 重连停止
9253
9272
  */
9254
- lt(this, ie, async () => {
9273
+ at(this, ne, async () => {
9255
9274
  });
9256
9275
  /**
9257
9276
  * 添加 FrameRequestCallback
@@ -9260,13 +9279,13 @@ class QuickVO extends Room {
9260
9279
  */
9261
9280
  Z(this, "addRequestAnimationFrame", async (a, E) => {
9262
9281
  {
9263
- const k = Q(this, Tt).get(a);
9282
+ const k = Q(this, It).get(a);
9264
9283
  k && cancelAnimationFrame(k);
9265
9284
  }
9266
9285
  const _ = (k = Date.now()) => {
9267
9286
  E(k);
9268
9287
  const e = requestAnimationFrame(_);
9269
- Q(this, Tt).set(a, e);
9288
+ Q(this, It).set(a, e);
9270
9289
  };
9271
9290
  _();
9272
9291
  });
@@ -9275,10 +9294,10 @@ class QuickVO extends Room {
9275
9294
  * @param keys string[] = []
9276
9295
  */
9277
9296
  Z(this, "clearRequestAnimationFrame", async (a = []) => {
9278
- a.length === 0 && (a = [...Q(this, Tt).keys()]);
9297
+ a.length === 0 && (a = [...Q(this, It).keys()]);
9279
9298
  const E = [];
9280
9299
  for (const _ of a) {
9281
- const k = Q(this, Tt).get(_);
9300
+ const k = Q(this, It).get(_);
9282
9301
  k && (cancelAnimationFrame(k), E.push(k));
9283
9302
  }
9284
9303
  return E;
@@ -9290,10 +9309,10 @@ class QuickVO extends Room {
9290
9309
  Z(this, "destroy", async () => {
9291
9310
  this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 销毁SDK"), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {}, desc: "sdk is destroy." }), this.stopLocalStreams(), await new Promise((a) => setTimeout(() => a(!0), 300)), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.cwsIns.close();
9292
9311
  });
9293
- Q(this, te).call(this), Q(this, ee).call(this), Q(this, ie).call(this), Q(this, Xt).call(this);
9312
+ Q(this, ee).call(this), Q(this, ie).call(this), Q(this, ne).call(this), Q(this, te).call(this);
9294
9313
  }
9295
9314
  }
9296
- Tt = new WeakMap(), Xt = new WeakMap(), te = new WeakMap(), ee = new WeakMap(), ie = new WeakMap();
9315
+ It = new WeakMap(), te = new WeakMap(), ee = new WeakMap(), ie = new WeakMap(), ne = new WeakMap();
9297
9316
  export {
9298
9317
  QuickVO,
9299
9318
  ignoreEvent