quickvo-sdk-js 0.1.8 → 0.2.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/README.md CHANGED
@@ -184,7 +184,6 @@ interface RoomOptions {
184
184
  * @enum 2 直播通话类型(间创建者默认拥有推拉流权限,其他加入者默认拥有订阅权限)
185
185
  */
186
186
  callType: number
187
-
188
187
  }
189
188
  ```
190
189
 
@@ -295,10 +294,10 @@ quickvo.setLocalStream('microphoneCamera_audio', true).then((streams) => {
295
294
  /**
296
295
  * 加入房间
297
296
  * @param roomOptions RoomOptions
298
- * @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' })
297
+ * @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1', newPublishAutoSubscribe: true })
299
298
  * @returns Promise<boolean>
300
299
  */
301
- const options: RoomOptions = { userId: '', roomId: '', sdkToken: '', callType: '1' }
300
+ const options: RoomOptions = { userId: '', roomId: '', sdkToken: '', callType: '1', newPublishAutoSubscribe: true }
302
301
  quickvo.joinRoom(options)
303
302
  ```
304
303
 
@@ -350,6 +349,34 @@ quickvo.subscribe(['123']).then((users) => {
350
349
  })
351
350
  ```
352
351
 
352
+ #### 注意:
353
+
354
+ - 在 sdk 0.1.6 版本之后 加入房间后不在主动进行订阅,并且移除了相关字段 (autoSubscribe),因此将订阅的逻辑全交给应用层控制。示例代码如下:
355
+
356
+ ```ts
357
+ // 首次进入房间订阅全部用户媒体
358
+ export const subscribeAll = async () => {
359
+ const trackNames: string[] = []
360
+
361
+ const ids: string[] = []
362
+
363
+ // 获取当需要订阅的轨道
364
+ for (const user of roomUsers.value) {
365
+ const { id, tracks } = user
366
+ for (const track of tracks) {
367
+ trackNames.push(track.trackName)
368
+ }
369
+ // 有媒体轨道才进行loading
370
+ if (tracks.length !== 0) {
371
+ ids.push(id)
372
+ }
373
+ }
374
+
375
+ addLoadings(ids) // 添加loading状态
376
+ await quickvo.subscribe(trackNames).finally(() => removeLoadings(ids)) // 移除loading状态
377
+ }
378
+ ```
379
+
353
380
  ### 销毁引擎
354
381
 
355
382
  - 对 SDK 整体进行销毁
@@ -378,6 +405,15 @@ quickvo.quitRoom()
378
405
 
379
406
  ### 版本迭代说明
380
407
 
408
+ - 版本:0.1.9 (2025-03-21)
409
+
410
+ ```
411
+ QuickVO.joinRoom 新增字段: newPublishAutoSubscribe
412
+ 新流自动订阅 (默认为true 当房间存在大量用户流多需要分页订阅时则使用false)
413
+ 用于控制当监听到新媒体轨道发布时 sdk内部是否自动发起订阅并输出最终媒体流。
414
+
415
+ ```
416
+
381
417
  - 版本:0.1.7 (2025-03-20)
382
418
 
383
419
  ```
@@ -391,4 +427,4 @@ SDK 内部逻辑改动说明:
391
427
  onPublish 之前受 autoSubscribe 影响,现在由[自动订阅/手动订阅] 改为 [自动订阅]。
392
428
  (如果之前加入房间一直使用 autoSubscribe:true 则不受影响 可以忽略。)
393
429
 
394
- ```
430
+ ```
@@ -15,8 +15,8 @@ export declare const enum_notifyName: {
15
15
  readonly onUpdatePermissions: "更新推流权限通知";
16
16
  readonly onTokenExpired: "Token已过期";
17
17
  readonly onDestroyRoom: "直播模式房间销毁";
18
- readonly destroyRoom: "销毁房间";
19
- readonly onDestroy: "销毁";
18
+ readonly destroyRoom: "服务器要求销毁房间";
19
+ readonly onDestroy: "SDK销毁";
20
20
  };
21
21
  export type T_notifyName = typeof enum_notifyName;
22
22
  export type K_notifyName = keyof T_notifyName;
@@ -26,4 +26,4 @@ export declare const notifyName_options: {
26
26
  label: any;
27
27
  }[];
28
28
  export declare const notifyName_keys: (keyof typeof enum_notifyName)[];
29
- export declare const notifyName_vals: ("关闭轨道" | "网络情况变更" | "房间网络情况变更" | "心跳检测" | "网络质量回调" | "登录回调" | "更新本地媒体流" | "房间用户变化" | "房间状态变化" | "加入房间回调" | "退出房间回调" | "监听到流发布" | "更新通讯状态" | "更新推流权限通知" | "Token已过期" | "直播模式房间销毁" | "销毁房间" | "销毁")[];
29
+ export declare const notifyName_vals: ("关闭轨道" | "网络情况变更" | "房间网络情况变更" | "心跳检测" | "网络质量回调" | "登录回调" | "更新本地媒体流" | "房间用户变化" | "房间状态变化" | "加入房间回调" | "退出房间回调" | "监听到流发布" | "更新通讯状态" | "更新推流权限通知" | "Token已过期" | "直播模式房间销毁" | "服务器要求销毁房间" | "SDK销毁")[];
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- var jt = Object.defineProperty;
2
- var Zt = (_) => {
1
+ var Ht = Object.defineProperty;
2
+ var Ft = (_) => {
3
3
  throw TypeError(_);
4
4
  };
5
- var Ht = (_, D, $) => D in _ ? jt(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $;
6
- var W = (_, D, $) => Ht(_, typeof D != "symbol" ? D + "" : D, $), Ft = (_, D, $) => D.has(_) || Zt("Cannot " + $);
7
- var X = (_, D, $) => (Ft(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), lt = (_, D, $) => D.has(_) ? Zt("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), yt = (_, D, $, M) => (Ft(_, D, "write to private field"), M ? M.call(_, $) : D.set(_, $), $);
5
+ var zt = (_, D, $) => D in _ ? Ht(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $;
6
+ var W = (_, D, $) => zt(_, typeof D != "symbol" ? D + "" : D, $), jt = (_, D, $) => D.has(_) || Ft("Cannot " + $);
7
+ var X = (_, D, $) => (jt(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), lt = (_, D, $) => D.has(_) ? Ft("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), yt = (_, D, $, M) => (jt(_, D, "write to private field"), M ? M.call(_, $) : D.set(_, $), $);
8
8
  const v$1 = (_, D = []) => {
9
9
  const $ = { ..._ }, M = Object.keys($);
10
10
  for (const R of M)
@@ -3850,8 +3850,8 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
3850
3850
  onUpdatePermissions: "更新推流权限通知",
3851
3851
  onTokenExpired: "Token已过期",
3852
3852
  onDestroyRoom: "直播模式房间销毁",
3853
- destroyRoom: "销毁房间",
3854
- onDestroy: "销毁"
3853
+ destroyRoom: "服务器要求销毁房间",
3854
+ onDestroy: "SDK销毁"
3855
3855
  };
3856
3856
  ut(enum_notifyName);
3857
3857
  const notifyName_keys = Object.keys(enum_notifyName);
@@ -4931,7 +4931,7 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
4931
4931
  const A = o.bits;
4932
4932
  let U = 0, L = 0, F = 0, Z = 0, H = 0, z = 0, V = 0, K = 0, J = 0, G = 0, tt, Y, nt, st, et, at = null, ct;
4933
4933
  const ot = new Uint16Array(MAXBITS + 1), rt = new Uint16Array(MAXBITS + 1);
4934
- let bt = null, Lt, Tt, It;
4934
+ let bt = null, Zt, It, Rt;
4935
4935
  for (U = 0; U <= MAXBITS; U++)
4936
4936
  ot[U] = 0;
4937
4937
  for (L = 0; L < M; L++)
@@ -4954,9 +4954,9 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
4954
4954
  if (_ === CODES$1 ? (at = bt = e, ct = 20) : _ === LENS$1 ? (at = lbase, bt = lext, ct = 257) : (at = dbase, bt = dext, ct = 0), G = 0, L = 0, U = F, et = N, z = H, V = 0, nt = -1, J = 1 << H, st = J - 1, _ === LENS$1 && J > ENOUGH_LENS$1 || _ === DISTS$1 && J > ENOUGH_DISTS$1)
4955
4955
  return 1;
4956
4956
  for (; ; ) {
4957
- Lt = U - V, e[L] + 1 < ct ? (Tt = 0, It = e[L]) : e[L] >= ct ? (Tt = bt[e[L] - ct], It = at[e[L] - ct]) : (Tt = 96, It = 0), tt = 1 << U - V, Y = 1 << z, F = Y;
4957
+ Zt = U - V, e[L] + 1 < ct ? (It = 0, Rt = e[L]) : e[L] >= ct ? (It = bt[e[L] - ct], Rt = at[e[L] - ct]) : (It = 96, Rt = 0), tt = 1 << U - V, Y = 1 << z, F = Y;
4958
4958
  do
4959
- Y -= tt, R[et + (G >> V) + Y] = Lt << 24 | Tt << 16 | It | 0;
4959
+ Y -= tt, R[et + (G >> V) + Y] = Zt << 24 | It << 16 | Rt | 0;
4960
4960
  while (Y !== 0);
4961
4961
  for (tt = 1 << U - 1; G & tt; )
4962
4962
  tt >>= 1;
@@ -5718,7 +5718,7 @@ const compressArrayBuffer = (_) => {
5718
5718
  }
5719
5719
  return _;
5720
5720
  }, checkReconnect = (_) => !0;
5721
- var _t, ft, Ot, vt, kt, dt, ht, Rt, gt, $t, Et, xt, Nt, At;
5721
+ var _t, ft, gt, St, kt, dt, ht, Et, $t, Tt, xt, Nt, At, qt;
5722
5722
  class CallsWebSocket {
5723
5723
  // 重连停止的回调
5724
5724
  constructor(D) {
@@ -5732,9 +5732,9 @@ class CallsWebSocket {
5732
5732
  // 最大重连次数
5733
5733
  timeout: 30 * 1e3
5734
5734
  });
5735
- lt(this, Ot, "");
5735
+ lt(this, gt, "");
5736
5736
  // 缓存登录凭证
5737
- lt(this, vt, !1);
5737
+ lt(this, St, !1);
5738
5738
  // 是否在房间内
5739
5739
  lt(this, kt, 0);
5740
5740
  // 活性时间戳 根据服务端的响应来更新当前连接活性 活性为0 说明连接已经存在异常进行重连
@@ -5746,9 +5746,9 @@ class CallsWebSocket {
5746
5746
  W(this, "onReconnectStop", async (D) => {
5747
5747
  });
5748
5748
  // 自定义心跳规则
5749
- lt(this, Rt, () => X(this, vt) ? com.quick.voice.proto.CommonReq.encode({ event: "heartbeat", sn: +`${O(1e5, 999999)}` }).finish() : "");
5749
+ lt(this, Et, () => X(this, St) ? com.quick.voice.proto.CommonReq.encode({ event: "heartbeat", sn: +`${O(1e5, 999999)}` }).finish() : "");
5750
5750
  // 更新日志
5751
- lt(this, gt, (D, $ = {}) => {
5751
+ lt(this, $t, (D, $ = {}) => {
5752
5752
  try {
5753
5753
  const { time: M, event: R, data: N = {}, data_original: e = {}, data_remote: o, ...A } = $, U = E(M, "YYYY-MM-DD hh:mm:ss", { offset: 480 });
5754
5754
  let L = {};
@@ -5776,7 +5776,7 @@ class CallsWebSocket {
5776
5776
  }
5777
5777
  });
5778
5778
  // 活性检查器 每次发送消息前 、 接收消息后 都会调用进行检查
5779
- lt(this, $t, (D) => new Promise(async ($) => {
5779
+ lt(this, Tt, (D) => new Promise(async ($) => {
5780
5780
  const { event: M } = D, R = Date.now();
5781
5781
  M === "healthCheck" && (yt(this, kt, R), X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 刷新活性", { activetimeStamp: X(this, kt), activetimeStampStr: E(X(this, kt)) }));
5782
5782
  const N = 30 * 1e3 + X(this, ft).timeout;
@@ -5793,7 +5793,7 @@ class CallsWebSocket {
5793
5793
  }
5794
5794
  });
5795
5795
  // 创建事件
5796
- lt(this, Et, (D, { resolve: $, reject: M }) => {
5796
+ lt(this, xt, (D, { resolve: $, reject: M }) => {
5797
5797
  const { sn: R } = D, N = () => {
5798
5798
  const o = X(this, dt)[R];
5799
5799
  clearTimeout(o.destructionTimer), delete X(this, dt)[R];
@@ -5804,9 +5804,9 @@ class CallsWebSocket {
5804
5804
  X(this, dt)[R] = { message: D, resolve: $, reject: M, destruction: N, destructionTimer: e };
5805
5805
  });
5806
5806
  // 获取事件
5807
- lt(this, xt, (D) => X(this, dt)[D]);
5807
+ lt(this, Nt, (D) => X(this, dt)[D]);
5808
5808
  // 重连成功
5809
- lt(this, Nt, async (D) => {
5809
+ lt(this, At, async (D) => {
5810
5810
  const $ = Date.now();
5811
5811
  yt(this, kt, $), X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重置活性", { activetimeStamp: X(this, kt), activetimeStampStr: E(X(this, kt)) }), await this.onReconnectSuccess(D);
5812
5812
  });
@@ -5816,16 +5816,16 @@ class CallsWebSocket {
5816
5816
  * @returns
5817
5817
  */
5818
5818
  W(this, "connect", async (D = "") => {
5819
- D && yt(this, Ot, D), X(this, _t) && await X(this, _t).close();
5820
- const $ = `${X(this, ft).url}?s=${X(this, Ot)}&t=${Date.now()}`;
5819
+ D && yt(this, gt, D), X(this, _t) && await X(this, _t).close();
5820
+ const $ = `${X(this, ft).url}?s=${X(this, gt)}&t=${Date.now()}`;
5821
5821
  return yt(this, _t, new k$1({
5822
5822
  ...X(this, ft),
5823
5823
  url: $,
5824
5824
  binaryType: "arraybuffer",
5825
- onMessage: X(this, At),
5825
+ onMessage: X(this, qt),
5826
5826
  checkReconnect,
5827
- getHeartbeatMsg: X(this, Rt),
5828
- onReconnectSuccess: X(this, Nt),
5827
+ getHeartbeatMsg: X(this, Et),
5828
+ onReconnectSuccess: X(this, At),
5829
5829
  onReconnectStop: (M) => this.onReconnectStop(M)
5830
5830
  })), await X(this, _t).connect(), yt(this, kt, Date.now()), X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", X(this, ht)), X(this, _t);
5831
5831
  });
@@ -5857,17 +5857,17 @@ class CallsWebSocket {
5857
5857
  compress: !1,
5858
5858
  ...e
5859
5859
  });
5860
- X(this, ft).debug && (X(this, gt).call(this, "req", A), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", A)), await X(this, $t).call(this, A), N === "joinRoom" && yt(this, vt, !1), $ && X(this, Et).call(this, A, { resolve: M, reject: R });
5860
+ X(this, ft).debug && (X(this, $t).call(this, "req", A), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", A)), await X(this, Tt).call(this, A), N === "joinRoom" && yt(this, St, !1), $ && X(this, xt).call(this, A, { resolve: M, reject: R });
5861
5861
  const U = com.quick.voice.proto.CommonReq.encode(A).finish();
5862
5862
  (L = X(this, _t)) == null || L.sendMessage(U);
5863
5863
  }));
5864
5864
  // 接收消息
5865
- lt(this, At, async (D) => {
5865
+ lt(this, qt, async (D) => {
5866
5866
  const $ = new Uint8Array(D), M = com.quick.voice.proto.CommonRsp.decode($), { sn: R, event: N } = M, e = onMessageFormat(M);
5867
- if (X(this, ft).debug && (X(this, gt).call(this, "res", e), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e)), await X(this, $t).call(this, e), N === "joinRoom" && yt(this, vt, !0), ignoreEvent.includes(N)) return;
5867
+ if (X(this, ft).debug && (X(this, $t).call(this, "res", e), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e)), await X(this, Tt).call(this, e), N === "joinRoom" && yt(this, St, !0), ignoreEvent.includes(N)) return;
5868
5868
  if (notifyName_keys.includes(N))
5869
5869
  return this.emitNotify(N, v$1(e, ["code", "data", "desc"]));
5870
- const A = X(this, xt).call(this, R);
5870
+ const A = X(this, Nt).call(this, R);
5871
5871
  if (A) {
5872
5872
  const { resolve: U = (F) => {
5873
5873
  }, destruction: L = () => {
@@ -5916,7 +5916,7 @@ class CallsWebSocket {
5916
5916
  yt(this, ft, { ...X(this, ft), ...D });
5917
5917
  }
5918
5918
  }
5919
- _t = new WeakMap(), ft = new WeakMap(), Ot = new WeakMap(), vt = new WeakMap(), kt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), Rt = new WeakMap(), gt = new WeakMap(), $t = new WeakMap(), Et = new WeakMap(), xt = new WeakMap(), Nt = new WeakMap(), At = new WeakMap();
5919
+ _t = new WeakMap(), ft = new WeakMap(), gt = new WeakMap(), St = new WeakMap(), kt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), Et = new WeakMap(), $t = new WeakMap(), Tt = new WeakMap(), xt = new WeakMap(), Nt = new WeakMap(), At = new WeakMap(), qt = new WeakMap();
5920
5920
  class AudioMediaStreamContext {
5921
5921
  constructor(D) {
5922
5922
  W(this, "options", {
@@ -6249,7 +6249,8 @@ class RoomBase extends MediaStreams {
6249
6249
  roomId: "",
6250
6250
  userId: "",
6251
6251
  callType: 0,
6252
- debug: !1
6252
+ debug: !1,
6253
+ newPublishAutoSubscribe: !0
6253
6254
  });
6254
6255
  W(this, "tools", tools);
6255
6256
  W(this, "asyncQueue", new k());
@@ -7177,7 +7178,7 @@ function requireLib() {
7177
7178
  var _ = requireParser(), D = requireWriter(), $ = requireGrammar();
7178
7179
  return lib.grammar = $, lib.write = D, lib.parse = _.parse, lib.parseParams = _.parseParams, lib.parseFmtpConfig = _.parseFmtpConfig, lib.parsePayloads = _.parsePayloads, lib.parseRemoteCandidates = _.parseRemoteCandidates, lib.parseImageAttributes = _.parseImageAttributes, lib.parseSimulcastStreamList = _.parseSimulcastStreamList, lib;
7179
7180
  }
7180
- var libExports = requireLib(), qt, Dt, Ct;
7181
+ var libExports = requireLib(), Dt, Ct, Ut;
7181
7182
  class RoomPeer extends RoomAudio {
7182
7183
  constructor() {
7183
7184
  super();
@@ -7196,7 +7197,7 @@ class RoomPeer extends RoomAudio {
7196
7197
  });
7197
7198
  W(this, "connectedResolveMap", /* @__PURE__ */ new Map());
7198
7199
  W(this, "initPeer", () => {
7199
- this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), X(this, qt).call(this), X(this, Ct).call(this);
7200
+ this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), X(this, Dt).call(this), X(this, Ut).call(this);
7200
7201
  });
7201
7202
  /**
7202
7203
  * 初始化发射器
@@ -7285,7 +7286,7 @@ class RoomPeer extends RoomAudio {
7285
7286
  /**
7286
7287
  * 监听webrtc ice通讯连接
7287
7288
  */
7288
- lt(this, qt, async () => {
7289
+ lt(this, Dt, async () => {
7289
7290
  let $ = 0;
7290
7291
  const M = () => {
7291
7292
  this.setRoomState("disconnected"), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} });
@@ -7431,7 +7432,7 @@ class RoomPeer extends RoomAudio {
7431
7432
  /**
7432
7433
  * 设置并分析报告
7433
7434
  */
7434
- lt(this, Dt, async ($) => {
7435
+ lt(this, Ct, async ($) => {
7435
7436
  try {
7436
7437
  let M = 0, R = 0, N = 0, e = 0, o = [], A = [];
7437
7438
  for (const J of this.reports) {
@@ -7467,7 +7468,7 @@ class RoomPeer extends RoomAudio {
7467
7468
  /**
7468
7469
  * 获取连接的所有状态数据
7469
7470
  */
7470
- lt(this, Ct, () => {
7471
+ lt(this, Ut, () => {
7471
7472
  const $ = (R) => {
7472
7473
  const N = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"];
7473
7474
  return new Promise(async (e) => {
@@ -7490,7 +7491,7 @@ class RoomPeer extends RoomAudio {
7490
7491
  const A = await $(o);
7491
7492
  N = [...N, ...A];
7492
7493
  }
7493
- X(this, Dt).call(this, N);
7494
+ X(this, Ct).call(this, N);
7494
7495
  };
7495
7496
  this.getPeerStatsTimer = setInterval(M, 1 * 1e3);
7496
7497
  });
@@ -7500,14 +7501,14 @@ class RoomPeer extends RoomAudio {
7500
7501
  W(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
7501
7502
  }
7502
7503
  }
7503
- qt = new WeakMap(), Dt = new WeakMap(), Ct = new WeakMap();
7504
- var St, Ut;
7504
+ Dt = new WeakMap(), Ct = new WeakMap(), Ut = new WeakMap();
7505
+ var wt, Ot, Mt;
7505
7506
  class RoomCalls extends RoomPeer {
7506
7507
  constructor() {
7507
7508
  super();
7508
7509
  // sdk服务版本
7509
7510
  W(this, "sdk_service_version", "1.0.3");
7510
- W(this, "beferCreateSession", !0);
7511
+ lt(this, wt, !0);
7511
7512
  /**
7512
7513
  * 添加广播事件
7513
7514
  * @param notify Notify
@@ -7573,12 +7574,12 @@ class RoomCalls extends RoomPeer {
7573
7574
  /**
7574
7575
  * 加入房间
7575
7576
  * @param roomOptions RoomOptions
7576
- * @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' })
7577
+ * @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' , newPublishAutoSubscribe: true })
7577
7578
  * @returns Promise<boolean>
7578
7579
  */
7579
7580
  W(this, "joinRoom", async ($) => new Promise(async (M, R) => {
7580
7581
  try {
7581
- this.setOptions($), this.clearUsers(), this.initPeer(), this.cwsIns.clearEvents(), await X(this, Ut).call(this), this.setRoomState("connect");
7582
+ this.setOptions($), this.clearUsers(), this.initPeer(), this.cwsIns.clearEvents(), await X(this, Mt).call(this), this.setRoomState("connect");
7582
7583
  const { roomId: N, userId: e, callType: o } = this.options;
7583
7584
  await this.cwsIns.sendMessage({
7584
7585
  event: "joinRoom",
@@ -7588,7 +7589,7 @@ class RoomCalls extends RoomPeer {
7588
7589
  if (U !== 200) return R(L);
7589
7590
  const { roomId: Z = "", roomUsers: H = [] } = F;
7590
7591
  if (Z !== N) return R("加入的房间不匹配");
7591
- this.beferCreateSession && this.createSession(), await this.updateUsers(H), this.setRoomState("connected"), await this.emitNotifyUpdateUsers();
7592
+ X(this, wt) && this.createSession(), await this.updateUsers(H), this.setRoomState("connected"), await this.emitNotifyUpdateUsers();
7592
7593
  const z = await this.getUsers();
7593
7594
  M(z);
7594
7595
  });
@@ -7602,12 +7603,13 @@ class RoomCalls extends RoomPeer {
7602
7603
  * @returns Promise<boolean>
7603
7604
  */
7604
7605
  W(this, "quitRoom", async () => new Promise(async ($) => {
7605
- const { roomId: M, userId: R } = this.options, N = { roomId: M, user: { id: R } };
7606
7606
  try {
7607
- this.stopPublish(), await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoom", data: N });
7608
- } catch {
7607
+ this.stopPublish();
7608
+ } catch (e) {
7609
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", e);
7609
7610
  }
7610
- this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} }), $(!0);
7611
+ const { roomId: M, userId: R } = this.options, N = { roomId: M, user: { id: R } };
7612
+ await this.cwsIns.sendMessage({ event: "quitRoom", data: N }), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} }), $(!0);
7611
7613
  }));
7612
7614
  /**
7613
7615
  * 同步房间信息
@@ -7633,7 +7635,7 @@ class RoomCalls extends RoomPeer {
7633
7635
  * @returns Promise<RoomUser>
7634
7636
  */
7635
7637
  W(this, "publish", async ($, M = 3) => {
7636
- this.beferCreateSession && await this.connectionICE();
7638
+ X(this, wt) && await this.connectionICE();
7637
7639
  const R = () => new Promise(async (N, e) => {
7638
7640
  try {
7639
7641
  $.includes("screenSharing_audio") && !$.includes("screenSharing_video") && ($ = [...$, "screenSharing_video"]);
@@ -7659,7 +7661,7 @@ class RoomCalls extends RoomPeer {
7659
7661
  throw this.options.debug && console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: publish is error. count 0", { mediaTypes: $ }), new Error(z);
7660
7662
  }
7661
7663
  const { remoteSdp: K } = V;
7662
- await this.setRemoteDescription({ type: "answer", sdp: K }), await this.connectionICE(), await this.updateUsertracks(o.id, U, !0), await X(this, St).call(this, L), this.beferCreateSession || this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: "", user: { id: o.id, tracks: A } } });
7664
+ await this.setRemoteDescription({ type: "answer", sdp: K }), await this.connectionICE(), await this.updateUsertracks(o.id, U, !0), await X(this, Ot).call(this, L), X(this, wt) || this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: "", user: { id: o.id, tracks: A } } });
7663
7665
  {
7664
7666
  await this.emitNotifyUpdateUsers();
7665
7667
  const J = await this.getCaller();
@@ -7693,7 +7695,7 @@ class RoomCalls extends RoomPeer {
7693
7695
  await this.closeUserTracks(e.id, o, !0);
7694
7696
  {
7695
7697
  const U = await this.tools.getCallAction(e.tracks);
7696
- await X(this, St).call(this, U);
7698
+ await X(this, Ot).call(this, U);
7697
7699
  }
7698
7700
  await this.createOffer(), await this.cwsIns.sendMessage({
7699
7701
  event: "closeTrack",
@@ -7716,7 +7718,7 @@ class RoomCalls extends RoomPeer {
7716
7718
  * @returns Promise<RoomUser[]>
7717
7719
  */
7718
7720
  W(this, "subscribe", async ($ = [], M = 3) => {
7719
- this.beferCreateSession && await this.connectionICE();
7721
+ X(this, wt) && await this.connectionICE();
7720
7722
  const R = () => new Promise(async (N, e) => {
7721
7723
  try {
7722
7724
  this.prohibitNotify = !0;
@@ -7816,7 +7818,7 @@ class RoomCalls extends RoomPeer {
7816
7818
  }
7817
7819
  }
7818
7820
  const A = await this.tools.getCallAction(o);
7819
- await X(this, St).call(this, A), await this.emitNotifyUpdateUsers();
7821
+ await X(this, Ot).call(this, A), await this.emitNotifyUpdateUsers();
7820
7822
  };
7821
7823
  return this.asyncQueue.add(R, { key: "inactiveTracks" });
7822
7824
  });
@@ -7834,7 +7836,7 @@ class RoomCalls extends RoomPeer {
7834
7836
  /**
7835
7837
  * 更新自己通话状态
7836
7838
  */
7837
- lt(this, St, async ($) => new Promise(async (M, R) => {
7839
+ lt(this, Ot, async ($) => new Promise(async (M, R) => {
7838
7840
  const { roomId: N, userId: e } = this.options, o = { roomId: N, user: { id: e, callAction: $ } };
7839
7841
  await this.cwsIns.sendMessage({ event: "updateCall", data: o }).then(async (A) => {
7840
7842
  const { code: U = 0 } = A;
@@ -7868,7 +7870,7 @@ class RoomCalls extends RoomPeer {
7868
7870
  /**
7869
7871
  * 登录
7870
7872
  */
7871
- lt(this, Ut, async () => new Promise(async ($, M) => {
7873
+ lt(this, Mt, async () => new Promise(async ($, M) => {
7872
7874
  try {
7873
7875
  this.setRoomState("checkAuth");
7874
7876
  const { appid: R } = this.options, { userId: N, sdkToken: e } = this.options, o = {
@@ -7885,7 +7887,7 @@ class RoomCalls extends RoomPeer {
7885
7887
  this.setRoomState("ready");
7886
7888
  }
7887
7889
  }
7888
- St = new WeakMap(), Ut = new WeakMap();
7890
+ wt = new WeakMap(), Ot = new WeakMap(), Mt = new WeakMap();
7889
7891
  class Room extends RoomCalls {
7890
7892
  constructor() {
7891
7893
  super();
@@ -7909,15 +7911,15 @@ class Room extends RoomCalls {
7909
7911
  });
7910
7912
  }
7911
7913
  }
7912
- var wt, Mt, Pt, Bt;
7914
+ var vt, Pt, Bt, Lt;
7913
7915
  class QuickVO extends Room {
7914
7916
  constructor($) {
7915
7917
  super();
7916
- lt(this, wt, /* @__PURE__ */ new Map());
7918
+ lt(this, vt, /* @__PURE__ */ new Map());
7917
7919
  /**
7918
7920
  * 添加内部监听事件
7919
7921
  */
7920
- lt(this, Mt, () => {
7922
+ lt(this, Pt, () => {
7921
7923
  {
7922
7924
  const $ = async (M) => {
7923
7925
  const { qualities: R } = M.data;
@@ -7947,11 +7949,14 @@ class QuickVO extends Room {
7947
7949
  const $ = async (M) => {
7948
7950
  await this.updateUsers([M.data.user]);
7949
7951
  {
7950
- const N = M.data.user, { id: e, tracks: o = [] } = N;
7951
- await this.updateUsertracks(e, o, !0);
7952
+ const R = M.data.user, { id: N, tracks: e = [] } = R;
7953
+ await this.updateUsertracks(N, e, !0);
7952
7954
  }
7953
- const R = this.tools.getTrackNamesFormTracks(M.data.user.tracks);
7954
- await this.subscribe(R);
7955
+ if (this.options.newPublishAutoSubscribe) {
7956
+ const R = this.tools.getTrackNamesFormTracks(M.data.user.tracks);
7957
+ await this.subscribe(R);
7958
+ } else
7959
+ await this.emitNotifyUpdateUsers();
7955
7960
  };
7956
7961
  this.cwsIns.addNotify({ event: "onPublish", callback: $ }, !0);
7957
7962
  }
@@ -8003,12 +8008,12 @@ class QuickVO extends Room {
8003
8008
  };
8004
8009
  this.cwsIns.addNotify({ event: "onUpdatePermissions", callback: $ }, !0);
8005
8010
  }
8006
- this.cwsIns.addNotify({ event: "onTokenExpired", callback: async ($) => this.destroy() }, !0), this.cwsIns.addNotify({ event: "onDestroy", callback: this.destroy }, !0), this.cwsIns.addNotify({ event: "destroyRoom", callback: this.destroy }, !0);
8011
+ this.cwsIns.addNotify({ event: "onTokenExpired", callback: async ($) => this.destroy() }, !0), this.cwsIns.addNotify({ event: "destroyRoom", callback: this.destroy }, !0), this.cwsIns.addNotify({ event: "onDestroy", callback: this.destroy }, !0);
8007
8012
  });
8008
8013
  /**
8009
8014
  * 重连成功
8010
8015
  */
8011
- lt(this, Pt, () => {
8016
+ lt(this, Bt, () => {
8012
8017
  this.cwsIns.onReconnectSuccess = async () => {
8013
8018
  this.syncRoomInfo();
8014
8019
  };
@@ -8016,7 +8021,7 @@ class QuickVO extends Room {
8016
8021
  /**
8017
8022
  * 重连停止
8018
8023
  */
8019
- lt(this, Bt, async () => {
8024
+ lt(this, Lt, async () => {
8020
8025
  this.cwsIns.onReconnectStop = async () => {
8021
8026
  this.destroy();
8022
8027
  };
@@ -8028,13 +8033,13 @@ class QuickVO extends Room {
8028
8033
  */
8029
8034
  W(this, "addRequestAnimationFrame", async ($, M) => {
8030
8035
  {
8031
- const N = X(this, wt).get($);
8036
+ const N = X(this, vt).get($);
8032
8037
  N && cancelAnimationFrame(N);
8033
8038
  }
8034
8039
  const R = (N = Date.now()) => {
8035
8040
  M(N);
8036
8041
  const e = requestAnimationFrame(R);
8037
- X(this, wt).set($, e);
8042
+ X(this, vt).set($, e);
8038
8043
  };
8039
8044
  R();
8040
8045
  });
@@ -8043,10 +8048,10 @@ class QuickVO extends Room {
8043
8048
  * @param keys string[] = []
8044
8049
  */
8045
8050
  W(this, "clearRequestAnimationFrame", async ($ = []) => {
8046
- $.length === 0 && ($ = [...X(this, wt).keys()]);
8051
+ $.length === 0 && ($ = [...X(this, vt).keys()]);
8047
8052
  const M = [];
8048
8053
  for (const R of $) {
8049
- const N = X(this, wt).get(R);
8054
+ const N = X(this, vt).get(R);
8050
8055
  N && (cancelAnimationFrame(N), M.push(N));
8051
8056
  }
8052
8057
  return M;
@@ -8058,10 +8063,10 @@ class QuickVO extends Room {
8058
8063
  W(this, "destroy", async () => {
8059
8064
  this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 销毁SDK"), this.stopGetPeerStats(), this.asyncQueue.clear(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), await this.cwsIns.close();
8060
8065
  });
8061
- this.setOptions($), this.initCwsCall(), X(this, Pt).call(this), X(this, Bt).call(this), X(this, Mt).call(this);
8066
+ this.setOptions($), this.initCwsCall(), X(this, Bt).call(this), X(this, Lt).call(this), X(this, Pt).call(this);
8062
8067
  }
8063
8068
  }
8064
- wt = new WeakMap(), Mt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap();
8069
+ vt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), Lt = new WeakMap();
8065
8070
  export {
8066
8071
  QuickVO,
8067
8072
  getAverageVolume,