zann-voice 0.1.38 → 0.1.40
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.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/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var j=require("@fingerprintjs/fingerprintjs");function t(o,e,i,s){if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?o!==e||!s:!e.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?s:i==="a"?s.call(o):s?s.value:e.get(o)}function a(o,e,i,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?o!==e||!n:!e.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(o,i):n?n.value=i:e.set(o,i),i}typeof SuppressedError=="function"&&SuppressedError;var f,r,l,h,T,W,g,V,S,v,b,A,k,m,F,R,C,Z,E,_,p,M,N,z,q,I,O,J,P,x,U,D,$,B;class L{constructor({wss:e,TURN:i,maxReconnect:s=5}){f.add(this),r.set(this,null),l.set(this,null),h.set(this,null),T.set(this,!1),W.set(this,!1),g.set(this,0),V.set(this,5),S.set(this,!1),v.set(this,!0),b.set(this,""),A.set(this,{urls:""}),k.set(this,null),m.set(this,null),F.set(this,void 0),R.set(this,void 0),C.set(this,void 0),Z.set(this,void 0),E.set(this,void 0),_.set(this,void 0),p.set(this,void 0),M.set(this,""),a(this,b,e,"f"),a(this,A,i,"f"),a(this,V,s,"f")}async connect({media:e={audio:!0,video:!1},onOpen:i,onTrack:s,onError:n,onMessage:u,onAuth:c,onMicrophoneChange:w,onCameraChange:y}){if(t(this,T,"f")){console.warn("\u26A0\uFE0F \u5DF2\u7ECF\u5B58\u5728 RTC/WS\uFF0C\u4E0D\u91CD\u590D\u521B\u5EFA");return}a(this,W,!1,"f"),a(this,S,!1,"f"),a(this,g,0,"f"),a(this,F,i,"f"),a(this,R,s,"f"),a(this,C,n,"f"),a(this,Z,u,"f"),a(this,E,c,"f"),a(this,_,w,"f"),a(this,p,y,"f"),a(this,r,new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},t(this,A,"f")]}),"f"),t(this,r,"f").onicecandidate=d=>{d.candidate&&t(this,l,"f")?.readyState===WebSocket.OPEN&&t(this,l,"f").send(JSON.stringify({type:"ice",data:d.candidate}))},t(this,r,"f").ontrack=d=>t(this,R,"f").call(this,d),e.audio&&await this.startMicrophone(),e.video&&await this.startCamera(),await t(this,f,"m",q).call(this),t(this,r,"f").onconnectionstatechange=()=>{const d=t(this,r,"f")?.connectionState;console.log("RTC connection state:",d),!t(this,W,"f")&&(d==="disconnected"||d==="failed")&&(console.warn("RTC disconnected, retrying offer..."),t(this,f,"m",D).call(this))}}async startMicrophone(){if(!t(this,r,"f")){console.warn("\u274C startMicrophone \u9700\u8981\u5148\u8C03\u7528 connect()");return}if(t(this,h,"f")?.getAudioTracks().length){t(this,h,"f").getAudioTracks().forEach(e=>e.enabled=!0),t(this,_,"f")&&t(this,_,"f").call(this,!0,t(this,h,"f"));return}try{const e=await navigator.mediaDevices.getUserMedia({audio:!0});e.getAudioTracks().forEach(i=>t(this,r,"f").addTrack(i,e)),t(this,h,"f")||a(this,h,new MediaStream,"f"),e.getAudioTracks().forEach(i=>t(this,h,"f").addTrack(i)),t(this,_,"f")&&t(this,_,"f").call(this,!0,e)}catch(e){t(this,E,"f").call(this,e),t(this,_,"f")&&t(this,_,"f").call(this,!1,null),t(this,f,"m",x).call(this)}}analyzeFrequency({stream:e,fftSize:i=2048,callback:s}){a(this,m,new AudioContext,"f");const n=t(this,m,"f").createAnalyser();n.fftSize=t(this,f,"m",U).call(this,i),n.smoothingTimeConstant=.8,t(this,m,"f").createMediaStreamSource(e).connect(n);const c=new Uint8Array(n.fftSize),w=new Uint8Array(n.frequencyBinCount),y=this;function d(){t(y,m,"f")&&(n.getByteTimeDomainData(c),n.getByteFrequencyData(w),t(y,T,"f")&&s(c,w),requestAnimationFrame(d))}d()}stopMicrophone(){t(this,h,"f")&&(t(this,h,"f").getAudioTracks().forEach(e=>{e.enabled=!1}),t(this,_,"f")&&t(this,_,"f").call(this,!1,t(this,h,"f")),t(this,f,"m",x).call(this))}async startCamera(){if(!t(this,r,"f")){console.warn("\u274C startCamera \u9700\u8981\u5148\u8C03\u7528 connect()");return}if(t(this,h,"f")?.getVideoTracks().length){t(this,h,"f").getVideoTracks().forEach(e=>e.enabled=!0),t(this,p,"f")&&t(this,p,"f").call(this,!0,t(this,h,"f"));return}try{const e=await navigator.mediaDevices.getUserMedia({video:!0});e.getVideoTracks().forEach(i=>t(this,r,"f").addTrack(i,e)),t(this,h,"f")||a(this,h,new MediaStream,"f"),e.getVideoTracks().forEach(i=>t(this,h,"f").addTrack(i)),t(this,p,"f")&&t(this,p,"f").call(this,!0,e)}catch(e){t(this,E,"f").call(this,e),t(this,p,"f")&&t(this,p,"f").call(this,!1,null)}}stopCamera(){t(this,h,"f")&&(t(this,h,"f").getVideoTracks().forEach(e=>{e.enabled=!1}),t(this,p,"f")&&t(this,p,"f").call(this,!1,t(this,h,"f")))}destroy(){console.log("\u{1F6D1} Destroying ZannVoice..."),a(this,W,!0,"f"),this.stopMicrophone(),this.stopCamera(),t(this,f,"m",$).call(this),t(this,f,"m",B).call(this),a(this,T,!1,"f"),clearInterval(t(this,k,"f")),a(this,k,null,"f"),a(this,S,!1,"f")}async authorize(){if(!navigator.permissions)return{microphone:"unknown",camera:"unknown"};const e=async n=>{try{return(await navigator.permissions.query({name:n})).state}catch{return"unknown"}},i=await e("microphone"),s=await e("camera");return{microphone:i,camera:s}}}r=new WeakMap,l=new WeakMap,h=new WeakMap,T=new WeakMap,W=new WeakMap,g=new WeakMap,V=new WeakMap,S=new WeakMap,v=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,m=new WeakMap,F=new WeakMap,R=new WeakMap,C=new WeakMap,Z=new WeakMap,E=new WeakMap,_=new WeakMap,p=new WeakMap,M=new WeakMap,f=new WeakSet,N=function(e,i){const s=new URL(e);return Object.entries(i).forEach(([n,u])=>s.searchParams.set(n,String(u))),s.toString()},z=function(e,i,s=1e4){let n=0,u=e;for(let c=0;c<i;c++)n+=u,u=Math.min(u*2,s);return n},q=async function o(e=1e3){if(!t(this,b,"f"))return;const s=await(await j.load()).get(),n=t(this,f,"m",z).call(this,1e3,t(this,V,"f")),u=t(this,f,"m",N).call(this,t(this,b,"f"),{fingerprint:s.visitorId,maxRetryTotalTime:n});a(this,l,new WebSocket(u),"f"),t(this,l,"f").onopen=()=>{console.log("\u2705 WS connected"),a(this,S,!0,"f"),a(this,g,0,"f"),t(this,r,"f")?.connectionState!=="connected"&&t(this,f,"m",D).call(this)},t(this,l,"f").onmessage=c=>t(this,f,"m",J).call(this,c),t(this,l,"f").onerror=c=>{t(this,S,"f")&&t(this,C,"f").call(this,c)},t(this,l,"f").onclose=()=>{var c;if(!t(this,W,"f")){if(t(this,g,"f")>=t(this,V,"f")){console.error(`\u274C WS \u8D85\u8FC7\u6700\u5927\u91CD\u8FDE\u6B21\u6570 ${t(this,V,"f")}`),t(this,C,"f")?.call(this,new Error(`WS exceeded max reconnects ${t(this,V,"f")}`)),a(this,S,!1,"f"),this.stopMicrophone();return}a(this,g,(c=t(this,g,"f"),c++,c),"f"),console.warn(`\u{1F504} WS disconnected, retrying in ${e}ms... [${t(this,g,"f")}/${t(this,V,"f")}]`),t(this,f,"m",O).call(this),setTimeout(()=>t(this,f,"m",o).call(this,Math.min(e*2,1e4)),e)}}},I=function(){t(this,f,"m",O).call(this),a(this,k,setInterval(()=>{t(this,l,"f")?.send(JSON.stringify({type:"heartbeat",data:"1"}))},1e4),"f")},O=function(){t(this,k,"f")!=null&&(clearInterval(t(this,k,"f")),a(this,k,null,"f"))},J=async function(e){const i=JSON.parse(e.data);switch(i.type){case"answer":await t(this,f,"m",P).call(this,i.data),t(this,F,"f").call(this),t(this,f,"m",I).call(this),a(this,T,!0,"f");break;case"ice":await t(this,r,"f")?.addIceCandidate(i.data);break;case"offer":await t(this,f,"m",P).call(this,i.data);const s=await t(this,r,"f")?.createAnswer();s&&(await t(this,r,"f")?.setLocalDescription(s),t(this,l,"f")?.send(JSON.stringify({type:"answer",data:s})));break;case"start_talking":a(this,M,"","f"),a(this,v,!0,"f"),t(this,Z,"f").call(this,{type:"start",data:null});break;case"asr_text":t(this,Z,"f").call(this,{type:"user",data:{content:i.data}});break;case"llm_text":i.finish_reason==="content_filter"?a(this,M,i.content,"f"):a(this,M,t(this,M,"f")+i.content,"f"),t(this,v,"f")&&(t(this,Z,"f").call(this,{type:"before",data:null}),a(this,v,!1,"f")),t(this,Z,"f").call(this,{type:"assistant",data:{content:t(this,M,"f")}});break;case"llm_end":t(this,Z,"f").call(this,{type:"end",data:null}),a(this,M,"","f"),a(this,v,!0,"f");break}},P=async function(e){const i=t(this,r,"f")?.signalingState;if(i!=="have-local-offer"){console.warn("\u26A0 \u5FFD\u7565\u91CD\u590D answer\uFF0C\u5F53\u524D\u72B6\u6001:",i);return}else await t(this,r,"f")?.setRemoteDescription(e)},x=function(){t(this,m,"f")&&(t(this,m,"f").close(),a(this,m,null,"f"))},U=function(e){const n=w=>(w&w-1)===0,u=w=>{let y=1;for(;y*2<=w;)y*=2;return y};let c=Math.min(Math.max(e,32),32768);return n(c)||(c=u(c)),c},D=async function(){if(!t(this,r,"f")||!t(this,l,"f")||t(this,l,"f").readyState!==WebSocket.OPEN)return;const e=await t(this,r,"f").createOffer();await t(this,r,"f").setLocalDescription(e),t(this,l,"f").send(JSON.stringify({type:"offer",data:e}))},$=function(){t(this,r,"f")?.getSenders().forEach(e=>e.track?.stop()),t(this,r,"f")?.close(),a(this,r,null,"f")},B=function(){t(this,l,"f")&&t(this,l,"f").readyState===WebSocket.OPEN&&t(this,l,"f").close(),a(this,l,null,"f")},module.exports=L;
|
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
|
-
import
|
|
1
|
+
import j from"@fingerprintjs/fingerprintjs";function t(o,e,i,s){if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?o!==e||!s:!e.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?s:i==="a"?s.call(o):s?s.value:e.get(o)}function a(o,e,i,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?o!==e||!n:!e.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(o,i):n?n.value=i:e.set(o,i),i}typeof SuppressedError=="function"&&SuppressedError;var f,r,l,h,T,W,g,V,S,b,v,A,k,m,F,R,C,Z,E,_,p,M,N,z,I,q,O,J,P,x,U,D,$,B;class L{constructor({wss:e,TURN:i,maxReconnect:s=5}){f.add(this),r.set(this,null),l.set(this,null),h.set(this,null),T.set(this,!1),W.set(this,!1),g.set(this,0),V.set(this,5),S.set(this,!1),b.set(this,!0),v.set(this,""),A.set(this,{urls:""}),k.set(this,null),m.set(this,null),F.set(this,void 0),R.set(this,void 0),C.set(this,void 0),Z.set(this,void 0),E.set(this,void 0),_.set(this,void 0),p.set(this,void 0),M.set(this,""),a(this,v,e,"f"),a(this,A,i,"f"),a(this,V,s,"f")}async connect({media:e={audio:!0,video:!1},onOpen:i,onTrack:s,onError:n,onMessage:u,onAuth:c,onMicrophoneChange:w,onCameraChange:y}){if(t(this,T,"f")){console.warn("\u26A0\uFE0F \u5DF2\u7ECF\u5B58\u5728 RTC/WS\uFF0C\u4E0D\u91CD\u590D\u521B\u5EFA");return}a(this,W,!1,"f"),a(this,S,!1,"f"),a(this,g,0,"f"),a(this,F,i,"f"),a(this,R,s,"f"),a(this,C,n,"f"),a(this,Z,u,"f"),a(this,E,c,"f"),a(this,_,w,"f"),a(this,p,y,"f"),a(this,r,new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},t(this,A,"f")]}),"f"),t(this,r,"f").onicecandidate=d=>{d.candidate&&t(this,l,"f")?.readyState===WebSocket.OPEN&&t(this,l,"f").send(JSON.stringify({type:"ice",data:d.candidate}))},t(this,r,"f").ontrack=d=>t(this,R,"f").call(this,d),e.audio&&await this.startMicrophone(),e.video&&await this.startCamera(),await t(this,f,"m",I).call(this),t(this,r,"f").onconnectionstatechange=()=>{const d=t(this,r,"f")?.connectionState;console.log("RTC connection state:",d),!t(this,W,"f")&&(d==="disconnected"||d==="failed")&&(console.warn("RTC disconnected, retrying offer..."),t(this,f,"m",D).call(this))}}async startMicrophone(){if(!t(this,r,"f")){console.warn("\u274C startMicrophone \u9700\u8981\u5148\u8C03\u7528 connect()");return}if(t(this,h,"f")?.getAudioTracks().length){t(this,h,"f").getAudioTracks().forEach(e=>e.enabled=!0),t(this,_,"f")&&t(this,_,"f").call(this,!0,t(this,h,"f"));return}try{const e=await navigator.mediaDevices.getUserMedia({audio:!0});e.getAudioTracks().forEach(i=>t(this,r,"f").addTrack(i,e)),t(this,h,"f")||a(this,h,new MediaStream,"f"),e.getAudioTracks().forEach(i=>t(this,h,"f").addTrack(i)),t(this,_,"f")&&t(this,_,"f").call(this,!0,e)}catch(e){t(this,E,"f").call(this,e),t(this,_,"f")&&t(this,_,"f").call(this,!1,null),t(this,f,"m",x).call(this)}}analyzeFrequency({stream:e,fftSize:i=2048,callback:s}){a(this,m,new AudioContext,"f");const n=t(this,m,"f").createAnalyser();n.fftSize=t(this,f,"m",U).call(this,i),n.smoothingTimeConstant=.8,t(this,m,"f").createMediaStreamSource(e).connect(n);const c=new Uint8Array(n.fftSize),w=new Uint8Array(n.frequencyBinCount),y=this;function d(){t(y,m,"f")&&(n.getByteTimeDomainData(c),n.getByteFrequencyData(w),t(y,T,"f")&&s(c,w),requestAnimationFrame(d))}d()}stopMicrophone(){t(this,h,"f")&&(t(this,h,"f").getAudioTracks().forEach(e=>{e.enabled=!1}),t(this,_,"f")&&t(this,_,"f").call(this,!1,t(this,h,"f")),t(this,f,"m",x).call(this))}async startCamera(){if(!t(this,r,"f")){console.warn("\u274C startCamera \u9700\u8981\u5148\u8C03\u7528 connect()");return}if(t(this,h,"f")?.getVideoTracks().length){t(this,h,"f").getVideoTracks().forEach(e=>e.enabled=!0),t(this,p,"f")&&t(this,p,"f").call(this,!0,t(this,h,"f"));return}try{const e=await navigator.mediaDevices.getUserMedia({video:!0});e.getVideoTracks().forEach(i=>t(this,r,"f").addTrack(i,e)),t(this,h,"f")||a(this,h,new MediaStream,"f"),e.getVideoTracks().forEach(i=>t(this,h,"f").addTrack(i)),t(this,p,"f")&&t(this,p,"f").call(this,!0,e)}catch(e){t(this,E,"f").call(this,e),t(this,p,"f")&&t(this,p,"f").call(this,!1,null)}}stopCamera(){t(this,h,"f")&&(t(this,h,"f").getVideoTracks().forEach(e=>{e.enabled=!1}),t(this,p,"f")&&t(this,p,"f").call(this,!1,t(this,h,"f")))}destroy(){console.log("\u{1F6D1} Destroying ZannVoice..."),a(this,W,!0,"f"),this.stopMicrophone(),this.stopCamera(),t(this,f,"m",$).call(this),t(this,f,"m",B).call(this),a(this,T,!1,"f"),clearInterval(t(this,k,"f")),a(this,k,null,"f"),a(this,S,!1,"f")}async authorize(){if(!navigator.permissions)return{microphone:"unknown",camera:"unknown"};const e=async n=>{try{return(await navigator.permissions.query({name:n})).state}catch{return"unknown"}},i=await e("microphone"),s=await e("camera");return{microphone:i,camera:s}}}r=new WeakMap,l=new WeakMap,h=new WeakMap,T=new WeakMap,W=new WeakMap,g=new WeakMap,V=new WeakMap,S=new WeakMap,b=new WeakMap,v=new WeakMap,A=new WeakMap,k=new WeakMap,m=new WeakMap,F=new WeakMap,R=new WeakMap,C=new WeakMap,Z=new WeakMap,E=new WeakMap,_=new WeakMap,p=new WeakMap,M=new WeakMap,f=new WeakSet,N=function(e,i){const s=new URL(e);return Object.entries(i).forEach(([n,u])=>s.searchParams.set(n,String(u))),s.toString()},z=function(e,i,s=1e4){let n=0,u=e;for(let c=0;c<i;c++)n+=u,u=Math.min(u*2,s);return n},I=async function o(e=1e3){if(!t(this,v,"f"))return;const s=await(await j.load()).get(),n=t(this,f,"m",z).call(this,1e3,t(this,V,"f")),u=t(this,f,"m",N).call(this,t(this,v,"f"),{fingerprint:s.visitorId,maxRetryTotalTime:n});a(this,l,new WebSocket(u),"f"),t(this,l,"f").onopen=()=>{console.log("\u2705 WS connected"),a(this,S,!0,"f"),a(this,g,0,"f"),t(this,r,"f")?.connectionState!=="connected"&&t(this,f,"m",D).call(this)},t(this,l,"f").onmessage=c=>t(this,f,"m",J).call(this,c),t(this,l,"f").onerror=c=>{t(this,S,"f")&&t(this,C,"f").call(this,c)},t(this,l,"f").onclose=()=>{var c;if(!t(this,W,"f")){if(t(this,g,"f")>=t(this,V,"f")){console.error(`\u274C WS \u8D85\u8FC7\u6700\u5927\u91CD\u8FDE\u6B21\u6570 ${t(this,V,"f")}`),t(this,C,"f")?.call(this,new Error(`WS exceeded max reconnects ${t(this,V,"f")}`)),a(this,S,!1,"f"),this.stopMicrophone();return}a(this,g,(c=t(this,g,"f"),c++,c),"f"),console.warn(`\u{1F504} WS disconnected, retrying in ${e}ms... [${t(this,g,"f")}/${t(this,V,"f")}]`),t(this,f,"m",O).call(this),setTimeout(()=>t(this,f,"m",o).call(this,Math.min(e*2,1e4)),e)}}},q=function(){t(this,f,"m",O).call(this),a(this,k,setInterval(()=>{t(this,l,"f")?.send(JSON.stringify({type:"heartbeat",data:"1"}))},1e4),"f")},O=function(){t(this,k,"f")!=null&&(clearInterval(t(this,k,"f")),a(this,k,null,"f"))},J=async function(e){const i=JSON.parse(e.data);switch(i.type){case"answer":await t(this,f,"m",P).call(this,i.data),t(this,F,"f").call(this),t(this,f,"m",q).call(this),a(this,T,!0,"f");break;case"ice":await t(this,r,"f")?.addIceCandidate(i.data);break;case"offer":await t(this,f,"m",P).call(this,i.data);const s=await t(this,r,"f")?.createAnswer();s&&(await t(this,r,"f")?.setLocalDescription(s),t(this,l,"f")?.send(JSON.stringify({type:"answer",data:s})));break;case"start_talking":a(this,M,"","f"),a(this,b,!0,"f"),t(this,Z,"f").call(this,{type:"start",data:null});break;case"asr_text":t(this,Z,"f").call(this,{type:"user",data:{content:i.data}});break;case"llm_text":i.finish_reason==="content_filter"?a(this,M,i.content,"f"):a(this,M,t(this,M,"f")+i.content,"f"),t(this,b,"f")&&(t(this,Z,"f").call(this,{type:"before",data:null}),a(this,b,!1,"f")),t(this,Z,"f").call(this,{type:"assistant",data:{content:t(this,M,"f")}});break;case"llm_end":t(this,Z,"f").call(this,{type:"end",data:null}),a(this,M,"","f"),a(this,b,!0,"f");break}},P=async function(e){const i=t(this,r,"f")?.signalingState;if(i!=="have-local-offer"){console.warn("\u26A0 \u5FFD\u7565\u91CD\u590D answer\uFF0C\u5F53\u524D\u72B6\u6001:",i);return}else await t(this,r,"f")?.setRemoteDescription(e)},x=function(){t(this,m,"f")&&(t(this,m,"f").close(),a(this,m,null,"f"))},U=function(e){const n=w=>(w&w-1)===0,u=w=>{let y=1;for(;y*2<=w;)y*=2;return y};let c=Math.min(Math.max(e,32),32768);return n(c)||(c=u(c)),c},D=async function(){if(!t(this,r,"f")||!t(this,l,"f")||t(this,l,"f").readyState!==WebSocket.OPEN)return;const e=await t(this,r,"f").createOffer();await t(this,r,"f").setLocalDescription(e),t(this,l,"f").send(JSON.stringify({type:"offer",data:e}))},$=function(){t(this,r,"f")?.getSenders().forEach(e=>e.track?.stop()),t(this,r,"f")?.close(),a(this,r,null,"f")},B=function(){t(this,l,"f")&&t(this,l,"f").readyState===WebSocket.OPEN&&t(this,l,"f").close(),a(this,l,null,"f")};export{L 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|