quickvo-sdk-js 0.5.8 → 0.6.0

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 ie = Object.defineProperty;
2
- var te = (a) => {
1
+ var re = Object.defineProperty;
2
+ var ne = (a) => {
3
3
  throw TypeError(a);
4
4
  };
5
- var ne = (a, I, u) => I in a ? ie(a, I, { enumerable: !0, configurable: !0, writable: !0, value: u }) : a[I] = u;
6
- var Z = (a, I, u) => ne(a, typeof I != "symbol" ? I + "" : I, u), ee = (a, I, u) => I.has(a) || te("Cannot " + u);
7
- var Q = (a, I, u) => (ee(a, I, "read from private field"), u ? u.call(a) : I.get(a)), st = (a, I, u) => I.has(a) ? te("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(a) : I.set(a, u), wt = (a, I, u, E) => (ee(a, I, "write to private field"), E ? E.call(a, u) : I.set(a, u), u);
5
+ var ce = (a, I, u) => I in a ? re(a, I, { enumerable: !0, configurable: !0, writable: !0, value: u }) : a[I] = u;
6
+ var Z = (a, I, u) => ce(a, typeof I != "symbol" ? I + "" : I, u), oe = (a, I, u) => I.has(a) || ne("Cannot " + u);
7
+ var Q = (a, I, u) => (oe(a, I, "read from private field"), u ? u.call(a) : I.get(a)), st = (a, I, u) => I.has(a) ? ne("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(a) : I.set(a, u), wt = (a, I, u, E) => (oe(a, I, "write to private field"), E ? E.call(a, u) : I.set(a, u), u);
8
8
  const L = (a, I = []) => {
9
9
  const u = { ...a }, E = Object.keys(u);
10
10
  for (const _ of E)
@@ -720,11 +720,17 @@ class AudioMediaContext {
720
720
  });
721
721
  Z(this, "kind", "audio");
722
722
  Z(this, "stream", new MediaStream());
723
+ Z(this, "gain", 1);
724
+ // 音量
725
+ Z(this, "enhanceGain", 0);
726
+ // 音量增强
723
727
  Z(this, "audio", new Audio());
724
728
  // @ts-ignore 音频上下文
725
729
  Z(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
726
730
  // 媒体流音频源节点
727
731
  Z(this, "mediaStreamAudioSourceNode");
732
+ // 媒体流音频源节点
733
+ Z(this, "destination");
728
734
  // 增益节点 (自动增益)
729
735
  Z(this, "autoGainNode");
730
736
  // 滤波器节点 (噪声抑制)
@@ -756,23 +762,33 @@ class AudioMediaContext {
756
762
  /**
757
763
  * 获取数据流
758
764
  */
759
- Z(this, "getStream", () => this.mediaStreamAudioSourceNode.mediaStream);
765
+ Z(this, "getStream", () => this.destination.stream);
766
+ // getStream = () => this.mediaStreamAudioSourceNode.mediaStream
760
767
  /**
761
768
  * 静音
762
769
  */
763
770
  Z(this, "setMute", (I = !0) => {
764
771
  I ? this.analyserNode.disconnect(this.audioContext.destination) : this.analyserNode.connect(this.audioContext.destination);
765
772
  });
773
+ /**
774
+ * 设置音量
775
+ */
776
+ Z(this, "setGain", () => {
777
+ const I = (1 + this.enhanceGain) * this.gain;
778
+ this.gainNode.gain.setValueAtTime(I, this.audioContext.currentTime);
779
+ });
766
780
  /**
767
781
  * 设置增强音量
768
782
  */
769
783
  Z(this, "setEnhanceGain", async (I) => {
784
+ let u = Math.max(0, I);
785
+ u = Math.min(u, 1), this.enhanceGain = u, this.setGain();
770
786
  });
771
787
  /**
772
- * 设置音量
788
+ * 设置基础音量
773
789
  */
774
790
  Z(this, "setVolumeGain", (I) => {
775
- this.gainNode.gain.setValueAtTime(I, this.audioContext.currentTime);
791
+ this.gain = I, this.setGain();
776
792
  });
777
793
  /**
778
794
  * 获取音量
@@ -793,9 +809,9 @@ class AudioMediaContext {
793
809
  const { autoGainControl: u, noiseSuppression: E, echoCancellation: _ } = this.options, { mediaStreamAudioSourceNode: k, autoGainNode: e, biquadFilterNode: n, delayNode: O, gainNode: $ } = this, N = k;
794
810
  return u && N.connect(e), E && N.connect(n), _ && N.connect(O), N.connect($), I;
795
811
  });
796
- this.stream.addTrack(I), 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(1, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
797
- const { gainNode: u, analyserNode: E } = this;
798
- u.connect(E), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
812
+ this.stream.addTrack(I), this.audio.srcObject = this.stream, this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.destination = this.audioContext.createMediaStreamDestination(), 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);
813
+ const { gainNode: u, destination: E, analyserNode: _ } = this;
814
+ u.connect(E), u.connect(_), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
799
815
  }
800
816
  }
801
817
  class VideoMediaContext {
@@ -6359,7 +6375,7 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
6359
6375
  const O = n.bits;
6360
6376
  let $ = 0, N = 0, D = 0, q = 0, P = 0, j = 0, V = 0, J = 0, z = 0, Y = 0, et, tt, nt, lt, it, at = null, ct;
6361
6377
  const ot = new Uint16Array(MAXBITS + 1), rt = new Uint16Array(MAXBITS + 1);
6362
- let Ot = null, Xt, Nt, At;
6378
+ let Ot = null, ie, Dt, Ct;
6363
6379
  for ($ = 0; $ <= MAXBITS; $++)
6364
6380
  ot[$] = 0;
6365
6381
  for (N = 0; N < E; N++)
@@ -6382,9 +6398,9 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
6382
6398
  if (a === CODES$1 ? (at = Ot = e, ct = 20) : a === LENS$1 ? (at = lbase, Ot = lext, ct = 257) : (at = dbase, Ot = dext, ct = 0), Y = 0, N = 0, $ = D, it = k, j = P, V = 0, nt = -1, z = 1 << P, lt = z - 1, a === LENS$1 && z > ENOUGH_LENS$1 || a === DISTS$1 && z > ENOUGH_DISTS$1)
6383
6399
  return 1;
6384
6400
  for (; ; ) {
6385
- Xt = $ - V, e[N] + 1 < ct ? (Nt = 0, At = e[N]) : e[N] >= ct ? (Nt = Ot[e[N] - ct], At = at[e[N] - ct]) : (Nt = 96, At = 0), et = 1 << $ - V, tt = 1 << j, D = tt;
6401
+ ie = $ - V, e[N] + 1 < ct ? (Dt = 0, Ct = e[N]) : e[N] >= ct ? (Dt = Ot[e[N] - ct], Ct = at[e[N] - ct]) : (Dt = 96, Ct = 0), et = 1 << $ - V, tt = 1 << j, D = tt;
6386
6402
  do
6387
- tt -= et, _[it + (Y >> V) + tt] = Xt << 24 | Nt << 16 | At | 0;
6403
+ tt -= et, _[it + (Y >> V) + tt] = ie << 24 | Dt << 16 | Ct | 0;
6388
6404
  while (tt !== 0);
6389
6405
  for (et = 1 << $ - 1; Y & et; )
6390
6406
  et >>= 1;
@@ -7154,7 +7170,7 @@ const noLogEvents = ["heartbeat", "onNetQuality", "networkQualityChange"], compr
7154
7170
  }
7155
7171
  return a;
7156
7172
  };
7157
- var vt, ut, Rt, yt, _t, qt, Dt, Ct, Ut, Et, Mt, Pt, Bt;
7173
+ var vt, ut, Rt, yt, _t, Ut, Mt, Pt, Bt, Et, Lt, jt, Zt;
7158
7174
  class CallsWebSocket {
7159
7175
  // 状态
7160
7176
  constructor(I) {
@@ -7183,21 +7199,21 @@ class CallsWebSocket {
7183
7199
  Z(this, "onReconnectStop", (I) => {
7184
7200
  });
7185
7201
  // 是否需要重连
7186
- st(this, qt, (I) => {
7202
+ st(this, Ut, (I) => {
7187
7203
  let u = !0;
7188
7204
  const { code: E = 1e3, reason: _ = "" } = I;
7189
7205
  return E === 1e3 && (_ === "quit success!" || _ === "replace old connection!") && (u = !1), u;
7190
7206
  });
7191
7207
  // 重连成功
7192
- st(this, Dt, async (I) => {
7208
+ st(this, Mt, async (I) => {
7193
7209
  Q(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重连成功", I), this.state = "connected", this.onReconnectSuccess(I);
7194
7210
  });
7195
7211
  // 重连停止
7196
- st(this, Ct, async (I) => {
7212
+ st(this, Pt, async (I) => {
7197
7213
  Q(this, ut).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);
7198
7214
  });
7199
7215
  // 自定义心跳规则
7200
- st(this, Ut, () => {
7216
+ st(this, Bt, () => {
7201
7217
  const I = { event: "heartbeat", sn: +`${F(1e5, 999999)}` };
7202
7218
  return com.quick.voice.proto.CommonReq.encode(I).finish();
7203
7219
  });
@@ -7206,11 +7222,11 @@ class CallsWebSocket {
7206
7222
  try {
7207
7223
  const { time: E, event: _, data: k = {}, data_original: e = {}, data_remote: n, ...O } = u, $ = U(E, "YYYY-MM-DD hh:mm:ss", { offset: 480 });
7208
7224
  let N = {};
7209
- const D = (Y = {}) => {
7210
- const et = JSON.parse(JSON.stringify(Y)), tt = Object.keys(et);
7211
- for (const nt of tt)
7212
- (nt.includes("sdp") || nt.includes("Sdp")) && (et[nt] = "");
7213
- return et;
7225
+ const D = (et = {}) => {
7226
+ const tt = JSON.parse(JSON.stringify(et)), nt = Object.keys(tt);
7227
+ for (const lt of nt)
7228
+ (lt.includes("sdp") || lt.includes("Sdp")) && (tt[lt] = "");
7229
+ return tt;
7214
7230
  };
7215
7231
  let q = "res ↓";
7216
7232
  switch (I) {
@@ -7223,14 +7239,25 @@ class CallsWebSocket {
7223
7239
  }
7224
7240
  let P = "#quickvo.logs";
7225
7241
  ignoreEvent.includes(_) && (P = "#quickvo.ignoreEvents");
7226
- const j = { "#action": q, timeStr: $, event: _, data: N, time: E, ...O }, V = localStorage.getItem(P) || JSON.stringify([]), J = JSON.parse(V), z = [j, ...J].slice(0, 500);
7227
- localStorage.setItem(P, JSON.stringify(z));
7242
+ const j = { "#action": q, timeStr: $, event: _, data: N, time: E, ...O }, V = localStorage.getItem(P) || JSON.stringify([]), J = JSON.parse(V);
7243
+ let z = _ === "heartbeat";
7244
+ const Y = [j];
7245
+ for (const et of J) {
7246
+ const { event: tt } = et;
7247
+ if (tt === "heartbeat") {
7248
+ if (z) continue;
7249
+ z = !0;
7250
+ }
7251
+ if (Y.length === 200) break;
7252
+ Y.push(et);
7253
+ }
7254
+ localStorage.setItem(P, JSON.stringify(Y));
7228
7255
  } catch (E) {
7229
7256
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: updataLogs is error", E);
7230
7257
  }
7231
7258
  });
7232
7259
  // 创建事件
7233
- st(this, Mt, (I, { resolve: u, reject: E }) => {
7260
+ st(this, Lt, (I, { resolve: u, reject: E }) => {
7234
7261
  const { sn: _ } = I, k = () => {
7235
7262
  const n = Q(this, yt)[_];
7236
7263
  clearTimeout(n.destructionTimer), delete Q(this, yt)[_];
@@ -7241,13 +7268,13 @@ class CallsWebSocket {
7241
7268
  Q(this, yt)[_] = { message: I, resolve: u, reject: E, destruction: k, destructionTimer: e };
7242
7269
  });
7243
7270
  // 获取事件
7244
- st(this, Pt, (I) => Q(this, yt)[I]);
7271
+ st(this, jt, (I) => Q(this, yt)[I]);
7245
7272
  // 接收消息
7246
- st(this, Bt, async (I) => {
7273
+ st(this, Zt, async (I) => {
7247
7274
  const u = new Uint8Array(I), E = com.quick.voice.proto.CommonRsp.decode(u), { sn: _, event: k } = E, e = onMessageFormat(E);
7248
7275
  if (Q(this, ut).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, Et).call(this, "res", e)), notifyName_keys.includes(k))
7249
7276
  return this.emitNotify(k, L(e, ["code", "data", "desc"]));
7250
- const O = Q(this, Pt).call(this, _);
7277
+ const O = Q(this, jt).call(this, _);
7251
7278
  if (O) {
7252
7279
  const { resolve: $ = (D) => {
7253
7280
  }, destruction: N = () => {
@@ -7277,11 +7304,11 @@ class CallsWebSocket {
7277
7304
  ...Q(this, ut),
7278
7305
  url: E,
7279
7306
  binaryType: "arraybuffer",
7280
- onMessage: Q(this, Bt),
7281
- checkReconnect: Q(this, qt),
7282
- getHeartbeatMsg: Q(this, Ut),
7283
- onReconnectSuccess: Q(this, Dt),
7284
- onReconnectStop: Q(this, Ct)
7307
+ onMessage: Q(this, Zt),
7308
+ checkReconnect: Q(this, Ut),
7309
+ getHeartbeatMsg: Q(this, Bt),
7310
+ onReconnectSuccess: Q(this, Mt),
7311
+ onReconnectStop: Q(this, Pt)
7285
7312
  })), this.state = "connecting", await Q(this, vt).connect(), this.state = "connected", Q(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", Q(this, _t)), u(Q(this, vt));
7286
7313
  }));
7287
7314
  /**
@@ -7313,7 +7340,7 @@ class CallsWebSocket {
7313
7340
  compress: !1,
7314
7341
  ...e
7315
7342
  });
7316
- Q(this, ut).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, Et).call(this, "req", O)), u && Q(this, Mt).call(this, O, { resolve: E, reject: _ });
7343
+ Q(this, ut).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, Et).call(this, "req", O)), u && Q(this, Lt).call(this, O, { resolve: E, reject: _ });
7317
7344
  const $ = com.quick.voice.proto.CommonReq.encode(O).finish();
7318
7345
  (N = Q(this, vt)) == null || N.sendMessage($);
7319
7346
  }));
@@ -7358,7 +7385,7 @@ class CallsWebSocket {
7358
7385
  wt(this, ut, { ...Q(this, ut), ...I });
7359
7386
  }
7360
7387
  }
7361
- vt = new WeakMap(), ut = new WeakMap(), Rt = new WeakMap(), yt = new WeakMap(), _t = new WeakMap(), qt = new WeakMap(), Dt = new WeakMap(), Ct = new WeakMap(), Ut = new WeakMap(), Et = new WeakMap(), Mt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap();
7388
+ vt = new WeakMap(), ut = new WeakMap(), Rt = new WeakMap(), yt = new WeakMap(), _t = new WeakMap(), Ut = new WeakMap(), Mt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), Et = new WeakMap(), Lt = new WeakMap(), jt = new WeakMap(), Zt = new WeakMap();
7362
7389
  var y = Object.defineProperty, x = (a) => {
7363
7390
  throw TypeError(a);
7364
7391
  }, g = (a, I, u) => I in a ? y(a, I, { enumerable: !0, configurable: !0, writable: !0, value: u }) : a[I] = u, h = (a, I, u) => g(a, typeof I != "symbol" ? I + "" : I, u), b = (a, I, u) => I.has(a) || x("Cannot " + u), o = (a, I, u) => (b(a, I, "read from private field"), u ? u.call(a) : I.get(a)), f = (a, I, u) => I.has(a) ? x("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(a) : I.set(a, u), p = (a, I, u, E) => (b(a, I, "write to private field"), I.set(a, u), u), d, c, l;
@@ -7414,7 +7441,7 @@ class K {
7414
7441
  }
7415
7442
  }
7416
7443
  d = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
7417
- var Lt;
7444
+ var Ft;
7418
7445
  class RoomBase {
7419
7446
  constructor(I) {
7420
7447
  Z(this, "options", {
@@ -7422,6 +7449,8 @@ class RoomBase {
7422
7449
  sdkToken: "",
7423
7450
  roomId: "",
7424
7451
  userId: "",
7452
+ earlyId: "",
7453
+ // 预连接ID
7425
7454
  callType: 0,
7426
7455
  debug: !1,
7427
7456
  newPublishAutoSubscribe: !0
@@ -7429,7 +7458,7 @@ class RoomBase {
7429
7458
  Z(this, "prohibitNotify", !1);
7430
7459
  // 是否禁止通知
7431
7460
  Z(this, "isEarly", !1);
7432
- // 是否提前建连
7461
+ // 是否 预连接
7433
7462
  Z(this, "isInRoom", !1);
7434
7463
  // 是否在房间内
7435
7464
  Z(this, "taskQueue", new K(["createWs", "createSession", "ice", "joinRoom", "createTrack", "subscribe", "closeTrack"]));
@@ -7454,7 +7483,18 @@ class RoomBase {
7454
7483
  screenSharing_video: "",
7455
7484
  screenSharing_audio: ""
7456
7485
  });
7457
- st(this, Lt, () => {
7486
+ /**
7487
+ * 提交日志
7488
+ */
7489
+ Z(this, "reportLogs", (I, u = "未知错误") => {
7490
+ const { appid: E, userId: _, earlyId: k } = this.options;
7491
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: obj", { origin: "web", type: I, app_id: E, user_id: _, ins_id: k, comment: u });
7492
+ {
7493
+ const O = localStorage.getItem("#quickvo.logs") || JSON.stringify([]), N = new TextEncoder().encode(O);
7494
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: binaryStream", N);
7495
+ }
7496
+ });
7497
+ st(this, Ft, () => {
7458
7498
  this.taskQueue.setCondition("createWs", !0), this.taskQueue.setCondition("createSession", !1), this.taskQueue.setCondition("ice", !1);
7459
7499
  });
7460
7500
  /**
@@ -7547,11 +7587,11 @@ class RoomBase {
7547
7587
  * 处理为应用层数据
7548
7588
  */
7549
7589
  Z(this, "usersFilter", (I) => ft(I, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "permissions", "isPublished", "updateStreams"]).sort((_, k) => _.id.localeCompare(k.id, "en")));
7550
- this.setOptions(I), this.cwsIns = new CallsWebSocket({ ...I }), Q(this, Lt).call(this);
7590
+ this.setOptions(I), this.cwsIns = new CallsWebSocket({ ...I }), Q(this, Ft).call(this);
7551
7591
  }
7552
7592
  }
7553
- Lt = new WeakMap();
7554
- var $t, kt, dt, bt, jt, Zt, Tt, Ft;
7593
+ Ft = new WeakMap();
7594
+ var $t, kt, dt, bt, Ht, zt, Tt, Jt;
7555
7595
  class RoomMedias extends RoomBase {
7556
7596
  // 媒体流上下文
7557
7597
  constructor(u) {
@@ -7566,13 +7606,13 @@ class RoomMedias extends RoomBase {
7566
7606
  /**
7567
7607
  * 初始化媒体参数
7568
7608
  */
7569
- st(this, jt, () => {
7609
+ st(this, Ht, () => {
7570
7610
  Q(this, dt).set("microphoneCamera_audio", {}), Q(this, dt).set("microphoneCamera_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), Q(this, dt).set("screenSharing_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), Q(this, dt).set("screenSharing_audio", {});
7571
7611
  });
7572
7612
  /**
7573
7613
  * 初始化媒体设备类型
7574
7614
  */
7575
- st(this, Zt, () => {
7615
+ st(this, zt, () => {
7576
7616
  Q(this, kt).set("audioinput", "default"), Q(this, kt).set("videoinput", "default"), Q(this, kt).set("audiooutput", "default");
7577
7617
  });
7578
7618
  /**
@@ -7782,7 +7822,7 @@ class RoomMedias extends RoomBase {
7782
7822
  /**
7783
7823
  * 媒体设备发生变化
7784
7824
  */
7785
- st(this, Ft, () => {
7825
+ st(this, Jt, () => {
7786
7826
  navigator.mediaDevices && (navigator.mediaDevices.ondevicechange = async () => {
7787
7827
  await Q(this, Tt).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
7788
7828
  }), Q(this, Tt).call(this);
@@ -7837,10 +7877,10 @@ class RoomMedias extends RoomBase {
7837
7877
  * @returns MediaDeviceInfo[]
7838
7878
  */
7839
7879
  Z(this, "getEnumerateVideoinputDevices", () => this.getEnumerateDevices("videoinput"));
7840
- Q(this, Ft).call(this), Q(this, Zt).call(this), Q(this, jt).call(this);
7880
+ Q(this, Jt).call(this), Q(this, zt).call(this), Q(this, Ht).call(this);
7841
7881
  }
7842
7882
  }
7843
- $t = new WeakMap(), kt = new WeakMap(), dt = new WeakMap(), bt = new WeakMap(), jt = new WeakMap(), Zt = new WeakMap(), Tt = new WeakMap(), Ft = new WeakMap();
7883
+ $t = new WeakMap(), kt = new WeakMap(), dt = new WeakMap(), bt = new WeakMap(), Ht = new WeakMap(), zt = new WeakMap(), Tt = new WeakMap(), Jt = new WeakMap();
7844
7884
  class RoomUsers extends RoomMedias {
7845
7885
  constructor(u) {
7846
7886
  super(u);
@@ -7879,7 +7919,7 @@ class RoomUsers extends RoomMedias {
7879
7919
  * 设置增强音量
7880
7920
  * @param userId
7881
7921
  * @param mediaType
7882
- * @param gain
7922
+ * @param gain 0-100
7883
7923
  */
7884
7924
  Z(this, "setEnhanceGain", async (u, E, _) => {
7885
7925
  const k = this.getUserMediaStreamContext(u, E);
@@ -7889,7 +7929,7 @@ class RoomUsers extends RoomMedias {
7889
7929
  * 设置音量
7890
7930
  * @param userId
7891
7931
  * @param mediaType
7892
- * @param gain
7932
+ * @param gain 0-1
7893
7933
  */
7894
7934
  Z(this, "setVolume", (u, E, _) => {
7895
7935
  const k = this.getUserMediaStreamContext(u, E);
@@ -8144,7 +8184,7 @@ const createMutedAudioStream = () => {
8144
8184
  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;
8145
8185
  }, 100), E.captureStream(u);
8146
8186
  };
8147
- var St, Ht, xt, zt, Jt, Wt;
8187
+ var St, Wt, xt, Kt, Gt, Qt;
8148
8188
  class RoomPeer extends RoomUsers {
8149
8189
  constructor(u) {
8150
8190
  super(u);
@@ -8167,10 +8207,10 @@ class RoomPeer extends RoomUsers {
8167
8207
  // 网络抖动
8168
8208
  });
8169
8209
  Z(this, "initPeer", () => {
8170
- this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this, zt).call(this), Q(this, Wt).call(this);
8210
+ this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this, Kt).call(this), Q(this, Qt).call(this);
8171
8211
  });
8172
8212
  // 初始化假数据流
8173
- st(this, Ht, () => {
8213
+ st(this, Wt, () => {
8174
8214
  for (const u of mediaType_keys)
8175
8215
  switch (u) {
8176
8216
  case "microphoneCamera_audio":
@@ -8314,14 +8354,14 @@ class RoomPeer extends RoomUsers {
8314
8354
  /**
8315
8355
  * 监听webrtc ice通讯连接
8316
8356
  */
8317
- st(this, zt, () => {
8357
+ st(this, Kt, () => {
8318
8358
  let u = 0;
8319
8359
  const E = () => {
8320
8360
  this.setRoomState("closed");
8321
8361
  };
8322
- this.peerIns.onconnectionstatechange = () => {
8323
- const _ = this.peerIns.connectionState;
8324
- switch (clearTimeout(u), _) {
8362
+ this.peerIns.oniceconnectionstatechange = () => {
8363
+ const _ = this.peerIns.iceConnectionState;
8364
+ switch (this.taskQueue.setCondition("ice", !1), clearTimeout(u), _) {
8325
8365
  // 连接完成
8326
8366
  case "connected":
8327
8367
  this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->quickvo: connectionState:${_}`), this.taskQueue.setCondition("ice", !0);
@@ -8463,7 +8503,7 @@ class RoomPeer extends RoomUsers {
8463
8503
  /**
8464
8504
  * 计算网络质量
8465
8505
  */
8466
- st(this, Jt, async () => {
8506
+ st(this, Gt, async () => {
8467
8507
  try {
8468
8508
  const u = await this.peerIns.getStats(), E = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"], k = [...u.values()].filter((nt) => E.includes(nt.type));
8469
8509
  let e = 0, n = 0, O = 0, $ = 0, N = 0, D = 0, q = [], P = [];
@@ -8499,9 +8539,9 @@ class RoomPeer extends RoomUsers {
8499
8539
  /**
8500
8540
  * 获取连接的所有轨道分析数据
8501
8541
  */
8502
- st(this, Wt, () => {
8542
+ st(this, Qt, () => {
8503
8543
  const u = async () => {
8504
- this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this, Jt).call(this);
8544
+ this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this, Gt).call(this);
8505
8545
  };
8506
8546
  this.getPeerStatsTimer = setInterval(u, 1 * 1e3);
8507
8547
  });
@@ -8509,16 +8549,124 @@ class RoomPeer extends RoomUsers {
8509
8549
  * 停止网络报告分析
8510
8550
  */
8511
8551
  Z(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
8512
- Q(this, Ht).call(this);
8552
+ Q(this, Wt).call(this);
8513
8553
  }
8514
8554
  }
8515
- St = new WeakMap(), Ht = new WeakMap(), xt = new WeakMap(), zt = new WeakMap(), Jt = new WeakMap(), Wt = new WeakMap();
8516
- var Kt, It;
8555
+ St = new WeakMap(), Wt = new WeakMap(), xt = new WeakMap(), Kt = new WeakMap(), Gt = new WeakMap(), Qt = new WeakMap();
8556
+ var Vt, It, Nt, At, qt;
8517
8557
  class RoomCalls extends RoomPeer {
8518
8558
  constructor(u) {
8519
8559
  super(u);
8520
8560
  // sdk服务版本
8521
8561
  Z(this, "sdk_service_version", "1.0.5");
8562
+ /**
8563
+ * 广播给房间其他人
8564
+ * 只有当自己建立了发射轨道 并且 加入房间后才进行广播
8565
+ */
8566
+ st(this, Vt, async (u) => {
8567
+ const { roomId: E } = this.options;
8568
+ if (!E) return;
8569
+ const { id: _, tracks: k = [] } = await this.getCaller();
8570
+ if (k.length === 0) return;
8571
+ const e = k.filter((n) => n.mediaType && u.includes(n.mediaType));
8572
+ this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: E, user: { id: _, tracks: e } } });
8573
+ });
8574
+ /**
8575
+ * 更新自己通话状态
8576
+ */
8577
+ st(this, It, async (u) => new Promise(async (E, _) => {
8578
+ const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: u } };
8579
+ await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
8580
+ const { code: $ = 0 } = O;
8581
+ if ($ !== 200) return _(O);
8582
+ await this.updateUserCallAction(e, u), E(u);
8583
+ }).catch((O) => _(O));
8584
+ }));
8585
+ /**
8586
+ * 创建连接
8587
+ */
8588
+ st(this, Nt, () => new Promise(async (u, E) => {
8589
+ try {
8590
+ if (["connecting", "connected"].includes(this.cwsIns.state)) return u(!0);
8591
+ this.taskQueue.setCondition("createWs", !1), this.cwsIns.clearEvents(), this.initPeer();
8592
+ const { appid: _ } = this.options, { userId: k = "", sdkToken: e, roomId: n } = this.options;
8593
+ if (!_) return E("quickvo: createWs is error. You must first use QuickVO.setOptions to set the appid.");
8594
+ const O = {
8595
+ a: e,
8596
+ b: k,
8597
+ c: _,
8598
+ r: n,
8599
+ v: this.sdk_service_version
8600
+ };
8601
+ if (this.isEarly) {
8602
+ const N = ht();
8603
+ O.i = N;
8604
+ }
8605
+ this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createWs", O);
8606
+ const $ = btoa(encodeURI(JSON.stringify(O)));
8607
+ await this.cwsIns.connect($), this.taskQueue.setCondition("createWs", !0), u(!0);
8608
+ } catch (_) {
8609
+ console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createWs is error.", _), E(_);
8610
+ }
8611
+ }));
8612
+ /**
8613
+ * 创建cf会话
8614
+ */
8615
+ st(this, At, () => {
8616
+ if (!["connecting", "connected"].includes(this.roomState))
8617
+ return this.setRoomState("connecting"), new Promise((u) => {
8618
+ const E = async () => {
8619
+ try {
8620
+ this.taskQueue.setCondition("createSession", !1), await this.addSenders(), await this.cwsIns.sendMessage({
8621
+ event: "connectCF",
8622
+ data: { sdp: this.getSdp() }
8623
+ }).then(async (_) => {
8624
+ const { code: k = 0, desc: e, data: n } = _;
8625
+ if (k !== 200) throw new Error(e);
8626
+ const { remoteSdp: O } = n;
8627
+ this.taskQueue.setCondition("ice", !1), await this.setRemoteDescription({ type: "answer", sdp: O }), this.taskQueue.setCondition("createSession", !0), u(!0);
8628
+ });
8629
+ } catch (_) {
8630
+ this.taskQueue.setCondition("createSession", !0), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo create session is error.", _);
8631
+ }
8632
+ };
8633
+ this.taskQueue.addTask(E, ["createWs"], { key: "createSession", describe: "createSession" });
8634
+ });
8635
+ });
8636
+ /**
8637
+ * 预连接
8638
+ * @param mediaTypes MediaType[]
8639
+ * @example quickvo.earlyConnect(['microphoneCamera_audio', 'microphoneCamera_video'])
8640
+ */
8641
+ Z(this, "earlyConnect", (u = []) => {
8642
+ this.isEarly = !0, Q(this, Nt).call(this), Q(this, At).call(this), u.length === 0 && (u = ["microphoneCamera_audio", "microphoneCamera_video"]), Q(this, qt).call(this, u);
8643
+ });
8644
+ /**
8645
+ * 创建媒体轨道
8646
+ */
8647
+ st(this, qt, async (u) => new Promise((E) => {
8648
+ const _ = async () => {
8649
+ try {
8650
+ this.taskQueue.setCondition("createTrack", !1);
8651
+ const k = await this.addSenders(u), e = this.getSenderTracks(k);
8652
+ if (e.length === 0)
8653
+ return this.taskQueue.setCondition("createTrack", !0), E(!0);
8654
+ await this.cwsIns.sendMessage({
8655
+ event: "publish",
8656
+ data: { sdp: this.getSdp(), tracks: e, callAction: 0 }
8657
+ }).then(async (n) => {
8658
+ const { code: O = 0, desc: $, data: N } = n;
8659
+ if (O !== 200)
8660
+ throw this.options.debug && console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createTrack is error.", { mediaTypes: u }), new Error($);
8661
+ const { remoteSdp: D } = N;
8662
+ await this.setRemoteDescription({ type: "answer", sdp: D }), this.taskQueue.setCondition("createTrack", !0), E(!0);
8663
+ });
8664
+ } catch {
8665
+ await this.removeSenders(u), this.taskQueue.setCondition("createTrack", !0), E(!0);
8666
+ }
8667
+ };
8668
+ this.taskQueue.addTask(_, ["createWs", "createSession", "ice", "subscribe", "createTrack", "closeTrack"], { describe: "createTrack" });
8669
+ }));
8522
8670
  /**
8523
8671
  * 设置本地流
8524
8672
  * @param mediaType MediaType
@@ -8586,31 +8734,13 @@ class RoomCalls extends RoomPeer {
8586
8734
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: changeScreenSharing is error.", e);
8587
8735
  }
8588
8736
  });
8589
- /**
8590
- * 添加广播事件
8591
- * @param notify Notify
8592
- * @returns sn
8593
- */
8594
- Z(this, "addNotify", (u) => this.cwsIns.addNotify(u));
8595
- /**
8596
- * 广播给房间其他人
8597
- * 只有当自己建立了发射轨道 并且 加入房间后才进行广播
8598
- */
8599
- st(this, Kt, async (u) => {
8600
- const { roomId: E } = this.options;
8601
- if (!E) return;
8602
- const { id: _, tracks: k = [] } = await this.getCaller();
8603
- if (k.length === 0) return;
8604
- const e = k.filter((n) => n.mediaType && u.includes(n.mediaType));
8605
- this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: E, user: { id: _, tracks: e } } });
8606
- });
8607
8737
  /**
8608
8738
  * 加入房间
8609
8739
  * @param roomOptions RoomOptions
8610
8740
  * @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' , newPublishAutoSubscribe: true })
8611
8741
  * @returns Promise<boolean>
8612
8742
  */
8613
- Z(this, "joinRoom", async (u) => (this.setOptions(u), await this.createWs(), new Promise((E, _) => {
8743
+ Z(this, "joinRoom", async (u) => (this.setOptions(u), await Q(this, Nt).call(this), new Promise((E, _) => {
8614
8744
  this.clearUsers();
8615
8745
  let k = "";
8616
8746
  const e = async () => {
@@ -8629,7 +8759,7 @@ class RoomCalls extends RoomPeer {
8629
8759
  if (q !== 200) return _(P);
8630
8760
  const { roomId: V = "", roomUsers: J = [] } = j;
8631
8761
  if (V !== O) return _("加入的房间不匹配");
8632
- this.isInRoom = !0, this.createSession(), await this.updateUsers(J), e();
8762
+ this.isInRoom = !0, Q(this, At).call(this), await this.updateUsers(J), e();
8633
8763
  });
8634
8764
  } catch (O) {
8635
8765
  this.taskQueue.setCondition("joinRoom", !0), _(`加入房间失败: ${O.message || O || "服务器繁忙"}`);
@@ -8645,7 +8775,7 @@ class RoomCalls extends RoomPeer {
8645
8775
  Z(this, "quitRoom", () => new Promise(async (u) => {
8646
8776
  const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
8647
8777
  try {
8648
- this.isInRoom = !1, this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.setRoomState("ready");
8778
+ this.isInRoom = !1, this.stopPublish(), this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.setRoomState("ready");
8649
8779
  } catch {
8650
8780
  }
8651
8781
  await new Promise((e) => setTimeout(() => e(!0), 300)), this.taskQueue.setCondition("closeTrack", !0), this.cwsIns.sendMessage({ event: "quitRoom", data: k }), u(!0);
@@ -8658,7 +8788,7 @@ class RoomCalls extends RoomPeer {
8658
8788
  Z(this, "quitRoomEx", () => new Promise(async (u) => {
8659
8789
  const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
8660
8790
  try {
8661
- this.isInRoom = !1, this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), await this.replaceSenderStream([], !1);
8791
+ this.isInRoom = !1, this.stopPublish(), this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), await this.replaceSenderStream([], !1);
8662
8792
  } catch {
8663
8793
  }
8664
8794
  await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoomEx", data: k }), u(!0);
@@ -8691,23 +8821,25 @@ class RoomCalls extends RoomPeer {
8691
8821
  Z(this, "publish", (u) => new Promise(async (E, _) => {
8692
8822
  const k = async () => {
8693
8823
  try {
8694
- await this.replaceSenderStream(u, !1), await this.createTrack(u);
8824
+ await this.replaceSenderStream(u, !1);
8695
8825
  const e = await this.getCaller();
8696
8826
  try {
8697
8827
  await this.setLocalStream(u, !0);
8698
8828
  } catch {
8699
8829
  }
8700
8830
  const n = [];
8701
- for (const D of u)
8702
- this.getUserStream(e.id, D).getTracks().length === 0 && n.push(D);
8703
- const O = this.getSenderTracks(u), $ = [...e.tracks, ...O];
8704
- await this.updateUsertracks(e.id, $, !0);
8705
- const N = await this.getCallAction($);
8706
- await Q(this, It).call(this, N), await this.replaceSenderStream(u, !0), Q(this, Kt).call(this, u), n.length !== 0 && await this.inactiveTracks(n, !1);
8831
+ for (const q of u)
8832
+ this.getUserStream(e.id, q).getTracks().length === 0 && n.push(q);
8833
+ const O = u.filter((q) => !n.includes(q) || ["microphoneCamera_audio", "microphoneCamera_video"].includes(q));
8834
+ await Q(this, qt).call(this, O);
8835
+ const $ = this.getSenderTracks(O), N = [...e.tracks, ...$];
8836
+ await this.updateUsertracks(e.id, N, !0);
8837
+ const D = await this.getCallAction(N);
8838
+ await Q(this, It).call(this, D), await this.replaceSenderStream(u, !0), Q(this, Vt).call(this, u), n.length !== 0 && await this.inactiveTracks(n, !1);
8707
8839
  {
8708
8840
  await this.emitNotifyUpdateUsers();
8709
- const D = await this.getCaller();
8710
- E(D);
8841
+ const q = await this.getCaller();
8842
+ E(q);
8711
8843
  }
8712
8844
  } catch (e) {
8713
8845
  _(`publish is error: ${e.message || e}`);
@@ -8805,6 +8937,17 @@ class RoomCalls extends RoomPeer {
8805
8937
  };
8806
8938
  this.taskQueue.addTask(e, ["createWs", "createSession", "ice", "createTrack", "closeTrack"], { describe: "subscribe" });
8807
8939
  }));
8940
+ /**
8941
+ * 协商流
8942
+ */
8943
+ Z(this, "renegotiate", () => new Promise(async (u, E) => {
8944
+ await this.createAnswer(), await this.cwsIns.sendMessage({ event: "renegotiate", data: { sdp: this.getSdp() } }).then((_) => {
8945
+ if (_.code !== 200) return E("协商流错误");
8946
+ u(!0);
8947
+ }).catch((_) => {
8948
+ console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe:error", _), E(`协商流错误: ${_.message || _}`);
8949
+ });
8950
+ }));
8808
8951
  /**
8809
8952
  * 停止订阅流
8810
8953
  * @param trackNames string[] = []
@@ -8876,118 +9019,15 @@ class RoomCalls extends RoomPeer {
8876
9019
  E(_);
8877
9020
  });
8878
9021
  }));
8879
- /**
8880
- * 更新自己通话状态
8881
- */
8882
- st(this, It, async (u) => new Promise(async (E, _) => {
8883
- const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: u } };
8884
- await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
8885
- const { code: $ = 0 } = O;
8886
- if ($ !== 200) return _(O);
8887
- await this.updateUserCallAction(e, u), E(u);
8888
- }).catch((O) => _(O));
8889
- }));
8890
- /**
8891
- * 协商流
8892
- */
8893
- Z(this, "renegotiate", () => new Promise(async (u, E) => {
8894
- await this.createAnswer(), await this.cwsIns.sendMessage({ event: "renegotiate", data: { sdp: this.getSdp() } }).then((_) => {
8895
- if (_.code !== 200) return E("协商流错误");
8896
- u(!0);
8897
- }).catch((_) => {
8898
- console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe:error", _), E(`协商流错误: ${_.message || _}`);
8899
- });
8900
- }));
8901
- /**
8902
- * 创建连接
8903
- */
8904
- Z(this, "createWs", () => new Promise(async (u, E) => {
8905
- try {
8906
- if (["connecting", "connected"].includes(this.cwsIns.state)) return u(!0);
8907
- this.taskQueue.setCondition("createWs", !1), this.cwsIns.clearEvents(), this.initPeer();
8908
- const { appid: _ } = this.options, { userId: k = "", sdkToken: e, roomId: n } = this.options;
8909
- if (!_) return E("quickvo: createWs is error. You must first use QuickVO.setOptions to set the appid.");
8910
- const O = {
8911
- a: e,
8912
- b: k,
8913
- c: _,
8914
- r: n,
8915
- v: this.sdk_service_version
8916
- };
8917
- this.isEarly && (O.i = ht()), this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createWs", O);
8918
- const $ = btoa(encodeURI(JSON.stringify(O)));
8919
- await this.cwsIns.connect($), this.taskQueue.setCondition("createWs", !0), u(!0);
8920
- } catch (_) {
8921
- console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createWs is error.", _), E(_);
8922
- }
8923
- }));
8924
- /**
8925
- * 创建cf会话
8926
- */
8927
- Z(this, "createSession", () => {
8928
- if (!["connecting", "connected"].includes(this.roomState))
8929
- return this.setRoomState("connecting"), new Promise((u) => {
8930
- const E = async () => {
8931
- try {
8932
- this.taskQueue.setCondition("createSession", !1), await this.addSenders(), await this.cwsIns.sendMessage({
8933
- event: "connectCF",
8934
- data: { sdp: this.getSdp() }
8935
- }).then(async (_) => {
8936
- const { code: k = 0, desc: e, data: n } = _;
8937
- if (k !== 200) throw new Error(e);
8938
- const { remoteSdp: O } = n;
8939
- this.taskQueue.setCondition("ice", !1), await this.setRemoteDescription({ type: "answer", sdp: O }), this.taskQueue.setCondition("createSession", !0), u(!0);
8940
- });
8941
- } catch (_) {
8942
- this.taskQueue.setCondition("createSession", !0), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo create session is error.", _);
8943
- }
8944
- };
8945
- this.taskQueue.addTask(E, ["createWs"], { key: "createSession", describe: "createSession" });
8946
- });
8947
- });
8948
- /**
8949
- * 创建媒体轨道
8950
- */
8951
- Z(this, "createTrack", async (u) => new Promise((E) => {
8952
- const _ = async () => {
8953
- try {
8954
- this.taskQueue.setCondition("createTrack", !1);
8955
- const k = await this.addSenders(u), e = this.getSenderTracks(k);
8956
- if (e.length === 0)
8957
- return this.taskQueue.setCondition("createTrack", !0), E(!0);
8958
- await this.cwsIns.sendMessage({
8959
- event: "publish",
8960
- data: { sdp: this.getSdp(), tracks: e, callAction: 0 }
8961
- }).then(async (n) => {
8962
- const { code: O = 0, desc: $, data: N } = n;
8963
- if (O !== 200)
8964
- throw this.options.debug && console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createTrack is error.", { mediaTypes: u }), new Error($);
8965
- const { remoteSdp: D } = N;
8966
- await this.setRemoteDescription({ type: "answer", sdp: D }), this.taskQueue.setCondition("createTrack", !0), E(!0);
8967
- });
8968
- } catch {
8969
- await this.removeSenders(u), this.taskQueue.setCondition("createTrack", !0), E(!0);
8970
- }
8971
- };
8972
- this.taskQueue.addTask(_, ["createWs", "createSession", "ice", "subscribe", "createTrack", "closeTrack"], { describe: "createTrack" });
8973
- }));
8974
- /**
8975
- * 预连接
8976
- * @param mediaTypes MediaType[]
8977
- * @example quickvo.earlyConnect(['microphoneCamera_audio', 'microphoneCamera_video'])
8978
- */
8979
- Z(this, "earlyConnect", (u = []) => {
8980
- this.isEarly = !0, this.createWs(), this.createSession(), u.length === 0 && (u = ["microphoneCamera_audio", "microphoneCamera_video"]), this.createTrack(u);
8981
- });
8982
9022
  }
8983
9023
  }
8984
- Kt = new WeakMap(), It = new WeakMap();
9024
+ Vt = new WeakMap(), It = new WeakMap(), Nt = new WeakMap(), At = new WeakMap(), qt = new WeakMap();
8985
9025
  class Room extends RoomCalls {
8986
9026
  constructor(I) {
8987
9027
  super(I);
8988
9028
  }
8989
9029
  }
8990
- var gt, Gt, Qt, Vt, Yt;
9030
+ var gt, Yt, Xt, te, ee;
8991
9031
  class QuickVO extends Room {
8992
9032
  constructor(u) {
8993
9033
  super(u);
@@ -8995,7 +9035,7 @@ class QuickVO extends Room {
8995
9035
  /**
8996
9036
  * 添加内部监听事件
8997
9037
  */
8998
- st(this, Gt, () => {
9038
+ st(this, Yt, () => {
8999
9039
  {
9000
9040
  const u = async (E) => {
9001
9041
  const { qualities: _ = [] } = E.data, [k] = _;
@@ -9024,21 +9064,21 @@ class QuickVO extends Room {
9024
9064
  }
9025
9065
  {
9026
9066
  const u = async (E) => {
9027
- const { user: _ } = E.data, { id: k, tracks: e = [] } = _;
9028
- await this.updateUserPermissions(k, 3);
9029
- const n = [];
9067
+ const { user: _ } = E.data, { id: k, tracks: e = [], callAction: n = 0 } = _;
9068
+ await this.updateUserCallAction(k, n), await this.updateUserPermissions(k, 3);
9069
+ const O = [];
9030
9070
  {
9031
- const { tracks: O } = await this.getUser(k);
9032
- for (const $ of e) {
9033
- const { mid: N, trackName: D } = $;
9034
- if (O.find((P) => P.mid === N && P.trackName === D)) continue;
9035
- n.push($);
9071
+ const { tracks: $ } = await this.getUser(k);
9072
+ for (const N of e) {
9073
+ const { mid: D, trackName: q } = N;
9074
+ if ($.find((j) => j.mid === D && j.trackName === q)) continue;
9075
+ O.push(N);
9036
9076
  }
9037
9077
  }
9038
- if (n.length !== 0)
9039
- if (await this.updateUsertracks(k, n, !0), this.options.newPublishAutoSubscribe) {
9040
- const O = this.getTrackNamesFormTracks(n);
9041
- await this.subscribe(O);
9078
+ if (O.length !== 0)
9079
+ if (await this.updateUsertracks(k, O, !0), this.options.newPublishAutoSubscribe) {
9080
+ const $ = this.getTrackNamesFormTracks(O);
9081
+ await this.subscribe($);
9042
9082
  } else
9043
9083
  await this.emitNotifyUpdateUsers();
9044
9084
  };
@@ -9067,23 +9107,29 @@ class QuickVO extends Room {
9067
9107
  }
9068
9108
  this.cwsIns.addNotify({ event: "onTokenExpired", callback: async (u) => this.destroy() }, !0), this.cwsIns.addNotify({ event: "destroyRoom", callback: this.destroy }, !0);
9069
9109
  });
9110
+ /**
9111
+ * 外部添加广播事件
9112
+ * @param notify Notify
9113
+ * @returns sn
9114
+ */
9115
+ Z(this, "addNotify", (u) => this.cwsIns.addNotify(u));
9070
9116
  /**
9071
9117
  * cwsIns 发送消息前
9072
9118
  */
9073
- st(this, Qt, () => {
9119
+ st(this, Xt, () => {
9074
9120
  });
9075
9121
  /**
9076
9122
  * 重连成功
9077
9123
  */
9078
- st(this, Vt, () => {
9124
+ st(this, te, () => {
9079
9125
  this.cwsIns.onReconnectSuccess = async () => {
9080
- this.syncRoomInfo();
9126
+ await this.syncRoomInfo();
9081
9127
  };
9082
9128
  });
9083
9129
  /**
9084
9130
  * 重连停止
9085
9131
  */
9086
- st(this, Yt, async () => {
9132
+ st(this, ee, async () => {
9087
9133
  });
9088
9134
  /**
9089
9135
  * 添加 FrameRequestCallback
@@ -9122,10 +9168,10 @@ class QuickVO extends Room {
9122
9168
  Z(this, "destroy", async () => {
9123
9169
  this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 销毁SDK"), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {}, desc: "sdk is destroy." }), await this.cwsIns.close();
9124
9170
  });
9125
- Q(this, Qt).call(this), Q(this, Vt).call(this), Q(this, Yt).call(this), Q(this, Gt).call(this);
9171
+ Q(this, Xt).call(this), Q(this, te).call(this), Q(this, ee).call(this), Q(this, Yt).call(this);
9126
9172
  }
9127
9173
  }
9128
- gt = new WeakMap(), Gt = new WeakMap(), Qt = new WeakMap(), Vt = new WeakMap(), Yt = new WeakMap();
9174
+ gt = new WeakMap(), Yt = new WeakMap(), Xt = new WeakMap(), te = new WeakMap(), ee = new WeakMap();
9129
9175
  export {
9130
9176
  QuickVO,
9131
9177
  ignoreEvent