quickvo-sdk-js 0.7.1 → 0.7.2
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
|
@@ -732,6 +732,7 @@ class AudioMediaContext {
|
|
|
732
732
|
// 音量
|
|
733
733
|
Z(this, "enhanceGain", 0);
|
|
734
734
|
// 音量增强
|
|
735
|
+
Z(this, "audio", new Audio());
|
|
735
736
|
// @ts-ignore 音频上下文
|
|
736
737
|
Z(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
|
|
737
738
|
// 媒体流音频源节点
|
|
@@ -748,9 +749,8 @@ class AudioMediaContext {
|
|
|
748
749
|
Z(this, "analyserNode");
|
|
749
750
|
// 缓冲区 存储分析节点的时域数据
|
|
750
751
|
Z(this, "analyserArrayData");
|
|
751
|
-
// 初始化节点
|
|
752
752
|
Z(this, "initNode", () => {
|
|
753
|
-
this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.autoGainNode = this.audioContext.createGain(), this.autoGainNode.gain.setValueAtTime(0.8, this.audioContext.currentTime), this.biquadFilterNode = this.audioContext.createBiquadFilter(), this.biquadFilterNode.type = "lowpass", this.biquadFilterNode.frequency.value = 1e3, this.delayNode = this.audioContext.createDelay(), this.delayNode.delayTime.value = 0.5, this.gainNode = this.audioContext.createGain(), this.gainNode.gain.setValueAtTime(this.gain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
|
|
753
|
+
this.audio.srcObject = this.stream, this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.autoGainNode = this.audioContext.createGain(), this.autoGainNode.gain.setValueAtTime(0.8, this.audioContext.currentTime), this.biquadFilterNode = this.audioContext.createBiquadFilter(), this.biquadFilterNode.type = "lowpass", this.biquadFilterNode.frequency.value = 1e3, this.delayNode = this.audioContext.createDelay(), this.delayNode.delayTime.value = 0.5, this.gainNode = this.audioContext.createGain(), this.gainNode.gain.setValueAtTime(this.gain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
|
|
754
754
|
const { gainNode: I, analyserNode: a } = this;
|
|
755
755
|
I.connect(a), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
|
|
756
756
|
});
|
|
@@ -824,7 +824,7 @@ class AudioMediaContext {
|
|
|
824
824
|
let N = k;
|
|
825
825
|
return a && N.connect(e), E && N.connect(n), _ && N.connect(O), N.connect($), I;
|
|
826
826
|
});
|
|
827
|
-
this.stream.addTrack(I), this.
|
|
827
|
+
this.stream.addTrack(I), this.initNode();
|
|
828
828
|
}
|
|
829
829
|
}
|
|
830
830
|
class VideoMediaContext {
|
|
@@ -7185,7 +7185,7 @@ const noLogEvents = ["heartbeat", "onNetQuality", "networkQualityChange"], compr
|
|
|
7185
7185
|
}
|
|
7186
7186
|
return u;
|
|
7187
7187
|
};
|
|
7188
|
-
var wt, dt, xt, yt,
|
|
7188
|
+
var wt, dt, xt, yt, bt, Mt, Pt, Lt, Bt, Nt, jt, Zt, Ft;
|
|
7189
7189
|
class CallsWebSocket {
|
|
7190
7190
|
// 状态
|
|
7191
7191
|
constructor(I) {
|
|
@@ -7202,7 +7202,7 @@ class CallsWebSocket {
|
|
|
7202
7202
|
lt(this, xt, "");
|
|
7203
7203
|
// 缓存登录凭证
|
|
7204
7204
|
lt(this, yt, {});
|
|
7205
|
-
lt(this,
|
|
7205
|
+
lt(this, bt, {});
|
|
7206
7206
|
Z(this, "state", "closed");
|
|
7207
7207
|
// 外部 发送消息之前
|
|
7208
7208
|
Z(this, "sendMessageBefore", async () => {
|
|
@@ -7324,7 +7324,7 @@ class CallsWebSocket {
|
|
|
7324
7324
|
getHeartbeatMsg: Q(this, Bt),
|
|
7325
7325
|
onReconnectSuccess: Q(this, Pt),
|
|
7326
7326
|
onReconnectStop: Q(this, Lt)
|
|
7327
|
-
})), this.state = "connecting", await Q(this, wt).connect(), this.state = "connected", Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", Q(this,
|
|
7327
|
+
})), this.state = "connecting", await Q(this, wt).connect(), this.state = "connected", Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", Q(this, bt)), a(Q(this, wt));
|
|
7328
7328
|
}));
|
|
7329
7329
|
/**
|
|
7330
7330
|
* 关闭
|
|
@@ -7365,7 +7365,7 @@ class CallsWebSocket {
|
|
|
7365
7365
|
* @param result 事件响应值
|
|
7366
7366
|
*/
|
|
7367
7367
|
Z(this, "emitNotify", async (I, a) => {
|
|
7368
|
-
const E = Q(this,
|
|
7368
|
+
const E = Q(this, bt)[I] || [];
|
|
7369
7369
|
for (const _ of E) {
|
|
7370
7370
|
const { callback: k = async () => {
|
|
7371
7371
|
} } = _;
|
|
@@ -7380,8 +7380,8 @@ class CallsWebSocket {
|
|
|
7380
7380
|
*/
|
|
7381
7381
|
Z(this, "addNotify", (I, a = !1) => {
|
|
7382
7382
|
const { event: E, sn: _ = ht(32) } = I;
|
|
7383
|
-
Q(this,
|
|
7384
|
-
const k = Q(this,
|
|
7383
|
+
Q(this, bt)[E] || (Q(this, bt)[E] = []);
|
|
7384
|
+
const k = Q(this, bt)[E], e = k.findIndex((n) => n.sn === _);
|
|
7385
7385
|
return e !== -1 && k.splice(e, 1), a ? k.unshift(I) : k.push(I), _;
|
|
7386
7386
|
});
|
|
7387
7387
|
/**
|
|
@@ -7389,18 +7389,18 @@ class CallsWebSocket {
|
|
|
7389
7389
|
*/
|
|
7390
7390
|
Z(this, "removeNotify", (I = []) => {
|
|
7391
7391
|
if (I.length === 0)
|
|
7392
|
-
St(this,
|
|
7392
|
+
St(this, bt, {});
|
|
7393
7393
|
else {
|
|
7394
|
-
const a = Object.keys(Q(this,
|
|
7394
|
+
const a = Object.keys(Q(this, bt));
|
|
7395
7395
|
for (const E of a)
|
|
7396
|
-
Q(this,
|
|
7396
|
+
Q(this, bt)[E] = Q(this, bt)[E].filter((_) => !I.includes(_.sn || ""));
|
|
7397
7397
|
}
|
|
7398
|
-
Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", Q(this,
|
|
7398
|
+
Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", Q(this, bt));
|
|
7399
7399
|
});
|
|
7400
7400
|
St(this, dt, { ...Q(this, dt), ...I });
|
|
7401
7401
|
}
|
|
7402
7402
|
}
|
|
7403
|
-
wt = new WeakMap(), dt = new WeakMap(), xt = new WeakMap(), yt = new WeakMap(),
|
|
7403
|
+
wt = new WeakMap(), dt = new WeakMap(), xt = new WeakMap(), yt = new WeakMap(), bt = new WeakMap(), Mt = new WeakMap(), Pt = new WeakMap(), Lt = new WeakMap(), Bt = new WeakMap(), Nt = new WeakMap(), jt = new WeakMap(), Zt = new WeakMap(), Ft = new WeakMap();
|
|
7404
7404
|
var y = Object.defineProperty, x = (u) => {
|
|
7405
7405
|
throw TypeError(u);
|
|
7406
7406
|
}, g = (u, I, a) => I in u ? y(u, I, { enumerable: !0, configurable: !0, writable: !0, value: a }) : u[I] = a, h = (u, I, a) => g(u, typeof I != "symbol" ? I + "" : I, a), b = (u, I, a) => I.has(u) || x("Cannot " + a), o = (u, I, a) => (b(u, I, "read from private field"), a ? a.call(u) : I.get(u)), f = (u, I, a) => I.has(u) ? x("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(u) : I.set(u, a), p = (u, I, a, E) => (b(u, I, "write to private field"), I.set(u, a), a), d, c, l;
|
|
@@ -7637,14 +7637,14 @@ class RoomBase {
|
|
|
7637
7637
|
}
|
|
7638
7638
|
}
|
|
7639
7639
|
Ht = new WeakMap();
|
|
7640
|
-
var It,
|
|
7640
|
+
var It, kt, _t, vt, gt, zt, Jt, Rt, Wt;
|
|
7641
7641
|
class RoomMedias extends RoomBase {
|
|
7642
7642
|
// 本地流活动状态管理
|
|
7643
7643
|
constructor(a) {
|
|
7644
7644
|
super(a);
|
|
7645
7645
|
lt(this, It, []);
|
|
7646
7646
|
// 可用媒体设备列表
|
|
7647
|
-
lt(this,
|
|
7647
|
+
lt(this, kt, /* @__PURE__ */ new Map());
|
|
7648
7648
|
// 媒体流设备管理
|
|
7649
7649
|
lt(this, _t, /* @__PURE__ */ new Map());
|
|
7650
7650
|
// 媒体轨道参数管理
|
|
@@ -7663,7 +7663,7 @@ class RoomMedias extends RoomBase {
|
|
|
7663
7663
|
* 初始化媒体设备类型
|
|
7664
7664
|
*/
|
|
7665
7665
|
lt(this, Jt, () => {
|
|
7666
|
-
Q(this,
|
|
7666
|
+
Q(this, kt).set("audioinput", "default"), Q(this, kt).set("videoinput", "default"), Q(this, kt).set("audiooutput", "default");
|
|
7667
7667
|
});
|
|
7668
7668
|
/**
|
|
7669
7669
|
* 房间所有用户所有媒体流变化
|
|
@@ -7703,7 +7703,7 @@ class RoomMedias extends RoomBase {
|
|
|
7703
7703
|
const $ = this.getUserMediaStreamContext(a, E);
|
|
7704
7704
|
if ($ && $.kind === "audio")
|
|
7705
7705
|
try {
|
|
7706
|
-
const N = Q(this,
|
|
7706
|
+
const N = Q(this, kt).get("audiooutput");
|
|
7707
7707
|
(O = $.audioContext) == null || O.setSinkId(N);
|
|
7708
7708
|
} catch (N) {
|
|
7709
7709
|
console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error", N);
|
|
@@ -7802,21 +7802,21 @@ class RoomMedias extends RoomBase {
|
|
|
7802
7802
|
// 麦克风
|
|
7803
7803
|
case "microphoneCamera_audio":
|
|
7804
7804
|
{
|
|
7805
|
-
const E = Q(this,
|
|
7805
|
+
const E = Q(this, kt).get("audioinput"), _ = Q(this, _t).get("microphoneCamera_audio"), k = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: E, ..._ }, video: !1 });
|
|
7806
7806
|
this.addLocalStream("microphoneCamera_audio", k);
|
|
7807
7807
|
}
|
|
7808
7808
|
break;
|
|
7809
7809
|
// 摄像头
|
|
7810
7810
|
case "microphoneCamera_video":
|
|
7811
7811
|
{
|
|
7812
|
-
const E = Q(this,
|
|
7812
|
+
const E = Q(this, kt).get("videoinput"), _ = Q(this, _t).get("microphoneCamera_video"), k = await navigator.mediaDevices.getUserMedia({ audio: !1, video: { deviceId: E, ..._ } });
|
|
7813
7813
|
this.addLocalStream("microphoneCamera_video", k);
|
|
7814
7814
|
}
|
|
7815
7815
|
break;
|
|
7816
7816
|
// 麦克风 + 摄像头
|
|
7817
7817
|
case "microphoneCamera":
|
|
7818
7818
|
{
|
|
7819
|
-
const E = Q(this,
|
|
7819
|
+
const E = Q(this, kt).get("audioinput"), _ = Q(this, kt).get("videoinput"), k = Q(this, _t).get("microphoneCamera_audio"), e = Q(this, _t).get("microphoneCamera_video"), O = (await navigator.mediaDevices.getUserMedia({ audio: { deviceId: E, ...k }, video: { deviceId: _, ...e } })).getTracks();
|
|
7820
7820
|
for (const $ of O) {
|
|
7821
7821
|
const { kind: N } = $;
|
|
7822
7822
|
if (N === "audio") {
|
|
@@ -7910,18 +7910,18 @@ class RoomMedias extends RoomBase {
|
|
|
7910
7910
|
* @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
|
|
7911
7911
|
* @returns deviceId 设备ID
|
|
7912
7912
|
*/
|
|
7913
|
-
Z(this, "getMediaDeviceKind", (a) => Q(this,
|
|
7913
|
+
Z(this, "getMediaDeviceKind", (a) => Q(this, kt).get(a));
|
|
7914
7914
|
/**
|
|
7915
7915
|
* 更改音频输出
|
|
7916
7916
|
*/
|
|
7917
7917
|
Z(this, "changeAudiooutput", () => {
|
|
7918
|
-
const a = Q(this, vt).values();
|
|
7919
|
-
for (const
|
|
7920
|
-
if (
|
|
7918
|
+
const a = Q(this, kt).get("audiooutput"), E = Q(this, vt).values();
|
|
7919
|
+
for (const _ of E)
|
|
7920
|
+
if (_.kind === "audio" && "setSinkId" in HTMLMediaElement.prototype)
|
|
7921
7921
|
try {
|
|
7922
|
-
|
|
7923
|
-
} catch (
|
|
7924
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error.",
|
|
7922
|
+
_.audioContext.setSinkId(a);
|
|
7923
|
+
} catch (k) {
|
|
7924
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error.", k);
|
|
7925
7925
|
}
|
|
7926
7926
|
});
|
|
7927
7927
|
/**
|
|
@@ -7930,7 +7930,7 @@ class RoomMedias extends RoomBase {
|
|
|
7930
7930
|
* @param deviceId 设备ID
|
|
7931
7931
|
*/
|
|
7932
7932
|
Z(this, "setDeviceKind", (a, E) => {
|
|
7933
|
-
Q(this,
|
|
7933
|
+
Q(this, kt).set(a, E);
|
|
7934
7934
|
});
|
|
7935
7935
|
/**
|
|
7936
7936
|
* 设置音频输出设备
|
|
@@ -7962,7 +7962,7 @@ class RoomMedias extends RoomBase {
|
|
|
7962
7962
|
Q(this, Wt).call(this), Q(this, Jt).call(this), Q(this, zt).call(this);
|
|
7963
7963
|
}
|
|
7964
7964
|
}
|
|
7965
|
-
It = new WeakMap(),
|
|
7965
|
+
It = new WeakMap(), kt = new WeakMap(), _t = new WeakMap(), vt = new WeakMap(), gt = new WeakMap(), zt = new WeakMap(), Jt = new WeakMap(), Rt = new WeakMap(), Wt = new WeakMap();
|
|
7966
7966
|
class RoomUsers extends RoomMedias {
|
|
7967
7967
|
constructor(a) {
|
|
7968
7968
|
super(a);
|