Package not found. Please check the package name and try again.

quickvo-sdk-js 0.0.9 → 0.1.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.
@@ -4,6 +4,7 @@ export declare const enum_notifyName: {
4
4
  readonly healthCheck: "心跳检测";
5
5
  readonly onNetQuality: "网络质量回调";
6
6
  readonly onLogin: "登录回调";
7
+ readonly onLocalStream: "更新本地媒体流";
7
8
  readonly onRoomUsers: "房间用户变化";
8
9
  readonly onRoomState: "房间状态变化";
9
10
  readonly onJoinRoom: "加入房间回调";
@@ -11,8 +12,6 @@ export declare const enum_notifyName: {
11
12
  readonly onPublish: "监听到流发布";
12
13
  readonly onCloseTrack: "关闭轨道";
13
14
  readonly onUpdateCall: "更新通讯状态";
14
- readonly onLocalStream: "更新本地媒体流";
15
- readonly onIceDisconnected: "ice断开";
16
15
  readonly onTokenExpired: "Token已过期";
17
16
  readonly destroyRoom: "销毁房间";
18
17
  readonly onDestroy: "销毁";
@@ -25,4 +24,4 @@ export declare const notifyName_options: {
25
24
  label: any;
26
25
  }[];
27
26
  export declare const notifyName_keys: (keyof typeof enum_notifyName)[];
28
- export declare const notifyName_vals: ("关闭轨道" | "网络情况变更" | "房间网络情况变更" | "心跳检测" | "网络质量回调" | "登录回调" | "房间用户变化" | "房间状态变化" | "加入房间回调" | "退出房间回调" | "监听到流发布" | "更新通讯状态" | "更新本地媒体流" | "ice断开" | "Token已过期" | "销毁房间" | "销毁")[];
27
+ export declare const notifyName_vals: ("关闭轨道" | "网络情况变更" | "房间网络情况变更" | "心跳检测" | "网络质量回调" | "登录回调" | "更新本地媒体流" | "房间用户变化" | "房间状态变化" | "加入房间回调" | "退出房间回调" | "监听到流发布" | "更新通讯状态" | "Token已过期" | "销毁房间" | "销毁")[];
@@ -2,8 +2,8 @@ export declare const enum_roomState: {
2
2
  readonly ready: "已就绪";
3
3
  readonly checkAuth: "正在鉴权";
4
4
  readonly connect: "连接中";
5
- readonly reconnect: "正在重新连接";
6
5
  readonly connected: "已连接";
6
+ readonly reconnect: "正在重新连接";
7
7
  readonly disconnected: "已断开";
8
8
  };
9
9
  export type T_roomState = typeof enum_roomState;
@@ -14,4 +14,4 @@ export declare const roomState_options: {
14
14
  label: any;
15
15
  }[];
16
16
  export declare const roomState_keys: (keyof typeof enum_roomState)[];
17
- export declare const roomState_vals: ("已就绪" | "正在鉴权" | "连接中" | "正在重新连接" | "已连接" | "已断开")[];
17
+ export declare const roomState_vals: ("已就绪" | "正在鉴权" | "连接中" | "已连接" | "正在重新连接" | "已断开")[];
package/dist/index.js CHANGED
@@ -704,40 +704,12 @@ const enum_mediaType = {
704
704
  screenSharing_audio: "屏幕共享-音频轨道"
705
705
  };
706
706
  at(enum_mediaType);
707
- const mediaType_keys = Object.keys(enum_mediaType), getTrackNamesFormTracks = (s, $ = [], u = "trackName") => {
708
- const A = [];
709
- for (const h of s) {
710
- const { type: k } = h;
711
- if ($.length === 0 || $.includes(k)) {
712
- const t = h[u];
713
- t && A.push(`${t}`);
714
- }
715
- }
716
- return A;
717
- }, getAverageVolume = (s, $) => {
718
- s.getByteFrequencyData($);
719
- let u = 0;
720
- for (let h = 0; h < $.length; h++)
721
- u += $[h];
722
- return Math.ceil(u / $.length);
723
- }, getCallAction = async (s) => {
724
- let $ = "";
725
- const u = (h) => s.findIndex(({ type: t, enabled: o = !0 }) => t === h && o) === -1 ? "0" : "1";
726
- return $ = `${u(0)}${$}`, $ = `${u(1)}${$}`, $ = `${u(2)}${$}`, $ = `${u(3)}${$}`, parseInt($, 2);
727
- }, getCallActionMap = (s = 0) => {
728
- const u = Number(s).toString(2).padStart(4, "0").split(""), [A, h, k, t] = u;
729
- return {
730
- microphoneCamera_audio: !!Number(t),
731
- microphoneCamera_video: !!Number(k),
732
- screenSharing_video: !!Number(h),
733
- screenSharing_audio: !!Number(A)
734
- };
735
- }, enum_roomState = {
707
+ const mediaType_keys = Object.keys(enum_mediaType), enum_roomState = {
736
708
  ready: "已就绪",
737
709
  checkAuth: "正在鉴权",
738
710
  connect: "连接中",
739
- reconnect: "正在重新连接",
740
711
  connected: "已连接",
712
+ reconnect: "正在重新连接",
741
713
  disconnected: "已断开"
742
714
  };
743
715
  at(enum_roomState);
@@ -4446,6 +4418,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
4446
4418
  healthCheck: "心跳检测",
4447
4419
  onNetQuality: "网络质量回调",
4448
4420
  onLogin: "登录回调",
4421
+ onLocalStream: "更新本地媒体流",
4449
4422
  onRoomUsers: "房间用户变化",
4450
4423
  onRoomState: "房间状态变化",
4451
4424
  onJoinRoom: "加入房间回调",
@@ -4453,8 +4426,6 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
4453
4426
  onPublish: "监听到流发布",
4454
4427
  onCloseTrack: "关闭轨道",
4455
4428
  onUpdateCall: "更新通讯状态",
4456
- onLocalStream: "更新本地媒体流",
4457
- onIceDisconnected: "ice断开",
4458
4429
  onTokenExpired: "Token已过期",
4459
4430
  destroyRoom: "销毁房间",
4460
4431
  onDestroy: "销毁"
@@ -6747,6 +6718,41 @@ class MediaStreams {
6747
6718
  });
6748
6719
  }
6749
6720
  }
6721
+ const getTrackNamesFormTracks = (s, $ = [], u = "trackName") => {
6722
+ const A = [];
6723
+ for (const h of s) {
6724
+ const { type: k } = h;
6725
+ if ($.length === 0 || $.includes(k)) {
6726
+ const t = h[u];
6727
+ t && A.push(`${t}`);
6728
+ }
6729
+ }
6730
+ return A;
6731
+ }, getAverageVolume = (s, $) => {
6732
+ s.getByteFrequencyData($);
6733
+ let u = 0;
6734
+ for (let h = 0; h < $.length; h++)
6735
+ u += $[h];
6736
+ return Math.ceil(u / $.length);
6737
+ }, getCallAction = async (s) => {
6738
+ let $ = "";
6739
+ const u = (h) => s.findIndex(({ type: t, enabled: o = !0 }) => t === h && o) === -1 ? "0" : "1";
6740
+ return $ = `${u(0)}${$}`, $ = `${u(1)}${$}`, $ = `${u(2)}${$}`, $ = `${u(3)}${$}`, parseInt($, 2);
6741
+ }, getCallActionMap = (s = 0) => {
6742
+ const u = Number(s).toString(2).padStart(4, "0").split(""), [A, h, k, t] = u;
6743
+ return {
6744
+ microphoneCamera_audio: !!Number(t),
6745
+ microphoneCamera_video: !!Number(k),
6746
+ screenSharing_video: !!Number(h),
6747
+ screenSharing_audio: !!Number(A)
6748
+ };
6749
+ }, tools = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6750
+ __proto__: null,
6751
+ getAverageVolume,
6752
+ getCallAction,
6753
+ getCallActionMap,
6754
+ getTrackNamesFormTracks
6755
+ }, Symbol.toStringTag, { value: "Module" }));
6750
6756
  class RoomBase extends MediaStreams {
6751
6757
  constructor() {
6752
6758
  super();
@@ -6758,12 +6764,11 @@ class RoomBase extends MediaStreams {
6758
6764
  callType: 0,
6759
6765
  autoSubscribe: !0
6760
6766
  });
6761
- W(this, "info", {
6762
- state: "",
6763
- // 房间状态
6764
- createAt: Date.now()
6765
- // 创建时间
6766
- });
6767
+ W(this, "tools", tools);
6768
+ W(this, "state", "ready");
6769
+ // 房间状态
6770
+ W(this, "createAt", Date.now());
6771
+ // 创建时间
6767
6772
  W(this, "cwsIns");
6768
6773
  // SDK通讯实例
6769
6774
  W(this, "loading", !1);
@@ -6778,20 +6783,17 @@ class RoomBase extends MediaStreams {
6778
6783
  /**
6779
6784
  * 获取房间信息
6780
6785
  */
6781
- W(this, "getRoomInfo", () => this.info);
6786
+ W(this, "getRoomInfo", () => {
6787
+ const { options: u, state: A, createAt: h } = this;
6788
+ return { ...u, state: A, createAt: h };
6789
+ });
6782
6790
  /**
6783
6791
  * 设置房间状态
6784
6792
  */
6785
6793
  W(this, "setRoomState", (u) => {
6786
- this.info.state = u;
6794
+ this.state = u;
6787
6795
  const A = enum_roomState[u], h = { state: u, stateStr: A };
6788
- this.cwsIns.emitNotify("onRoomState", h);
6789
- });
6790
- /**
6791
- * 设置房间信息
6792
- */
6793
- W(this, "setRoomInfo", (u) => {
6794
- this.info = { ...this.info, ...u };
6796
+ this.cwsIns.emitNotify("onRoomState", { code: 200, obj: h });
6795
6797
  });
6796
6798
  /**
6797
6799
  * 设置属性
@@ -6933,7 +6935,7 @@ class RoomUsers extends RoomBase {
6933
6935
  */
6934
6936
  W(this, "updateUserCallAction", async (u, A = 0) => {
6935
6937
  const h = await this.getUser(u);
6936
- h.callAction = A, h.callActionMap = getCallActionMap(A);
6938
+ h.callAction = A, h.callActionMap = this.tools.getCallActionMap(A);
6937
6939
  });
6938
6940
  /**
6939
6941
  * 更新用户网络信息
@@ -7377,7 +7379,7 @@ class RoomCalls extends RoomPeer {
7377
7379
  }
7378
7380
  }
7379
7381
  }
7380
- const D = [...t.tracks, ...o], L = await getCallAction(D), Z = async () => {
7382
+ const D = [...t.tracks, ...o], L = await this.tools.getCallAction(D), Z = async () => {
7381
7383
  this.setLoading(!1), await this.emitNotifyUpdateUsers();
7382
7384
  const H = await this.getCaller();
7383
7385
  h(H);
@@ -7420,7 +7422,7 @@ class RoomCalls extends RoomPeer {
7420
7422
  await this.cwsIns.sendMessage({ event: "closeTrack", data: { sdp: v.sdp, tracks: t } });
7421
7423
  }
7422
7424
  {
7423
- const v = await getCallAction(k.tracks);
7425
+ const v = await this.tools.getCallAction(k.tracks);
7424
7426
  await Y(this, kt).call(this, v);
7425
7427
  }
7426
7428
  await this.emitNotifyUpdateUsers(), o();
@@ -7561,7 +7563,7 @@ class RoomCalls extends RoomPeer {
7561
7563
  L.enabled = A;
7562
7564
  }
7563
7565
  }
7564
- const v = await getCallAction(o);
7566
+ const v = await this.tools.getCallAction(o);
7565
7567
  await Y(this, kt).call(this, v), await this.emitNotifyUpdateUsers();
7566
7568
  });
7567
7569
  /**
@@ -7619,7 +7621,7 @@ class RoomCalls extends RoomPeer {
7619
7621
  }
7620
7622
  {
7621
7623
  const u = async (A) => {
7622
- const { id: h, callAction: k } = A.data.user, t = await this.getUser(h), { tracks: o = [] } = t, v = await this.getUserStreams(h), N = getCallActionMap(k), q = [];
7624
+ const { id: h, callAction: k } = A.data.user, t = await this.getUser(h), { tracks: o = [] } = t, v = await this.getUserStreams(h), N = this.tools.getCallActionMap(k), q = [];
7623
7625
  for (const U of o) {
7624
7626
  const { type: D } = U, L = mediaType_keys[D], Z = N[L];
7625
7627
  if (D === 0) {
@@ -7649,7 +7651,7 @@ class RoomCalls extends RoomPeer {
7649
7651
  };
7650
7652
  this.cwsIns.addNotify({ event: "onUpdateCall", callback: u }, !0);
7651
7653
  }
7652
- this.cwsIns.addNotify({ event: "onTokenExpired", callback: async (u) => this.destroy() }, !0), this.cwsIns.addNotify({ event: "onDestroy", callback: this.destroy }, !0);
7654
+ this.cwsIns.addNotify({ event: "onTokenExpired", callback: async (u) => this.destroy() }, !0), this.cwsIns.addNotify({ event: "onDestroy", callback: this.destroy }, !0), this.cwsIns.addNotify({ event: "destroyRoom", callback: this.destroy }, !0);
7653
7655
  });
7654
7656
  /**
7655
7657
  * 更新自己通话状态
@@ -7683,7 +7685,7 @@ class RoomCalls extends RoomPeer {
7683
7685
  let k = 0;
7684
7686
  const t = async () => {
7685
7687
  this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: iceconnectionstatechange", this.peerIns.iceConnectionState), (this.peerIns.iceConnectionState === "disconnected" || this.peerIns.iceConnectionState === "failed") && setTimeout(() => {
7686
- this.setRoomState("disconnected"), this.cwsIns.emitNotify("onIceDisconnected", { code: 200, data: [] }), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} }), this.peerIns.removeEventListener("iceconnectionstatechange", t);
7688
+ this.setRoomState("disconnected"), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} }), this.peerIns.removeEventListener("iceconnectionstatechange", t);
7687
7689
  }, 10 * 1e3), this.peerIns.iceConnectionState === "connected" && (clearTimeout(k), u(!0));
7688
7690
  };
7689
7691
  this.peerIns.addEventListener("iceconnectionstatechange", t), k = setTimeout(() => {