quickvo-sdk-js 0.5.6 → 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/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
  /**
@@ -7697,7 +7693,6 @@ class RoomMedias extends RoomBase {
7697
7693
  * 初始化本地流
7698
7694
  */
7699
7695
  Z(this, "initLocalStream", async (u) => {
7700
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: initLocalStream", u);
7701
7696
  const { userId: E } = this.options;
7702
7697
  switch (u) {
7703
7698
  // 麦克风
@@ -7779,7 +7774,7 @@ class RoomMedias extends RoomBase {
7779
7774
  /**
7780
7775
  * 获取媒体设备列表
7781
7776
  */
7782
- 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) => {
7783
7778
  wt(this, $t, u);
7784
7779
  }).catch(function(u) {
7785
7780
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", u);
@@ -7787,7 +7782,7 @@ class RoomMedias extends RoomBase {
7787
7782
  /**
7788
7783
  * 媒体设备发生变化
7789
7784
  */
7790
- at(this, Ft, () => {
7785
+ st(this, Ft, () => {
7791
7786
  navigator.mediaDevices && (navigator.mediaDevices.ondevicechange = async () => {
7792
7787
  await Q(this, Tt).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
7793
7788
  }), Q(this, Tt).call(this);
@@ -7807,7 +7802,12 @@ class RoomMedias extends RoomBase {
7807
7802
  if (Q(this, kt).set(u, E), u === "audiooutput") {
7808
7803
  const _ = Q(this, bt).values();
7809
7804
  for (const k of _)
7810
- 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
+ }
7811
7811
  }
7812
7812
  });
7813
7813
  /**
@@ -7842,8 +7842,8 @@ class RoomMedias extends RoomBase {
7842
7842
  }
7843
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();
7844
7844
  class RoomUsers extends RoomMedias {
7845
- constructor() {
7846
- super();
7845
+ constructor(u) {
7846
+ super(u);
7847
7847
  /**
7848
7848
  * 获取最大音量用户
7849
7849
  */
@@ -8146,9 +8146,9 @@ const createMutedAudioStream = () => {
8146
8146
  };
8147
8147
  var St, Ht, xt, zt, Jt, Wt;
8148
8148
  class RoomPeer extends RoomUsers {
8149
- constructor() {
8150
- super();
8151
- at(this, St, /* @__PURE__ */ new Map());
8149
+ constructor(u) {
8150
+ super(u);
8151
+ st(this, St, /* @__PURE__ */ new Map());
8152
8152
  // 假媒体流 (创建轨道用)
8153
8153
  Z(this, "getPeerStatsTimer", 0);
8154
8154
  // 获取报告的定时器
@@ -8170,7 +8170,7 @@ class RoomPeer extends RoomUsers {
8170
8170
  this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this, zt).call(this), Q(this, Wt).call(this);
8171
8171
  });
8172
8172
  // 初始化假数据流
8173
- at(this, Ht, () => {
8173
+ st(this, Ht, () => {
8174
8174
  for (const u of mediaType_keys)
8175
8175
  switch (u) {
8176
8176
  case "microphoneCamera_audio":
@@ -8188,7 +8188,7 @@ class RoomPeer extends RoomUsers {
8188
8188
  }
8189
8189
  });
8190
8190
  // 获取假数据流
8191
- at(this, xt, (u) => Q(this, St).get(u));
8191
+ st(this, xt, (u) => Q(this, St).get(u));
8192
8192
  /**
8193
8193
  * 替换发射器媒体流
8194
8194
  */
@@ -8314,7 +8314,7 @@ class RoomPeer extends RoomUsers {
8314
8314
  /**
8315
8315
  * 监听webrtc ice通讯连接
8316
8316
  */
8317
- at(this, zt, () => {
8317
+ st(this, zt, () => {
8318
8318
  let u = 0;
8319
8319
  const E = () => {
8320
8320
  this.setRoomState("closed");
@@ -8463,7 +8463,7 @@ class RoomPeer extends RoomUsers {
8463
8463
  /**
8464
8464
  * 计算网络质量
8465
8465
  */
8466
- at(this, Jt, async () => {
8466
+ st(this, Jt, async () => {
8467
8467
  try {
8468
8468
  const u = await this.peerIns.getStats(), E = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"], k = [...u.values()].filter((nt) => E.includes(nt.type));
8469
8469
  let e = 0, n = 0, O = 0, $ = 0, N = 0, D = 0, q = [], P = [];
@@ -8473,23 +8473,23 @@ class RoomPeer extends RoomUsers {
8473
8473
  }
8474
8474
  this.reports = k;
8475
8475
  for (const nt of this.reports) {
8476
- const { bytesReceived: lt, bytesSent: it, packetsSent: st, packetsLost: ct, jitter: ot, roundTripTime: rt } = nt;
8477
- 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));
8478
8478
  }
8479
8479
  P.sort().reverse(), q.sort().reverse();
8480
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 };
8481
8481
  this.peerNetwork = et;
8482
8482
  const tt = (nt, lt, it) => {
8483
- const st = Number(nt), ct = Number(lt), ot = Number(it);
8483
+ const at = Number(nt), ct = Number(lt), ot = Number(it);
8484
8484
  let rt = "0";
8485
- 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);
8486
8486
  };
8487
8487
  {
8488
- 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);
8489
- 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) {
8490
8490
  this.emitNotifyUpdateUsers();
8491
8491
  const { userId: ot, roomId: rt } = this.options;
8492
- 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);
8493
8493
  }
8494
8494
  }
8495
8495
  } catch (u) {
@@ -8499,7 +8499,7 @@ class RoomPeer extends RoomUsers {
8499
8499
  /**
8500
8500
  * 获取连接的所有轨道分析数据
8501
8501
  */
8502
- at(this, Wt, () => {
8502
+ st(this, Wt, () => {
8503
8503
  const u = async () => {
8504
8504
  this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this, Jt).call(this);
8505
8505
  };
@@ -8515,8 +8515,8 @@ class RoomPeer extends RoomUsers {
8515
8515
  St = new WeakMap(), Ht = new WeakMap(), xt = new WeakMap(), zt = new WeakMap(), Jt = new WeakMap(), Wt = new WeakMap();
8516
8516
  var Kt, It;
8517
8517
  class RoomCalls extends RoomPeer {
8518
- constructor() {
8519
- super();
8518
+ constructor(u) {
8519
+ super(u);
8520
8520
  // sdk服务版本
8521
8521
  Z(this, "sdk_service_version", "1.0.5");
8522
8522
  /**
@@ -8524,10 +8524,12 @@ class RoomCalls extends RoomPeer {
8524
8524
  * @param mediaType MediaType
8525
8525
  * @param active 激活状态
8526
8526
  * @example quickvo.setLocalStream('microphoneCamera_audio', false)
8527
+ * @example quickvo.setLocalStream(['microphoneCamera_audio', 'microphoneCamera_video'], false)
8527
8528
  * @returns Promise<Streams>
8528
8529
  */
8529
8530
  Z(this, "setLocalStream", (u, E) => new Promise(async (_, k) => {
8530
8531
  try {
8532
+ typeof u == "string" && (u = [u]);
8531
8533
  const { userId: e } = this.options;
8532
8534
  for (const O of u)
8533
8535
  if (this.setLocalStreamActiveMap.set(O, E), E === !1) {
@@ -8569,6 +8571,21 @@ class RoomCalls extends RoomPeer {
8569
8571
  };
8570
8572
  u === "audioinput" && await n("microphoneCamera_audio"), u === "videoinput" && await n("microphoneCamera_video");
8571
8573
  });
8574
+ /**
8575
+ * 改变屏幕共享流
8576
+ * @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
8577
+ * @param deviceId 设备ID
8578
+ */
8579
+ Z(this, "changeScreenSharing", async (u) => {
8580
+ const E = await this.getCaller(), { tracks: _ = [], callActionMap: k } = E;
8581
+ try {
8582
+ await this.setLocalStream(u, !0), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: 123");
8583
+ for (const e of u)
8584
+ _.find((O) => O.mediaType === e && k[e]) && await this.replaceSenderStream([e], !0);
8585
+ } catch (e) {
8586
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: changeScreenSharing is error.", e);
8587
+ }
8588
+ });
8572
8589
  /**
8573
8590
  * 添加广播事件
8574
8591
  * @param notify Notify
@@ -8579,7 +8596,7 @@ class RoomCalls extends RoomPeer {
8579
8596
  * 广播给房间其他人
8580
8597
  * 只有当自己建立了发射轨道 并且 加入房间后才进行广播
8581
8598
  */
8582
- at(this, Kt, async (u) => {
8599
+ st(this, Kt, async (u) => {
8583
8600
  const { roomId: E } = this.options;
8584
8601
  if (!E) return;
8585
8602
  const { id: _, tracks: k = [] } = await this.getCaller();
@@ -8612,7 +8629,7 @@ class RoomCalls extends RoomPeer {
8612
8629
  if (q !== 200) return _(P);
8613
8630
  const { roomId: V = "", roomUsers: J = [] } = j;
8614
8631
  if (V !== O) return _("加入的房间不匹配");
8615
- this.createSession(), await this.updateUsers(J), e();
8632
+ this.isInRoom = !0, this.createSession(), await this.updateUsers(J), e();
8616
8633
  });
8617
8634
  } catch (O) {
8618
8635
  this.taskQueue.setCondition("joinRoom", !0), _(`加入房间失败: ${O.message || O || "服务器繁忙"}`);
@@ -8628,10 +8645,10 @@ class RoomCalls extends RoomPeer {
8628
8645
  Z(this, "quitRoom", () => new Promise(async (u) => {
8629
8646
  const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
8630
8647
  try {
8631
- 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");
8632
8649
  } catch {
8633
8650
  }
8634
- 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);
8635
8652
  }));
8636
8653
  /**
8637
8654
  * 退出房间 不断开连接
@@ -8641,7 +8658,7 @@ class RoomCalls extends RoomPeer {
8641
8658
  Z(this, "quitRoomEx", () => new Promise(async (u) => {
8642
8659
  const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
8643
8660
  try {
8644
- 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);
8645
8662
  } catch {
8646
8663
  }
8647
8664
  await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoomEx", data: k }), u(!0);
@@ -8675,18 +8692,18 @@ class RoomCalls extends RoomPeer {
8675
8692
  const k = async () => {
8676
8693
  try {
8677
8694
  await this.replaceSenderStream(u, !1), await this.createTrack(u);
8678
- const e = await this.getCaller(), n = this.getSenderTracks(u), O = [...e.tracks, ...n];
8679
- await this.updateUsertracks(e.id, O, !0);
8680
- const $ = await this.getCallAction(O);
8681
- await Q(this, It).call(this, $), await this.replaceSenderStream(u, !0), Q(this, Kt).call(this, u);
8695
+ const e = await this.getCaller();
8682
8696
  try {
8683
8697
  await this.setLocalStream(u, !0);
8684
8698
  } catch {
8685
8699
  }
8686
- const N = [];
8700
+ const n = [];
8687
8701
  for (const D of u)
8688
- this.getUserStream(e.id, D).getTracks().length === 0 && N.push(D);
8689
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: inactive_mediaTypes", N), N.length !== 0 && await this.inactiveTracks(N, !1);
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);
8690
8707
  {
8691
8708
  await this.emitNotifyUpdateUsers();
8692
8709
  const D = await this.getCaller();
@@ -8862,7 +8879,7 @@ class RoomCalls extends RoomPeer {
8862
8879
  /**
8863
8880
  * 更新自己通话状态
8864
8881
  */
8865
- at(this, It, async (u) => new Promise(async (E, _) => {
8882
+ st(this, It, async (u) => new Promise(async (E, _) => {
8866
8883
  const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: u } };
8867
8884
  await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
8868
8885
  const { code: $ = 0 } = O;
@@ -8888,9 +8905,8 @@ class RoomCalls extends RoomPeer {
8888
8905
  try {
8889
8906
  if (["connecting", "connected"].includes(this.cwsIns.state)) return u(!0);
8890
8907
  this.taskQueue.setCondition("createWs", !1), this.cwsIns.clearEvents(), this.initPeer();
8891
- 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;
8892
8909
  if (!_) return E("quickvo: createWs is error. You must first use QuickVO.setOptions to set the appid.");
8893
- if (!k) return E("quickvo: createWs is error. You must first use QuickVO.setOptions to set the userId.");
8894
8910
  const O = {
8895
8911
  a: e,
8896
8912
  b: k,
@@ -8956,29 +8972,30 @@ class RoomCalls extends RoomPeer {
8956
8972
  this.taskQueue.addTask(_, ["createWs", "createSession", "ice", "subscribe", "createTrack", "closeTrack"], { describe: "createTrack" });
8957
8973
  }));
8958
8974
  /**
8959
- * 提前建连
8975
+ * 预连接
8976
+ * @param mediaTypes MediaType[]
8977
+ * @example quickvo.earlyConnect(['microphoneCamera_audio', 'microphoneCamera_video'])
8960
8978
  */
8961
- Z(this, "earlyConnect", () => {
8962
- this.isEarly = !0, this.createWs(), this.createSession(), this.createTrack(["microphoneCamera_audio", "microphoneCamera_video"]);
8979
+ Z(this, "earlyConnect", (u = []) => {
8980
+ this.isEarly = !0, this.createWs(), this.createSession(), u.length === 0 && (u = ["microphoneCamera_audio", "microphoneCamera_video"]), this.createTrack(u);
8963
8981
  });
8964
- this.setRoomState("ready");
8965
8982
  }
8966
8983
  }
8967
8984
  Kt = new WeakMap(), It = new WeakMap();
8968
8985
  class Room extends RoomCalls {
8969
- constructor() {
8970
- super();
8986
+ constructor(I) {
8987
+ super(I);
8971
8988
  }
8972
8989
  }
8973
8990
  var gt, Gt, Qt, Vt, Yt;
8974
8991
  class QuickVO extends Room {
8975
8992
  constructor(u) {
8976
- super();
8977
- at(this, gt, /* @__PURE__ */ new Map());
8993
+ super(u);
8994
+ st(this, gt, /* @__PURE__ */ new Map());
8978
8995
  /**
8979
8996
  * 添加内部监听事件
8980
8997
  */
8981
- at(this, Gt, () => {
8998
+ st(this, Gt, () => {
8982
8999
  {
8983
9000
  const u = async (E) => {
8984
9001
  const { qualities: _ = [] } = E.data, [k] = _;
@@ -9053,14 +9070,12 @@ class QuickVO extends Room {
9053
9070
  /**
9054
9071
  * cwsIns 发送消息前
9055
9072
  */
9056
- at(this, Qt, () => {
9057
- this.cwsIns.sendMessageBefore = async () => {
9058
- };
9073
+ st(this, Qt, () => {
9059
9074
  });
9060
9075
  /**
9061
9076
  * 重连成功
9062
9077
  */
9063
- at(this, Vt, () => {
9078
+ st(this, Vt, () => {
9064
9079
  this.cwsIns.onReconnectSuccess = async () => {
9065
9080
  this.syncRoomInfo();
9066
9081
  };
@@ -9068,7 +9083,7 @@ class QuickVO extends Room {
9068
9083
  /**
9069
9084
  * 重连停止
9070
9085
  */
9071
- at(this, Yt, async () => {
9086
+ st(this, Yt, async () => {
9072
9087
  });
9073
9088
  /**
9074
9089
  * 添加 FrameRequestCallback
@@ -9107,7 +9122,7 @@ class QuickVO extends Room {
9107
9122
  Z(this, "destroy", async () => {
9108
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();
9109
9124
  });
9110
- 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);
9111
9126
  }
9112
9127
  }
9113
9128
  gt = new WeakMap(), Gt = new WeakMap(), Qt = new WeakMap(), Vt = new WeakMap(), Yt = new WeakMap();