quickvo-sdk-js 0.4.5 → 0.4.7

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
@@ -7350,9 +7350,9 @@ class CallsWebSocket {
7350
7350
  }
7351
7351
  }
7352
7352
  yt = new WeakMap(), lt = new WeakMap(), gt = new WeakMap(), ft = new WeakMap(), dt = new WeakMap(), Et = new WeakMap(), xt = new WeakMap(), Nt = new WeakMap(), At = new WeakMap(), $t = new WeakMap(), qt = new WeakMap(), Dt = new WeakMap(), Ct = new WeakMap();
7353
- var p = Object.defineProperty, x = (_) => {
7353
+ var p = Object.defineProperty, y = (_) => {
7354
7354
  throw TypeError(_);
7355
- }, g = (_, q, k) => q in _ ? p(_, q, { enumerable: !0, configurable: !0, writable: !0, value: k }) : _[q] = k, h = (_, q, k) => g(_, typeof q != "symbol" ? q + "" : q, k), y = (_, q, k) => q.has(_) || x("Cannot " + k), n = (_, q, k) => (y(_, q, "read from private field"), k ? k.call(_) : q.get(_)), a = (_, q, k) => q.has(_) ? x("Cannot add the same private member more than once") : q instanceof WeakSet ? q.add(_) : q.set(_, k), b = (_, q, k, D) => (y(_, q, "write to private field"), q.set(_, k), k), d, o, f;
7355
+ }, g = (_, q, k) => q in _ ? p(_, q, { enumerable: !0, configurable: !0, writable: !0, value: k }) : _[q] = k, h = (_, q, k) => g(_, typeof q != "symbol" ? q + "" : q, k), x = (_, q, k) => q.has(_) || y("Cannot " + k), n = (_, q, k) => (x(_, q, "read from private field"), k ? k.call(_) : q.get(_)), f = (_, q, k) => q.has(_) ? y("Cannot add the same private member more than once") : q instanceof WeakSet ? q.add(_) : q.set(_, k), b = (_, q, k, D) => (x(_, q, "write to private field"), q.set(_, k), k), a, o, d;
7356
7356
  class K {
7357
7357
  // 任务 index
7358
7358
  /**
@@ -7361,8 +7361,8 @@ class K {
7361
7361
  * @param conditionKeys 条件keys string[]
7362
7362
  */
7363
7363
  constructor(q) {
7364
- a(this, d, /* @__PURE__ */ new Map()), a(this, o, []), h(this, "index"), h(this, "setCondition", (k, D) => {
7365
- n(this, d).set(k, D), D && n(this, f).call(this);
7364
+ f(this, a, /* @__PURE__ */ new Map()), f(this, o, []), h(this, "index"), h(this, "setCondition", (k, D) => {
7365
+ n(this, a).set(k, D), D && n(this, d).call(this);
7366
7366
  }), h(this, "addTask", (k, D, $ = {}) => {
7367
7367
  const I = { key: "", strict: !1, describe: "", ...$ };
7368
7368
  let { key: e, strict: u, describe: N } = I;
@@ -7371,7 +7371,7 @@ class K {
7371
7371
  const A = { key: e, func: k, conditionKeys: D, describe: N, strict: u };
7372
7372
  n(this, o).unshift(A);
7373
7373
  }
7374
- return n(this, f).call(this), e;
7374
+ return n(this, d).call(this), e;
7375
7375
  }), h(this, "clear", (k = []) => {
7376
7376
  if (k.length === 0) {
7377
7377
  b(this, o, []);
@@ -7381,7 +7381,7 @@ class K {
7381
7381
  const $ = n(this, o).findIndex((I) => I.key === D);
7382
7382
  $ !== -1 && n(this, o).splice($, 1);
7383
7383
  }
7384
- }), h(this, "getConditions", () => Object.fromEntries(n(this, d))), h(this, "getTasks", () => {
7384
+ }), h(this, "getConditions", () => Object.fromEntries(n(this, a))), h(this, "getTasks", () => {
7385
7385
  const k = [];
7386
7386
  for (const D of n(this, o)) {
7387
7387
  const { key: $, describe: I, conditionKeys: e } = D;
@@ -7391,18 +7391,18 @@ class K {
7391
7391
  }), h(this, "checkConditions", (k) => {
7392
7392
  let D = !0;
7393
7393
  for (const $ of k)
7394
- if (n(this, d).get($) === !1) {
7394
+ if (n(this, a).get($) === !1) {
7395
7395
  D = !1;
7396
7396
  break;
7397
7397
  }
7398
7398
  return D;
7399
- }), a(this, f, () => {
7399
+ }), f(this, d, async () => {
7400
7400
  const k = n(this, o).length;
7401
7401
  for (let D = k; D > 0; D--) {
7402
7402
  const $ = D - 1, I = n(this, o)[$], { conditionKeys: e, func: u, strict: N } = I, A = this.checkConditions(e);
7403
7403
  {
7404
7404
  if (!A) return;
7405
- u();
7405
+ await u();
7406
7406
  }
7407
7407
  {
7408
7408
  if (N) return;
@@ -7411,10 +7411,10 @@ class K {
7411
7411
  }
7412
7412
  }), this.index = 0;
7413
7413
  for (const k of q)
7414
- n(this, d).set(k, !1);
7414
+ n(this, a).set(k, !1);
7415
7415
  }
7416
7416
  }
7417
- d = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap();
7417
+ a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap();
7418
7418
  class RoomBase {
7419
7419
  constructor() {
7420
7420
  H(this, "options", {
@@ -7430,7 +7430,7 @@ class RoomBase {
7430
7430
  // 是否禁止通知
7431
7431
  H(this, "isEarly", !1);
7432
7432
  // 是否提前建连
7433
- H(this, "taskQueue", new K(["createWs", "createSession", "ice", "joinRoom", "createTrack", "subscribe", "closeTrack", "publish"]));
7433
+ H(this, "taskQueue", new K(["createWs", "createSession", "ice", "joinRoom", "createTrack", "subscribe", "closeTrack"]));
7434
7434
  // 条件队列
7435
7435
  H(this, "roomState", "ready");
7436
7436
  // 房间状态
@@ -7450,7 +7450,7 @@ class RoomBase {
7450
7450
  screenSharing_audio: ""
7451
7451
  });
7452
7452
  H(this, "initAsyncQueue", () => {
7453
- this.taskQueue.clear(), this.taskQueue.setCondition("joinRoom", !0), this.taskQueue.setCondition("createTrack", !0), this.taskQueue.setCondition("closeTrack", !0), this.taskQueue.setCondition("subscribe", !0), this.taskQueue.setCondition("publish", !0);
7453
+ this.taskQueue.clear(), this.taskQueue.setCondition("createSession", !0), this.taskQueue.setCondition("ice", !0), this.taskQueue.setCondition("joinRoom", !0), this.taskQueue.setCondition("createTrack", !0), this.taskQueue.setCondition("closeTrack", !0), this.taskQueue.setCondition("subscribe", !0);
7454
7454
  });
7455
7455
  /**
7456
7456
  * 获取房间信息
@@ -8262,7 +8262,7 @@ class RoomPeer extends RoomUsers {
8262
8262
  };
8263
8263
  this.peerIns.onconnectionstatechange = () => {
8264
8264
  const $ = this.peerIns.connectionState;
8265
- switch (clearTimeout(k), this.taskQueue.setCondition("ice", !1), $) {
8265
+ switch (clearTimeout(k), $) {
8266
8266
  // 连接完成
8267
8267
  case "connected":
8268
8268
  this.taskQueue.setCondition("ice", !0), this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->quickvo: connectionState:${$}`);
@@ -8592,7 +8592,7 @@ class RoomCalls extends RoomPeer {
8592
8592
  H(this, "publish", (k) => new Promise(async (D, $) => {
8593
8593
  const I = async () => {
8594
8594
  try {
8595
- this.taskQueue.setCondition("publish", !1), k.includes("screenSharing_audio") && !k.includes("screenSharing_video") && (k = [...k, "screenSharing_video"]), await this.replaceSenderStream(k, !1);
8595
+ k.includes("screenSharing_audio") && !k.includes("screenSharing_video") && (k = [...k, "screenSharing_video"]), await this.replaceSenderStream(k, !1);
8596
8596
  const e = await this.getCaller();
8597
8597
  for (const L of k)
8598
8598
  this.getUserStream(e.id, L).getTracks().length === 0 && await this.setLocalStream(L, !0);
@@ -8605,16 +8605,16 @@ class RoomCalls extends RoomPeer {
8605
8605
  {
8606
8606
  await this.emitNotifyUpdateUsers();
8607
8607
  const L = await this.getCaller();
8608
- this.taskQueue.setCondition("publish", !0), D(L);
8608
+ D(L);
8609
8609
  }
8610
8610
  } catch (e) {
8611
8611
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", e);
8612
8612
  for (const u of k)
8613
8613
  await this.setLocalStream(u, !1);
8614
- this.taskQueue.setCondition("publish", !0), $(`publish is error: ${e.message || e}`);
8614
+ $(`publish is error: ${e.message || e}`);
8615
8615
  }
8616
8616
  };
8617
- this.taskQueue.addTask(I, ["createWs", "createSession", "ice", "createTrack", "subscribe", "publish"], { describe: "replaceSenderStream" });
8617
+ this.taskQueue.addTask(I, ["createWs", "createSession", "ice", "createTrack", "subscribe"], { describe: "replaceSenderStream" });
8618
8618
  }));
8619
8619
  /**
8620
8620
  * 停止发布流
@@ -8825,19 +8825,27 @@ class RoomCalls extends RoomPeer {
8825
8825
  /**
8826
8826
  * 创建cf会话
8827
8827
  */
8828
- H(this, "createSession", () => new Promise((k) => {
8829
- if (["connecting", "connected"].includes(this.roomState)) return k(!0);
8830
- const D = async () => (this.taskQueue.setCondition("ice", !1), this.taskQueue.setCondition("createSession", !1), this.setRoomState("connecting"), await this.addSenders(), this.cwsIns.sendMessage({
8831
- event: "connectCF",
8832
- data: { sdp: this.getSdp() }
8833
- }).then(async ($) => {
8834
- const { code: I = 0, desc: e, data: u } = $;
8835
- if (I !== 200) throw new Error(e);
8836
- const { remoteSdp: N } = u;
8837
- await this.setRemoteDescription({ type: "answer", sdp: N }), this.taskQueue.setCondition("createSession", !0), k(!0);
8838
- }));
8839
- this.taskQueue.addTask(D, ["createWs"], { describe: "createSession" });
8840
- }));
8828
+ H(this, "createSession", () => {
8829
+ if (!["connecting", "connected"].includes(this.roomState))
8830
+ return this.setRoomState("connecting"), new Promise((k) => {
8831
+ const D = async () => {
8832
+ try {
8833
+ this.taskQueue.setCondition("createSession", !1), await this.addSenders(), await this.cwsIns.sendMessage({
8834
+ event: "connectCF",
8835
+ data: { sdp: this.getSdp() }
8836
+ }).then(async ($) => {
8837
+ const { code: I = 0, desc: e, data: u } = $;
8838
+ if (I !== 200) throw new Error(e);
8839
+ const { remoteSdp: N } = u;
8840
+ this.taskQueue.setCondition("ice", !1), await this.setRemoteDescription({ type: "answer", sdp: N }), this.taskQueue.setCondition("createSession", !0), k(!0);
8841
+ });
8842
+ } catch ($) {
8843
+ this.taskQueue.setCondition("createSession", !0), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo create session is error.", $);
8844
+ }
8845
+ };
8846
+ this.taskQueue.addTask(D, ["createWs", "createSession", "ice"], { key: "createSession", describe: "createSession" });
8847
+ });
8848
+ });
8841
8849
  /**
8842
8850
  * 创建媒体轨道
8843
8851
  */