zann-voice 0.1.15 → 0.1.16
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 +24 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +3 -2
package/README.md
CHANGED
|
@@ -128,4 +128,27 @@ voice.connect({
|
|
|
128
128
|
| granted | string | 用户已经授权 |
|
|
129
129
|
| denied | string | 用户明确拒绝 |
|
|
130
130
|
| prompt | string | 尚未询问 |
|
|
131
|
-
| unknown | string | 无法获取状态 |
|
|
131
|
+
| unknown | string | 无法获取状态 |
|
|
132
|
+
|
|
133
|
+
### **8.analyzeFrequency() 麦克风频谱分析辅助方法**
|
|
134
|
+
> 此方法可以辅助分析onMicrophoneChange 的获取麦克风音频频谱
|
|
135
|
+
> <br/>必须在onMicrophoneChange 调用
|
|
136
|
+
|
|
137
|
+
| 属性 | 类型 |备注 |
|
|
138
|
+
| ------------- | :-----------: | :-----------: |
|
|
139
|
+
| stream | MediaStream | onMicrophoneChange中的回调的参数 |
|
|
140
|
+
| fftSize | number | 决定频谱分辨率,可调 512-32768 |
|
|
141
|
+
| callback | (wave: Uint8Array, freq: Uint8Array) => void | 实时回调 |
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
onMicrophoneChange: (state: boolean, stream: MediaStream | null) => {
|
|
145
|
+
if (state && stream) {
|
|
146
|
+
analyzeFrequency({
|
|
147
|
+
stream, callback(wave, freq) {
|
|
148
|
+
console.log("wave", wave); // 波形
|
|
149
|
+
console.log("freq", freq); // 频谱
|
|
150
|
+
},
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
```
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(o,e,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?o!==e||!a:!e.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(o):a?a.value:e.get(o)}function s(o,e,i,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?o!==e||!c:!e.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(o,i):c?c.value=i:e.set(o,i),i}typeof SuppressedError=="function"&&SuppressedError;var h,n,r,f,k,
|
|
1
|
+
"use strict";function t(o,e,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?o!==e||!a:!e.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(o):a?a.value:e.get(o)}function s(o,e,i,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?o!==e||!c:!e.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(o,i):c?c.value=i:e.set(o,i),i}typeof SuppressedError=="function"&&SuppressedError;var h,n,r,f,g,k,_,m,y,S,C,p,d,E,b,V,A,Z,u,w,R,N,P,D,W,q,x;class z{constructor({wss:e,TURN:i,maxReconnect:a=5}){h.add(this),n.set(this,null),r.set(this,null),f.set(this,null),g.set(this,!1),k.set(this,!1),_.set(this,0),m.set(this,5),y.set(this,!1),S.set(this,""),C.set(this,{urls:""}),p.set(this,null),d.set(this,null),E.set(this,void 0),b.set(this,void 0),V.set(this,void 0),A.set(this,void 0),Z.set(this,void 0),u.set(this,void 0),w.set(this,void 0),s(this,S,e,"f"),s(this,C,i,"f"),s(this,m,a,"f")}async connect({media:e={audio:!0,video:!1},onOpen:i,onTrack:a,onError:c,onMessage:O,onAuth:M,onMicrophoneChange:T,onCameraChange:v}){if(t(this,g,"f")){console.warn("\u26A0\uFE0F \u5DF2\u7ECF\u5B58\u5728 RTC/WS\uFF0C\u4E0D\u91CD\u590D\u521B\u5EFA");return}s(this,k,!1,"f"),s(this,y,!1,"f"),s(this,_,0,"f"),s(this,E,i,"f"),s(this,b,a,"f"),s(this,V,c,"f"),s(this,A,O,"f"),s(this,Z,M,"f"),s(this,u,T,"f"),s(this,w,v,"f"),s(this,n,new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},t(this,C,"f")]}),"f"),t(this,n,"f").onicecandidate=l=>{l.candidate&&t(this,r,"f")?.readyState===WebSocket.OPEN&&t(this,r,"f").send(JSON.stringify({type:"ice",data:l.candidate}))},t(this,n,"f").ontrack=l=>t(this,b,"f").call(this,l),t(this,n,"f").onconnectionstatechange=()=>{const l=t(this,n,"f")?.connectionState;console.log("RTC connection state:",l),!t(this,k,"f")&&(l==="disconnected"||l==="failed")&&(console.warn("RTC disconnected, retrying offer..."),t(this,h,"m",W).call(this))},t(this,h,"m",R).call(this),e.audio&&await this.startMicrophone(),e.video&&await this.startCamera()}async startMicrophone(){if(!t(this,n,"f")){console.warn("\u274C startMic \u9700\u8981\u5148\u8C03\u7528 create()");return}if(!t(this,f,"f")?.getAudioTracks().length)try{const e=await navigator.mediaDevices.getUserMedia({audio:!0});e.getAudioTracks().forEach(i=>t(this,n,"f").addTrack(i,e)),t(this,f,"f")||s(this,f,new MediaStream,"f"),e.getAudioTracks().forEach(i=>t(this,f,"f").addTrack(i)),t(this,h,"m",W).call(this),t(this,u,"f")&&t(this,u,"f").call(this,!0,e)}catch(e){t(this,Z,"f").call(this,e),t(this,u,"f")&&t(this,u,"f").call(this,!1,null),t(this,h,"m",D).call(this)}}analyzeFrequency({stream:e,fftSize:i=2048,callback:a}){s(this,d,new AudioContext,"f");const c=t(this,d,"f").createAnalyser();c.fftSize=i,c.smoothingTimeConstant=.8,t(this,d,"f").createMediaStreamSource(e).connect(c);const M=new Uint8Array(c.fftSize),T=new Uint8Array(c.frequencyBinCount),v=this;function l(){t(v,d,"f")&&(c.getByteTimeDomainData(M),c.getByteFrequencyData(T),t(v,g,"f")&&a(M,T),requestAnimationFrame(l))}l()}stopMicrophone(){t(this,f,"f")&&(t(this,f,"f").getAudioTracks().forEach(e=>{e.stop();const i=t(this,n,"f")?.getSenders().find(a=>a.track===e);i&&t(this,n,"f")?.removeTrack(i)}),t(this,u,"f")&&t(this,u,"f").call(this,!1,null),t(this,h,"m",D).call(this))}async startCamera(){if(!t(this,n,"f")){console.warn("\u274C startCamera \u9700\u8981\u5148\u8C03\u7528 create()");return}if(!t(this,f,"f")?.getVideoTracks().length)try{const e=await navigator.mediaDevices.getUserMedia({video:!0});e.getVideoTracks().forEach(i=>t(this,n,"f").addTrack(i,e)),t(this,f,"f")||s(this,f,new MediaStream,"f"),e.getVideoTracks().forEach(i=>t(this,f,"f").addTrack(i)),t(this,h,"m",W).call(this),t(this,w,"f")&&t(this,w,"f").call(this,!0,e)}catch(e){t(this,Z,"f").call(this,e),t(this,w,"f")&&t(this,w,"f").call(this,!1,null)}}stopCamera(){t(this,f,"f")&&(t(this,f,"f").getVideoTracks().forEach(e=>{e.stop();const i=t(this,n,"f")?.getSenders().find(a=>a.track===e);i&&t(this,n,"f")?.removeTrack(i)}),t(this,w,"f")&&t(this,w,"f").call(this,!1,null))}destroy(){console.log("\u{1F6D1} Destroying ZannVoice..."),s(this,k,!0,"f"),this.stopMicrophone(),this.stopCamera(),t(this,h,"m",q).call(this),t(this,h,"m",x).call(this),s(this,g,!1,"f"),clearInterval(t(this,p,"f")),s(this,p,null,"f"),s(this,y,!1,"f")}async authorize(){if(!navigator.permissions)return{microphone:"unknown",camera:"unknown"};const e=async c=>{try{return(await navigator.permissions.query({name:c})).state}catch{return"unknown"}},i=await e("microphone"),a=await e("camera");return{microphone:i,camera:a}}}n=new WeakMap,r=new WeakMap,f=new WeakMap,g=new WeakMap,k=new WeakMap,_=new WeakMap,m=new WeakMap,y=new WeakMap,S=new WeakMap,C=new WeakMap,p=new WeakMap,d=new WeakMap,E=new WeakMap,b=new WeakMap,V=new WeakMap,A=new WeakMap,Z=new WeakMap,u=new WeakMap,w=new WeakMap,h=new WeakSet,R=function o(e=1e3){t(this,S,"f")&&(s(this,r,new WebSocket(t(this,S,"f")),"f"),t(this,r,"f").onopen=()=>{console.log("\u2705 WS connected"),s(this,y,!0,"f"),s(this,_,0,"f"),t(this,n,"f")?.connectionState!=="connected"&&t(this,h,"m",W).call(this)},t(this,r,"f").onmessage=i=>t(this,h,"m",P).call(this,i),t(this,r,"f").onerror=i=>{t(this,y,"f")&&t(this,V,"f").call(this,i)},t(this,r,"f").onclose=()=>{var i;if(!t(this,k,"f")){if(t(this,_,"f")>=t(this,m,"f")){console.error(`\u274C WS \u8D85\u8FC7\u6700\u5927\u91CD\u8FDE\u6B21\u6570 ${t(this,m,"f")}`),t(this,V,"f")?.call(this,new Error(`WS exceeded max reconnects ${t(this,m,"f")}`)),s(this,y,!1,"f");return}s(this,_,(i=t(this,_,"f"),i++,i),"f"),console.warn(`\u{1F504} WS disconnected, retrying in ${e}ms... [${t(this,_,"f")}/${t(this,m,"f")}]`),setTimeout(()=>t(this,h,"m",o).call(this,Math.min(e*2,1e4)),e)}})},N=function(){t(this,p,"f")!=null&&(clearInterval(t(this,p,"f")),s(this,p,null,"f")),s(this,p,setInterval(()=>{t(this,r,"f")?.send(JSON.stringify({type:"heartbeat",data:"1"}))},3e3),"f")},P=async function(e){const i=JSON.parse(e.data);switch(i.type){case"answer":await t(this,n,"f")?.setRemoteDescription(i.data),t(this,E,"f").call(this),t(this,h,"m",N).call(this),s(this,g,!0,"f");break;case"ice":await t(this,n,"f")?.addIceCandidate(i.data);break;case"offer":await t(this,n,"f")?.setRemoteDescription(i.data);const a=await t(this,n,"f")?.createAnswer();a&&(await t(this,n,"f")?.setLocalDescription(a),t(this,r,"f")?.send(JSON.stringify({type:"answer",data:a})));break;default:t(this,A,"f").call(this,e);break}},D=function(){t(this,d,"f")&&(t(this,d,"f").close(),s(this,d,null,"f"))},W=async function(){if(!t(this,n,"f")||!t(this,r,"f")||t(this,r,"f").readyState!==WebSocket.OPEN)return;const e=await t(this,n,"f").createOffer();await t(this,n,"f").setLocalDescription(e),t(this,r,"f").send(JSON.stringify({type:"offer",data:e}))},q=function(){t(this,n,"f")?.getSenders().forEach(e=>e.track?.stop()),t(this,n,"f")?.close(),s(this,n,null,"f")},x=function(){t(this,r,"f")&&t(this,r,"f").readyState===WebSocket.OPEN&&t(this,r,"f").close(),s(this,r,null,"f")},module.exports=z;
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(o,e,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?o!==e||!a:!e.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(o):a?a.value:e.get(o)}function s(o,e,i,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?o!==e||!c:!e.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(o,i):c?c.value=i:e.set(o,i),i}typeof SuppressedError=="function"&&SuppressedError;var h,n,r,f,k,
|
|
1
|
+
function t(o,e,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?o!==e||!a:!e.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(o):a?a.value:e.get(o)}function s(o,e,i,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?o!==e||!c:!e.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(o,i):c?c.value=i:e.set(o,i),i}typeof SuppressedError=="function"&&SuppressedError;var h,n,r,f,g,k,_,m,y,S,C,p,d,E,b,V,A,Z,u,w,R,N,P,D,W,q,x;class z{constructor({wss:e,TURN:i,maxReconnect:a=5}){h.add(this),n.set(this,null),r.set(this,null),f.set(this,null),g.set(this,!1),k.set(this,!1),_.set(this,0),m.set(this,5),y.set(this,!1),S.set(this,""),C.set(this,{urls:""}),p.set(this,null),d.set(this,null),E.set(this,void 0),b.set(this,void 0),V.set(this,void 0),A.set(this,void 0),Z.set(this,void 0),u.set(this,void 0),w.set(this,void 0),s(this,S,e,"f"),s(this,C,i,"f"),s(this,m,a,"f")}async connect({media:e={audio:!0,video:!1},onOpen:i,onTrack:a,onError:c,onMessage:O,onAuth:M,onMicrophoneChange:T,onCameraChange:v}){if(t(this,g,"f")){console.warn("\u26A0\uFE0F \u5DF2\u7ECF\u5B58\u5728 RTC/WS\uFF0C\u4E0D\u91CD\u590D\u521B\u5EFA");return}s(this,k,!1,"f"),s(this,y,!1,"f"),s(this,_,0,"f"),s(this,E,i,"f"),s(this,b,a,"f"),s(this,V,c,"f"),s(this,A,O,"f"),s(this,Z,M,"f"),s(this,u,T,"f"),s(this,w,v,"f"),s(this,n,new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},t(this,C,"f")]}),"f"),t(this,n,"f").onicecandidate=l=>{l.candidate&&t(this,r,"f")?.readyState===WebSocket.OPEN&&t(this,r,"f").send(JSON.stringify({type:"ice",data:l.candidate}))},t(this,n,"f").ontrack=l=>t(this,b,"f").call(this,l),t(this,n,"f").onconnectionstatechange=()=>{const l=t(this,n,"f")?.connectionState;console.log("RTC connection state:",l),!t(this,k,"f")&&(l==="disconnected"||l==="failed")&&(console.warn("RTC disconnected, retrying offer..."),t(this,h,"m",W).call(this))},t(this,h,"m",R).call(this),e.audio&&await this.startMicrophone(),e.video&&await this.startCamera()}async startMicrophone(){if(!t(this,n,"f")){console.warn("\u274C startMic \u9700\u8981\u5148\u8C03\u7528 create()");return}if(!t(this,f,"f")?.getAudioTracks().length)try{const e=await navigator.mediaDevices.getUserMedia({audio:!0});e.getAudioTracks().forEach(i=>t(this,n,"f").addTrack(i,e)),t(this,f,"f")||s(this,f,new MediaStream,"f"),e.getAudioTracks().forEach(i=>t(this,f,"f").addTrack(i)),t(this,h,"m",W).call(this),t(this,u,"f")&&t(this,u,"f").call(this,!0,e)}catch(e){t(this,Z,"f").call(this,e),t(this,u,"f")&&t(this,u,"f").call(this,!1,null),t(this,h,"m",D).call(this)}}analyzeFrequency({stream:e,fftSize:i=2048,callback:a}){s(this,d,new AudioContext,"f");const c=t(this,d,"f").createAnalyser();c.fftSize=i,c.smoothingTimeConstant=.8,t(this,d,"f").createMediaStreamSource(e).connect(c);const M=new Uint8Array(c.fftSize),T=new Uint8Array(c.frequencyBinCount),v=this;function l(){t(v,d,"f")&&(c.getByteTimeDomainData(M),c.getByteFrequencyData(T),t(v,g,"f")&&a(M,T),requestAnimationFrame(l))}l()}stopMicrophone(){t(this,f,"f")&&(t(this,f,"f").getAudioTracks().forEach(e=>{e.stop();const i=t(this,n,"f")?.getSenders().find(a=>a.track===e);i&&t(this,n,"f")?.removeTrack(i)}),t(this,u,"f")&&t(this,u,"f").call(this,!1,null),t(this,h,"m",D).call(this))}async startCamera(){if(!t(this,n,"f")){console.warn("\u274C startCamera \u9700\u8981\u5148\u8C03\u7528 create()");return}if(!t(this,f,"f")?.getVideoTracks().length)try{const e=await navigator.mediaDevices.getUserMedia({video:!0});e.getVideoTracks().forEach(i=>t(this,n,"f").addTrack(i,e)),t(this,f,"f")||s(this,f,new MediaStream,"f"),e.getVideoTracks().forEach(i=>t(this,f,"f").addTrack(i)),t(this,h,"m",W).call(this),t(this,w,"f")&&t(this,w,"f").call(this,!0,e)}catch(e){t(this,Z,"f").call(this,e),t(this,w,"f")&&t(this,w,"f").call(this,!1,null)}}stopCamera(){t(this,f,"f")&&(t(this,f,"f").getVideoTracks().forEach(e=>{e.stop();const i=t(this,n,"f")?.getSenders().find(a=>a.track===e);i&&t(this,n,"f")?.removeTrack(i)}),t(this,w,"f")&&t(this,w,"f").call(this,!1,null))}destroy(){console.log("\u{1F6D1} Destroying ZannVoice..."),s(this,k,!0,"f"),this.stopMicrophone(),this.stopCamera(),t(this,h,"m",q).call(this),t(this,h,"m",x).call(this),s(this,g,!1,"f"),clearInterval(t(this,p,"f")),s(this,p,null,"f"),s(this,y,!1,"f")}async authorize(){if(!navigator.permissions)return{microphone:"unknown",camera:"unknown"};const e=async c=>{try{return(await navigator.permissions.query({name:c})).state}catch{return"unknown"}},i=await e("microphone"),a=await e("camera");return{microphone:i,camera:a}}}n=new WeakMap,r=new WeakMap,f=new WeakMap,g=new WeakMap,k=new WeakMap,_=new WeakMap,m=new WeakMap,y=new WeakMap,S=new WeakMap,C=new WeakMap,p=new WeakMap,d=new WeakMap,E=new WeakMap,b=new WeakMap,V=new WeakMap,A=new WeakMap,Z=new WeakMap,u=new WeakMap,w=new WeakMap,h=new WeakSet,R=function o(e=1e3){t(this,S,"f")&&(s(this,r,new WebSocket(t(this,S,"f")),"f"),t(this,r,"f").onopen=()=>{console.log("\u2705 WS connected"),s(this,y,!0,"f"),s(this,_,0,"f"),t(this,n,"f")?.connectionState!=="connected"&&t(this,h,"m",W).call(this)},t(this,r,"f").onmessage=i=>t(this,h,"m",P).call(this,i),t(this,r,"f").onerror=i=>{t(this,y,"f")&&t(this,V,"f").call(this,i)},t(this,r,"f").onclose=()=>{var i;if(!t(this,k,"f")){if(t(this,_,"f")>=t(this,m,"f")){console.error(`\u274C WS \u8D85\u8FC7\u6700\u5927\u91CD\u8FDE\u6B21\u6570 ${t(this,m,"f")}`),t(this,V,"f")?.call(this,new Error(`WS exceeded max reconnects ${t(this,m,"f")}`)),s(this,y,!1,"f");return}s(this,_,(i=t(this,_,"f"),i++,i),"f"),console.warn(`\u{1F504} WS disconnected, retrying in ${e}ms... [${t(this,_,"f")}/${t(this,m,"f")}]`),setTimeout(()=>t(this,h,"m",o).call(this,Math.min(e*2,1e4)),e)}})},N=function(){t(this,p,"f")!=null&&(clearInterval(t(this,p,"f")),s(this,p,null,"f")),s(this,p,setInterval(()=>{t(this,r,"f")?.send(JSON.stringify({type:"heartbeat",data:"1"}))},3e3),"f")},P=async function(e){const i=JSON.parse(e.data);switch(i.type){case"answer":await t(this,n,"f")?.setRemoteDescription(i.data),t(this,E,"f").call(this),t(this,h,"m",N).call(this),s(this,g,!0,"f");break;case"ice":await t(this,n,"f")?.addIceCandidate(i.data);break;case"offer":await t(this,n,"f")?.setRemoteDescription(i.data);const a=await t(this,n,"f")?.createAnswer();a&&(await t(this,n,"f")?.setLocalDescription(a),t(this,r,"f")?.send(JSON.stringify({type:"answer",data:a})));break;default:t(this,A,"f").call(this,e);break}},D=function(){t(this,d,"f")&&(t(this,d,"f").close(),s(this,d,null,"f"))},W=async function(){if(!t(this,n,"f")||!t(this,r,"f")||t(this,r,"f").readyState!==WebSocket.OPEN)return;const e=await t(this,n,"f").createOffer();await t(this,n,"f").setLocalDescription(e),t(this,r,"f").send(JSON.stringify({type:"offer",data:e}))},q=function(){t(this,n,"f")?.getSenders().forEach(e=>e.track?.stop()),t(this,n,"f")?.close(),s(this,n,null,"f")},x=function(){t(this,r,"f")&&t(this,r,"f").readyState===WebSocket.OPEN&&t(this,r,"f").close(),s(this,r,null,"f")};export{z as default};
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export type voice = {
|
|
|
8
8
|
onError: (event: any) => void;
|
|
9
9
|
onMessage: (event: any) => void;
|
|
10
10
|
onAuth: (event: any) => void;
|
|
11
|
-
onMicrophoneChange?: (state: boolean,
|
|
12
|
-
onCameraChange?: (state: boolean,
|
|
11
|
+
onMicrophoneChange?: (state: boolean, stream: MediaStream | null) => void;
|
|
12
|
+
onCameraChange?: (state: boolean, stream: MediaStream | null) => void;
|
|
13
13
|
};
|
|
14
14
|
export type analyze = {
|
|
15
15
|
stream: MediaStream;
|
|
@@ -52,6 +52,7 @@ declare class ZannVoice {
|
|
|
52
52
|
startMicrophone(): Promise<void>;
|
|
53
53
|
/**
|
|
54
54
|
* 分析频谱
|
|
55
|
+
* @param stream
|
|
55
56
|
*/
|
|
56
57
|
analyzeFrequency({ stream, fftSize, callback }: analyze): void;
|
|
57
58
|
/**
|