quickvo-sdk-js 0.5.7 → 0.5.8

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/README.md CHANGED
@@ -279,10 +279,10 @@ quickvo.addNotify({
279
279
  * 设置本地流
280
280
  * @param mediaType MediaType
281
281
  * @param active 激活状态
282
- * @example quickvo.setLocalStream('microphoneCamera_audio', false)
282
+ * @example quickvo.setLocalStream(['microphoneCamera_audio'], false)
283
283
  * @returns Promise<Streams>
284
284
  */
285
- quickvo.setLocalStream('microphoneCamera_audio', true).then((streams) => {
285
+ quickvo.setLocalStream(['microphoneCamera_audio'], true).then((streams) => {
286
286
  // 因考虑到易用性(与 onLocalStream 保持一致) 这里会返回所有本地流对象
287
287
  const stream = streams['microphoneCamera_audio']
288
288
  // 拿到所需要的 stream 然后进行渲染 (这里以原生js使用方式作为参考)
@@ -409,6 +409,20 @@ quickvo.quitRoom()
409
409
 
410
410
  ### 版本迭代说明
411
411
 
412
+ - 版本:0.5.8 (2025-05-30)
413
+
414
+ ```
415
+ 优化SDK内部连接建立机制,优化媒体设备切换逻辑和错误,新增 QuickVO.changeScreenSharing()方法 (用于切换共享屏幕流)
416
+
417
+ ```
418
+
419
+ - 版本:0.4.0 (2025-05-24)
420
+
421
+ ```
422
+ 新版本支持 预连接 模式,使用预连接可以极大的缩短进入房间后发布流的时间,更快的接通会话。详情查阅 预连接专栏。
423
+
424
+ ```
425
+
412
426
  - 版本:0.2.3 (2025-03-28)
413
427
 
414
428
  ```
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ var te = (a) => {
4
4
  };
5
5
  var ne = (a, I, u) => I in a ? ie(a, I, { enumerable: !0, configurable: !0, writable: !0, value: u }) : a[I] = u;
6
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)), at = (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);
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);
8
8
  const L = (a, I = []) => {
9
9
  const u = { ...a }, E = Object.keys(u);
10
10
  for (const _ of E)
@@ -6134,7 +6134,7 @@ var Deflate_1$1 = Deflate$1, deflate_2 = deflate$1, deflateRaw_1$1 = deflateRaw$
6134
6134
  };
6135
6135
  const BAD$1 = 16209, TYPE$1 = 16191;
6136
6136
  var inffast = function a(I, u) {
6137
- let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, lt, it, st, ct, ot;
6137
+ let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, lt, it, at, ct, ot;
6138
6138
  const rt = I.state;
6139
6139
  E = I.next_in, ct = I.input, _ = E + (I.avail_in - 5), k = I.next_out, ot = I.output, e = k - (u - I.avail_out), n = k + (I.avail_out - 257), O = rt.dmax, $ = rt.wsize, N = rt.whave, D = rt.wnext, q = rt.window, P = rt.hold, j = rt.bits, V = rt.lencode, J = rt.distcode, z = (1 << rt.lenbits) - 1, Y = (1 << rt.distbits) - 1;
6140
6140
  t:
@@ -6158,13 +6158,13 @@ var inffast = function a(I, u) {
6158
6158
  I.msg = "invalid distance too far back", rt.mode = BAD$1;
6159
6159
  break t;
6160
6160
  }
6161
- if (it = 0, st = q, D === 0) {
6161
+ if (it = 0, at = q, D === 0) {
6162
6162
  if (it += $ - tt, tt < nt) {
6163
6163
  nt -= tt;
6164
6164
  do
6165
6165
  ot[k++] = q[it++];
6166
6166
  while (--tt);
6167
- it = k - lt, st = ot;
6167
+ it = k - lt, at = ot;
6168
6168
  }
6169
6169
  } else if (D < tt) {
6170
6170
  if (it += $ + D - tt, tt -= D, tt < nt) {
@@ -6177,7 +6177,7 @@ var inffast = function a(I, u) {
6177
6177
  do
6178
6178
  ot[k++] = q[it++];
6179
6179
  while (--tt);
6180
- it = k - lt, st = ot;
6180
+ it = k - lt, at = ot;
6181
6181
  }
6182
6182
  }
6183
6183
  } else if (it += D - tt, tt < nt) {
@@ -6185,11 +6185,11 @@ var inffast = function a(I, u) {
6185
6185
  do
6186
6186
  ot[k++] = q[it++];
6187
6187
  while (--tt);
6188
- it = k - lt, st = ot;
6188
+ it = k - lt, at = ot;
6189
6189
  }
6190
6190
  for (; nt > 2; )
6191
- ot[k++] = st[it++], ot[k++] = st[it++], ot[k++] = st[it++], nt -= 3;
6192
- nt && (ot[k++] = st[it++], nt > 1 && (ot[k++] = st[it++]));
6191
+ ot[k++] = at[it++], ot[k++] = at[it++], ot[k++] = at[it++], nt -= 3;
6192
+ nt && (ot[k++] = at[it++], nt > 1 && (ot[k++] = at[it++]));
6193
6193
  } else {
6194
6194
  it = k - lt;
6195
6195
  do
@@ -6357,7 +6357,7 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
6357
6357
  64
6358
6358
  ]), inflate_table = (a, I, u, E, _, k, e, n) => {
6359
6359
  const O = n.bits;
6360
- 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, st = null, ct;
6360
+ 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
6361
  const ot = new Uint16Array(MAXBITS + 1), rt = new Uint16Array(MAXBITS + 1);
6362
6362
  let Ot = null, Xt, Nt, At;
6363
6363
  for ($ = 0; $ <= MAXBITS; $++)
@@ -6379,10 +6379,10 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
6379
6379
  rt[$ + 1] = rt[$] + ot[$];
6380
6380
  for (N = 0; N < E; N++)
6381
6381
  I[u + N] !== 0 && (e[rt[I[u + N]]++] = N);
6382
- if (a === CODES$1 ? (st = Ot = e, ct = 20) : a === LENS$1 ? (st = lbase, Ot = lext, ct = 257) : (st = 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)
6382
+ 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
6383
  return 1;
6384
6384
  for (; ; ) {
6385
- Xt = $ - V, e[N] + 1 < ct ? (Nt = 0, At = e[N]) : e[N] >= ct ? (Nt = Ot[e[N] - ct], At = st[e[N] - ct]) : (Nt = 96, At = 0), et = 1 << $ - V, tt = 1 << j, D = tt;
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;
6386
6386
  do
6387
6387
  tt -= et, _[it + (Y >> V) + tt] = Xt << 24 | Nt << 16 | At | 0;
6388
6388
  while (tt !== 0);
@@ -6472,7 +6472,7 @@ const fixedtables = (a) => {
6472
6472
  const k = a.state;
6473
6473
  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(u - k.wsize, u), 0), k.wnext = 0, k.whave = k.wsize) : (_ = k.wsize - k.wnext, _ > E && (_ = E), k.window.set(I.subarray(u - E, u - E + _), k.wnext), E -= _, E ? (k.window.set(I.subarray(u - E, u), 0), k.wnext = E, k.whave = k.wsize) : (k.wnext += _, k.wnext === k.wsize && (k.wnext = 0), k.whave < k.wsize && (k.whave += _))), 0;
6474
6474
  }, inflate$2 = (a, I) => {
6475
- let u, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, lt, it, st;
6475
+ let u, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, lt, it, at;
6476
6476
  const ct = new Uint8Array(4);
6477
6477
  let ot, rt;
6478
6478
  const Ot = (
@@ -6481,7 +6481,7 @@ const fixedtables = (a) => {
6481
6481
  );
6482
6482
  if (inflateStateCheck(a) || !a.output || !a.input && a.avail_in !== 0)
6483
6483
  return Z_STREAM_ERROR$1;
6484
- u = a.state, u.mode === TYPE && (u.mode = TYPEDO), e = a.next_out, _ = a.output, O = a.avail_out, k = a.next_in, E = a.input, n = a.avail_in, $ = u.hold, N = u.bits, D = n, q = O, st = Z_OK$1;
6484
+ u = a.state, u.mode === TYPE && (u.mode = TYPEDO), e = a.next_out, _ = a.output, O = a.avail_out, k = a.next_in, E = a.input, n = a.avail_in, $ = u.hold, N = u.bits, D = n, q = O, at = Z_OK$1;
6485
6485
  t:
6486
6486
  for (; ; )
6487
6487
  switch (u.mode) {
@@ -6705,7 +6705,7 @@ const fixedtables = (a) => {
6705
6705
  }
6706
6706
  for (; u.have < 19; )
6707
6707
  u.lens[Ot[u.have++]] = 0;
6708
- if (u.lencode = u.lendyn, u.lenbits = 7, ot = { bits: u.lenbits }, st = inftrees(CODES, u.lens, 0, 19, u.lencode, 0, u.work, ot), u.lenbits = ot.bits, st) {
6708
+ if (u.lencode = u.lendyn, u.lenbits = 7, ot = { bits: u.lenbits }, at = inftrees(CODES, u.lens, 0, 19, u.lencode, 0, u.work, ot), u.lenbits = ot.bits, at) {
6709
6709
  a.msg = "invalid code lengths set", u.mode = BAD;
6710
6710
  break;
6711
6711
  }
@@ -6761,11 +6761,11 @@ const fixedtables = (a) => {
6761
6761
  a.msg = "invalid code -- missing end-of-block", u.mode = BAD;
6762
6762
  break;
6763
6763
  }
6764
- if (u.lenbits = 9, ot = { bits: u.lenbits }, st = inftrees(LENS, u.lens, 0, u.nlen, u.lencode, 0, u.work, ot), u.lenbits = ot.bits, st) {
6764
+ if (u.lenbits = 9, ot = { bits: u.lenbits }, at = inftrees(LENS, u.lens, 0, u.nlen, u.lencode, 0, u.work, ot), u.lenbits = ot.bits, at) {
6765
6765
  a.msg = "invalid literal/lengths set", u.mode = BAD;
6766
6766
  break;
6767
6767
  }
6768
- if (u.distbits = 6, u.distcode = u.distdyn, ot = { bits: u.distbits }, st = inftrees(DISTS, u.lens, u.nlen, u.ndist, u.distcode, 0, u.work, ot), u.distbits = ot.bits, st) {
6768
+ if (u.distbits = 6, u.distcode = u.distdyn, ot = { bits: u.distbits }, at = inftrees(DISTS, u.lens, u.nlen, u.ndist, u.distcode, 0, u.work, ot), u.distbits = ot.bits, at) {
6769
6769
  a.msg = "invalid distances set", u.mode = BAD;
6770
6770
  break;
6771
6771
  }
@@ -6907,10 +6907,10 @@ const fixedtables = (a) => {
6907
6907
  u.mode = DONE;
6908
6908
  /* falls through */
6909
6909
  case DONE:
6910
- st = Z_STREAM_END$1;
6910
+ at = Z_STREAM_END$1;
6911
6911
  break t;
6912
6912
  case BAD:
6913
- st = Z_DATA_ERROR$1;
6913
+ at = Z_DATA_ERROR$1;
6914
6914
  break t;
6915
6915
  case MEM:
6916
6916
  return Z_MEM_ERROR$1;
@@ -6920,7 +6920,7 @@ const fixedtables = (a) => {
6920
6920
  return Z_STREAM_ERROR$1;
6921
6921
  }
6922
6922
  return a.next_out = e, a.avail_out = O, a.next_in = k, a.avail_in = n, u.hold = $, u.bits = N, (u.wsize || q !== a.avail_out && u.mode < BAD && (u.mode < CHECK || I !== Z_FINISH$1)) && updatewindow(a, a.output, a.next_out, q - a.avail_out), D -= a.avail_in, q -= a.avail_out, a.total_in += D, a.total_out += q, u.total += q, u.wrap & 4 && q && (a.adler = u.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/
6923
- u.flags ? crc32_1(u.check, _, q, a.next_out - q) : adler32_1(u.check, _, q, a.next_out - q)), a.data_type = u.bits + (u.last ? 64 : 0) + (u.mode === TYPE ? 128 : 0) + (u.mode === LEN_ || u.mode === COPY_ ? 256 : 0), (D === 0 && q === 0 || I === Z_FINISH$1) && st === Z_OK$1 && (st = Z_BUF_ERROR), st;
6923
+ u.flags ? crc32_1(u.check, _, q, a.next_out - q) : adler32_1(u.check, _, q, a.next_out - q)), a.data_type = u.bits + (u.last ? 64 : 0) + (u.mode === TYPE ? 128 : 0) + (u.mode === LEN_ || u.mode === COPY_ ? 256 : 0), (D === 0 && q === 0 || I === Z_FINISH$1) && at === Z_OK$1 && (at = Z_BUF_ERROR), at;
6924
6924
  }, inflateEnd = (a) => {
6925
6925
  if (inflateStateCheck(a))
6926
6926
  return Z_STREAM_ERROR$1;
@@ -7158,8 +7158,8 @@ var vt, ut, Rt, yt, _t, qt, Dt, Ct, Ut, Et, Mt, Pt, Bt;
7158
7158
  class CallsWebSocket {
7159
7159
  // 状态
7160
7160
  constructor(I) {
7161
- at(this, vt);
7162
- at(this, ut, {
7161
+ st(this, vt);
7162
+ st(this, ut, {
7163
7163
  url: "wss://demo.putplay.cc/websocket",
7164
7164
  // 地址
7165
7165
  debug: !1,
@@ -7168,10 +7168,10 @@ class CallsWebSocket {
7168
7168
  // 最大重连次数
7169
7169
  timeout: 30 * 1e3
7170
7170
  });
7171
- at(this, Rt, "");
7171
+ st(this, Rt, "");
7172
7172
  // 缓存登录凭证
7173
- at(this, yt, {});
7174
- at(this, _t, {});
7173
+ st(this, yt, {});
7174
+ st(this, _t, {});
7175
7175
  Z(this, "state", "closed");
7176
7176
  // 外部 发送消息之前
7177
7177
  Z(this, "sendMessageBefore", async () => {
@@ -7183,26 +7183,26 @@ class CallsWebSocket {
7183
7183
  Z(this, "onReconnectStop", (I) => {
7184
7184
  });
7185
7185
  // 是否需要重连
7186
- at(this, qt, (I) => {
7186
+ st(this, qt, (I) => {
7187
7187
  let u = !0;
7188
7188
  const { code: E = 1e3, reason: _ = "" } = I;
7189
7189
  return E === 1e3 && (_ === "quit success!" || _ === "replace old connection!") && (u = !1), u;
7190
7190
  });
7191
7191
  // 重连成功
7192
- at(this, Dt, async (I) => {
7192
+ st(this, Dt, async (I) => {
7193
7193
  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
7194
  });
7195
7195
  // 重连停止
7196
- at(this, Ct, async (I) => {
7196
+ st(this, Ct, async (I) => {
7197
7197
  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
7198
  });
7199
7199
  // 自定义心跳规则
7200
- at(this, Ut, () => {
7200
+ st(this, Ut, () => {
7201
7201
  const I = { event: "heartbeat", sn: +`${F(1e5, 999999)}` };
7202
7202
  return com.quick.voice.proto.CommonReq.encode(I).finish();
7203
7203
  });
7204
7204
  // 更新日志
7205
- at(this, Et, (I, u = {}) => {
7205
+ st(this, Et, (I, u = {}) => {
7206
7206
  try {
7207
7207
  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
7208
  let N = {};
@@ -7230,7 +7230,7 @@ class CallsWebSocket {
7230
7230
  }
7231
7231
  });
7232
7232
  // 创建事件
7233
- at(this, Mt, (I, { resolve: u, reject: E }) => {
7233
+ st(this, Mt, (I, { resolve: u, reject: E }) => {
7234
7234
  const { sn: _ } = I, k = () => {
7235
7235
  const n = Q(this, yt)[_];
7236
7236
  clearTimeout(n.destructionTimer), delete Q(this, yt)[_];
@@ -7241,9 +7241,9 @@ class CallsWebSocket {
7241
7241
  Q(this, yt)[_] = { message: I, resolve: u, reject: E, destruction: k, destructionTimer: e };
7242
7242
  });
7243
7243
  // 获取事件
7244
- at(this, Pt, (I) => Q(this, yt)[I]);
7244
+ st(this, Pt, (I) => Q(this, yt)[I]);
7245
7245
  // 接收消息
7246
- at(this, Bt, async (I) => {
7246
+ st(this, Bt, async (I) => {
7247
7247
  const u = new Uint8Array(I), E = com.quick.voice.proto.CommonRsp.decode(u), { sn: _, event: k } = E, e = onMessageFormat(E);
7248
7248
  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
7249
  return this.emitNotify(k, L(e, ["code", "data", "desc"]));
@@ -7416,7 +7416,7 @@ class K {
7416
7416
  d = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
7417
7417
  var Lt;
7418
7418
  class RoomBase {
7419
- constructor() {
7419
+ constructor(I) {
7420
7420
  Z(this, "options", {
7421
7421
  appid: "",
7422
7422
  sdkToken: "",
@@ -7430,13 +7430,15 @@ class RoomBase {
7430
7430
  // 是否禁止通知
7431
7431
  Z(this, "isEarly", !1);
7432
7432
  // 是否提前建连
7433
+ Z(this, "isInRoom", !1);
7434
+ // 是否在房间内
7433
7435
  Z(this, "taskQueue", new K(["createWs", "createSession", "ice", "joinRoom", "createTrack", "subscribe", "closeTrack"]));
7434
7436
  // 条件队列
7435
7437
  Z(this, "roomState", "ready");
7436
7438
  // 房间状态
7437
7439
  Z(this, "createAt", Date.now());
7438
7440
  // 创建时间
7439
- Z(this, "cwsIns", new CallsWebSocket());
7441
+ Z(this, "cwsIns");
7440
7442
  // SDK通讯实例 // SDK通讯实例
7441
7443
  Z(this, "peerIns", new RTCPeerConnection({ bundlePolicy: "max-bundle" }));
7442
7444
  Z(this, "transceiverMap", /* @__PURE__ */ new Map());
@@ -7452,7 +7454,7 @@ class RoomBase {
7452
7454
  screenSharing_video: "",
7453
7455
  screenSharing_audio: ""
7454
7456
  });
7455
- at(this, Lt, () => {
7457
+ st(this, Lt, () => {
7456
7458
  this.taskQueue.setCondition("createWs", !0), this.taskQueue.setCondition("createSession", !1), this.taskQueue.setCondition("ice", !1);
7457
7459
  });
7458
7460
  /**
@@ -7477,12 +7479,6 @@ class RoomBase {
7477
7479
  const u = { ...this.options, ...I };
7478
7480
  this.options = u;
7479
7481
  });
7480
- /**
7481
- * 初始化通讯实例
7482
- */
7483
- Z(this, "initCwsCall", () => {
7484
- this.cwsIns = new CallsWebSocket({ ...this.options });
7485
- });
7486
7482
  /**
7487
7483
  * 获取媒体设备错误信息
7488
7484
  */
@@ -7551,32 +7547,32 @@ class RoomBase {
7551
7547
  * 处理为应用层数据
7552
7548
  */
7553
7549
  Z(this, "usersFilter", (I) => ft(I, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "permissions", "isPublished", "updateStreams"]).sort((_, k) => _.id.localeCompare(k.id, "en")));
7554
- Q(this, Lt).call(this);
7550
+ this.setOptions(I), this.cwsIns = new CallsWebSocket({ ...I }), Q(this, Lt).call(this);
7555
7551
  }
7556
7552
  }
7557
7553
  Lt = new WeakMap();
7558
7554
  var $t, kt, dt, bt, jt, Zt, Tt, Ft;
7559
7555
  class RoomMedias extends RoomBase {
7560
7556
  // 媒体流上下文
7561
- constructor() {
7562
- super();
7563
- at(this, $t, []);
7557
+ constructor(u) {
7558
+ super(u);
7559
+ st(this, $t, []);
7564
7560
  // 可用媒体设备列表
7565
- at(this, kt, /* @__PURE__ */ new Map());
7561
+ st(this, kt, /* @__PURE__ */ new Map());
7566
7562
  // 媒体流设备管理
7567
- at(this, dt, /* @__PURE__ */ new Map());
7563
+ st(this, dt, /* @__PURE__ */ new Map());
7568
7564
  // 媒体轨道参数管理
7569
- at(this, bt, /* @__PURE__ */ new Map());
7565
+ st(this, bt, /* @__PURE__ */ new Map());
7570
7566
  /**
7571
7567
  * 初始化媒体参数
7572
7568
  */
7573
- at(this, jt, () => {
7569
+ st(this, jt, () => {
7574
7570
  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", {});
7575
7571
  });
7576
7572
  /**
7577
7573
  * 初始化媒体设备类型
7578
7574
  */
7579
- at(this, Zt, () => {
7575
+ st(this, Zt, () => {
7580
7576
  Q(this, kt).set("audioinput", "default"), Q(this, kt).set("videoinput", "default"), Q(this, kt).set("audiooutput", "default");
7581
7577
  });
7582
7578
  /**
@@ -7778,7 +7774,7 @@ class RoomMedias extends RoomBase {
7778
7774
  /**
7779
7775
  * 获取媒体设备列表
7780
7776
  */
7781
- at(this, Tt, async () => !navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices ? (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 不支持 enumerateDevices"), []) : (await navigator.mediaDevices.enumerateDevices().then((u) => {
7777
+ st(this, Tt, async () => !navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices ? (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 不支持 enumerateDevices"), []) : (await navigator.mediaDevices.enumerateDevices().then((u) => {
7782
7778
  wt(this, $t, u);
7783
7779
  }).catch(function(u) {
7784
7780
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", u);
@@ -7786,7 +7782,7 @@ class RoomMedias extends RoomBase {
7786
7782
  /**
7787
7783
  * 媒体设备发生变化
7788
7784
  */
7789
- at(this, Ft, () => {
7785
+ st(this, Ft, () => {
7790
7786
  navigator.mediaDevices && (navigator.mediaDevices.ondevicechange = async () => {
7791
7787
  await Q(this, Tt).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
7792
7788
  }), Q(this, Tt).call(this);
@@ -7806,7 +7802,12 @@ class RoomMedias extends RoomBase {
7806
7802
  if (Q(this, kt).set(u, E), u === "audiooutput") {
7807
7803
  const _ = Q(this, bt).values();
7808
7804
  for (const k of _)
7809
- k.kind === "audio" && "setSinkId" in HTMLMediaElement.prototype && k.audioContext.setSinkId(E);
7805
+ if (k.kind === "audio" && "setSinkId" in HTMLMediaElement.prototype)
7806
+ try {
7807
+ k.audioContext.setSinkId(E);
7808
+ } catch (e) {
7809
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error.", e);
7810
+ }
7810
7811
  }
7811
7812
  });
7812
7813
  /**
@@ -7841,8 +7842,8 @@ class RoomMedias extends RoomBase {
7841
7842
  }
7842
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();
7843
7844
  class RoomUsers extends RoomMedias {
7844
- constructor() {
7845
- super();
7845
+ constructor(u) {
7846
+ super(u);
7846
7847
  /**
7847
7848
  * 获取最大音量用户
7848
7849
  */
@@ -8145,9 +8146,9 @@ const createMutedAudioStream = () => {
8145
8146
  };
8146
8147
  var St, Ht, xt, zt, Jt, Wt;
8147
8148
  class RoomPeer extends RoomUsers {
8148
- constructor() {
8149
- super();
8150
- at(this, St, /* @__PURE__ */ new Map());
8149
+ constructor(u) {
8150
+ super(u);
8151
+ st(this, St, /* @__PURE__ */ new Map());
8151
8152
  // 假媒体流 (创建轨道用)
8152
8153
  Z(this, "getPeerStatsTimer", 0);
8153
8154
  // 获取报告的定时器
@@ -8169,7 +8170,7 @@ class RoomPeer extends RoomUsers {
8169
8170
  this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this, zt).call(this), Q(this, Wt).call(this);
8170
8171
  });
8171
8172
  // 初始化假数据流
8172
- at(this, Ht, () => {
8173
+ st(this, Ht, () => {
8173
8174
  for (const u of mediaType_keys)
8174
8175
  switch (u) {
8175
8176
  case "microphoneCamera_audio":
@@ -8187,7 +8188,7 @@ class RoomPeer extends RoomUsers {
8187
8188
  }
8188
8189
  });
8189
8190
  // 获取假数据流
8190
- at(this, xt, (u) => Q(this, St).get(u));
8191
+ st(this, xt, (u) => Q(this, St).get(u));
8191
8192
  /**
8192
8193
  * 替换发射器媒体流
8193
8194
  */
@@ -8313,7 +8314,7 @@ class RoomPeer extends RoomUsers {
8313
8314
  /**
8314
8315
  * 监听webrtc ice通讯连接
8315
8316
  */
8316
- at(this, zt, () => {
8317
+ st(this, zt, () => {
8317
8318
  let u = 0;
8318
8319
  const E = () => {
8319
8320
  this.setRoomState("closed");
@@ -8462,7 +8463,7 @@ class RoomPeer extends RoomUsers {
8462
8463
  /**
8463
8464
  * 计算网络质量
8464
8465
  */
8465
- at(this, Jt, async () => {
8466
+ st(this, Jt, async () => {
8466
8467
  try {
8467
8468
  const u = await this.peerIns.getStats(), E = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"], k = [...u.values()].filter((nt) => E.includes(nt.type));
8468
8469
  let e = 0, n = 0, O = 0, $ = 0, N = 0, D = 0, q = [], P = [];
@@ -8472,23 +8473,23 @@ class RoomPeer extends RoomUsers {
8472
8473
  }
8473
8474
  this.reports = k;
8474
8475
  for (const nt of this.reports) {
8475
- const { bytesReceived: lt, bytesSent: it, packetsSent: st, packetsLost: ct, jitter: ot, roundTripTime: rt } = nt;
8476
- lt && (e = lt), it && (n = it), st && (N += st), ct && (D += ct), rt && q.push((rt * 100).toFixed(2)), ot && P.push(ot.toFixed(2));
8476
+ const { bytesReceived: lt, bytesSent: it, packetsSent: at, packetsLost: ct, jitter: ot, roundTripTime: rt } = nt;
8477
+ lt && (e = lt), it && (n = it), at && (N += at), ct && (D += ct), rt && q.push((rt * 100).toFixed(2)), ot && P.push(ot.toFixed(2));
8477
8478
  }
8478
8479
  P.sort().reverse(), q.sort().reverse();
8479
8480
  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 };
8480
8481
  this.peerNetwork = et;
8481
8482
  const tt = (nt, lt, it) => {
8482
- const st = Number(nt), ct = Number(lt), ot = Number(it);
8483
+ const at = Number(nt), ct = Number(lt), ot = Number(it);
8483
8484
  let rt = "0";
8484
- return st < 0.03 && ct < 100 && ot < 0.05 ? rt = "5" : st < 0.06 && ct < 160 && ot < 0.1 ? rt = "4" : st < 0.1 && ct < 250 && ot < 0.15 ? rt = "3" : st < 0.15 && ct < 400 && ot < 0.2 ? rt = "2" : rt = "1", Number(rt);
8485
+ return at < 0.03 && ct < 100 && ot < 0.05 ? rt = "5" : at < 0.06 && ct < 160 && ot < 0.1 ? rt = "4" : at < 0.1 && ct < 250 && ot < 0.15 ? rt = "3" : at < 0.15 && ct < 400 && ot < 0.2 ? rt = "2" : rt = "1", Number(rt);
8485
8486
  };
8486
8487
  {
8487
- const nt = tt(J, z, Y), lt = await this.getCaller(), { network: it } = lt, st = { egress: nt, ingress: nt }, ct = JSON.stringify(it) !== JSON.stringify(st);
8488
- if (await this.updateUserNetwork(this.options.userId, st), ct) {
8488
+ const nt = tt(J, z, Y), lt = await this.getCaller(), { network: it } = lt, at = { egress: nt, ingress: nt }, ct = JSON.stringify(it) !== JSON.stringify(at);
8489
+ if (await this.updateUserNetwork(this.options.userId, at), ct) {
8489
8490
  this.emitNotifyUpdateUsers();
8490
8491
  const { userId: ot, roomId: rt } = this.options;
8491
- this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...st, userId: ot, roomId: rt } }, !1);
8492
+ this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...at, userId: ot, roomId: rt } }, !1);
8492
8493
  }
8493
8494
  }
8494
8495
  } catch (u) {
@@ -8498,7 +8499,7 @@ class RoomPeer extends RoomUsers {
8498
8499
  /**
8499
8500
  * 获取连接的所有轨道分析数据
8500
8501
  */
8501
- at(this, Wt, () => {
8502
+ st(this, Wt, () => {
8502
8503
  const u = async () => {
8503
8504
  this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this, Jt).call(this);
8504
8505
  };
@@ -8514,8 +8515,8 @@ class RoomPeer extends RoomUsers {
8514
8515
  St = new WeakMap(), Ht = new WeakMap(), xt = new WeakMap(), zt = new WeakMap(), Jt = new WeakMap(), Wt = new WeakMap();
8515
8516
  var Kt, It;
8516
8517
  class RoomCalls extends RoomPeer {
8517
- constructor() {
8518
- super();
8518
+ constructor(u) {
8519
+ super(u);
8519
8520
  // sdk服务版本
8520
8521
  Z(this, "sdk_service_version", "1.0.5");
8521
8522
  /**
@@ -8523,10 +8524,12 @@ class RoomCalls extends RoomPeer {
8523
8524
  * @param mediaType MediaType
8524
8525
  * @param active 激活状态
8525
8526
  * @example quickvo.setLocalStream('microphoneCamera_audio', false)
8527
+ * @example quickvo.setLocalStream(['microphoneCamera_audio', 'microphoneCamera_video'], false)
8526
8528
  * @returns Promise<Streams>
8527
8529
  */
8528
8530
  Z(this, "setLocalStream", (u, E) => new Promise(async (_, k) => {
8529
8531
  try {
8532
+ typeof u == "string" && (u = [u]);
8530
8533
  const { userId: e } = this.options;
8531
8534
  for (const O of u)
8532
8535
  if (this.setLocalStreamActiveMap.set(O, E), E === !1) {
@@ -8569,7 +8572,7 @@ class RoomCalls extends RoomPeer {
8569
8572
  u === "audioinput" && await n("microphoneCamera_audio"), u === "videoinput" && await n("microphoneCamera_video");
8570
8573
  });
8571
8574
  /**
8572
- * 设置正在使用的媒体设备
8575
+ * 改变屏幕共享流
8573
8576
  * @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
8574
8577
  * @param deviceId 设备ID
8575
8578
  */
@@ -8593,7 +8596,7 @@ class RoomCalls extends RoomPeer {
8593
8596
  * 广播给房间其他人
8594
8597
  * 只有当自己建立了发射轨道 并且 加入房间后才进行广播
8595
8598
  */
8596
- at(this, Kt, async (u) => {
8599
+ st(this, Kt, async (u) => {
8597
8600
  const { roomId: E } = this.options;
8598
8601
  if (!E) return;
8599
8602
  const { id: _, tracks: k = [] } = await this.getCaller();
@@ -8626,7 +8629,7 @@ class RoomCalls extends RoomPeer {
8626
8629
  if (q !== 200) return _(P);
8627
8630
  const { roomId: V = "", roomUsers: J = [] } = j;
8628
8631
  if (V !== O) return _("加入的房间不匹配");
8629
- this.createSession(), await this.updateUsers(J), e();
8632
+ this.isInRoom = !0, this.createSession(), await this.updateUsers(J), e();
8630
8633
  });
8631
8634
  } catch (O) {
8632
8635
  this.taskQueue.setCondition("joinRoom", !0), _(`加入房间失败: ${O.message || O || "服务器繁忙"}`);
@@ -8642,10 +8645,10 @@ class RoomCalls extends RoomPeer {
8642
8645
  Z(this, "quitRoom", () => new Promise(async (u) => {
8643
8646
  const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
8644
8647
  try {
8645
- this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.setRoomState("ready");
8648
+ this.isInRoom = !1, this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.setRoomState("ready");
8646
8649
  } catch {
8647
8650
  }
8648
- await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoom", data: k }), u(!0);
8651
+ await new Promise((e) => setTimeout(() => e(!0), 300)), this.taskQueue.setCondition("closeTrack", !0), this.cwsIns.sendMessage({ event: "quitRoom", data: k }), u(!0);
8649
8652
  }));
8650
8653
  /**
8651
8654
  * 退出房间 不断开连接
@@ -8655,7 +8658,7 @@ class RoomCalls extends RoomPeer {
8655
8658
  Z(this, "quitRoomEx", () => new Promise(async (u) => {
8656
8659
  const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
8657
8660
  try {
8658
- this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), await this.replaceSenderStream([], !1);
8661
+ this.isInRoom = !1, this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), await this.replaceSenderStream([], !1);
8659
8662
  } catch {
8660
8663
  }
8661
8664
  await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoomEx", data: k }), u(!0);
@@ -8876,7 +8879,7 @@ class RoomCalls extends RoomPeer {
8876
8879
  /**
8877
8880
  * 更新自己通话状态
8878
8881
  */
8879
- at(this, It, async (u) => new Promise(async (E, _) => {
8882
+ st(this, It, async (u) => new Promise(async (E, _) => {
8880
8883
  const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: u } };
8881
8884
  await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
8882
8885
  const { code: $ = 0 } = O;
@@ -8902,9 +8905,8 @@ class RoomCalls extends RoomPeer {
8902
8905
  try {
8903
8906
  if (["connecting", "connected"].includes(this.cwsIns.state)) return u(!0);
8904
8907
  this.taskQueue.setCondition("createWs", !1), this.cwsIns.clearEvents(), this.initPeer();
8905
- const { appid: _ } = this.options, { userId: k, sdkToken: e, roomId: n } = this.options;
8908
+ const { appid: _ } = this.options, { userId: k = "", sdkToken: e, roomId: n } = this.options;
8906
8909
  if (!_) return E("quickvo: createWs is error. You must first use QuickVO.setOptions to set the appid.");
8907
- if (!k) return E("quickvo: createWs is error. You must first use QuickVO.setOptions to set the userId.");
8908
8910
  const O = {
8909
8911
  a: e,
8910
8912
  b: k,
@@ -8970,29 +8972,30 @@ class RoomCalls extends RoomPeer {
8970
8972
  this.taskQueue.addTask(_, ["createWs", "createSession", "ice", "subscribe", "createTrack", "closeTrack"], { describe: "createTrack" });
8971
8973
  }));
8972
8974
  /**
8973
- * 提前建连
8975
+ * 预连接
8976
+ * @param mediaTypes MediaType[]
8977
+ * @example quickvo.earlyConnect(['microphoneCamera_audio', 'microphoneCamera_video'])
8974
8978
  */
8975
8979
  Z(this, "earlyConnect", (u = []) => {
8976
8980
  this.isEarly = !0, this.createWs(), this.createSession(), u.length === 0 && (u = ["microphoneCamera_audio", "microphoneCamera_video"]), this.createTrack(u);
8977
8981
  });
8978
- this.setRoomState("ready");
8979
8982
  }
8980
8983
  }
8981
8984
  Kt = new WeakMap(), It = new WeakMap();
8982
8985
  class Room extends RoomCalls {
8983
- constructor() {
8984
- super();
8986
+ constructor(I) {
8987
+ super(I);
8985
8988
  }
8986
8989
  }
8987
8990
  var gt, Gt, Qt, Vt, Yt;
8988
8991
  class QuickVO extends Room {
8989
8992
  constructor(u) {
8990
- super();
8991
- at(this, gt, /* @__PURE__ */ new Map());
8993
+ super(u);
8994
+ st(this, gt, /* @__PURE__ */ new Map());
8992
8995
  /**
8993
8996
  * 添加内部监听事件
8994
8997
  */
8995
- at(this, Gt, () => {
8998
+ st(this, Gt, () => {
8996
8999
  {
8997
9000
  const u = async (E) => {
8998
9001
  const { qualities: _ = [] } = E.data, [k] = _;
@@ -9067,14 +9070,12 @@ class QuickVO extends Room {
9067
9070
  /**
9068
9071
  * cwsIns 发送消息前
9069
9072
  */
9070
- at(this, Qt, () => {
9071
- this.cwsIns.sendMessageBefore = async () => {
9072
- };
9073
+ st(this, Qt, () => {
9073
9074
  });
9074
9075
  /**
9075
9076
  * 重连成功
9076
9077
  */
9077
- at(this, Vt, () => {
9078
+ st(this, Vt, () => {
9078
9079
  this.cwsIns.onReconnectSuccess = async () => {
9079
9080
  this.syncRoomInfo();
9080
9081
  };
@@ -9082,7 +9083,7 @@ class QuickVO extends Room {
9082
9083
  /**
9083
9084
  * 重连停止
9084
9085
  */
9085
- at(this, Yt, async () => {
9086
+ st(this, Yt, async () => {
9086
9087
  });
9087
9088
  /**
9088
9089
  * 添加 FrameRequestCallback
@@ -9121,7 +9122,7 @@ class QuickVO extends Room {
9121
9122
  Z(this, "destroy", async () => {
9122
9123
  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();
9123
9124
  });
9124
- this.setOptions(u), this.initCwsCall(), Q(this, Qt).call(this), Q(this, Vt).call(this), Q(this, Yt).call(this), Q(this, Gt).call(this);
9125
+ Q(this, Qt).call(this), Q(this, Vt).call(this), Q(this, Yt).call(this), Q(this, Gt).call(this);
9125
9126
  }
9126
9127
  }
9127
9128
  gt = new WeakMap(), Gt = new WeakMap(), Qt = new WeakMap(), Vt = new WeakMap(), Yt = new WeakMap();