From 0be426b733cae43a6e0b3217b94e91a8b27dddc6 Mon Sep 17 00:00:00 2001 From: NikyOFF Date: Thu, 31 Oct 2024 11:41:39 +0300 Subject: [PATCH] chore: prod --- .env.development | 2 +- .env.production | 2 +- lib/build.js | 2 +- lib/build.umd.cjs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.env.development b/.env.development index 02c868b..e5bdb13 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ -VITE_SIGNALING_SERVER_URL=https://9906.voip.green-api.com/ +VITE_SIGNALING_SERVER_URL=https://voip.green-api.com/ VITE_API_URL=https://api.green-api.com/ VITE_RTC_ICE_SERVERS='[ { diff --git a/.env.production b/.env.production index 02c868b..e5bdb13 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,4 @@ -VITE_SIGNALING_SERVER_URL=https://9906.voip.green-api.com/ +VITE_SIGNALING_SERVER_URL=https://voip.green-api.com/ VITE_API_URL=https://api.green-api.com/ VITE_RTC_ICE_SERVERS='[ { diff --git a/lib/build.js b/lib/build.js index 366b598..fad8b2d 100644 --- a/lib/build.js +++ b/lib/build.js @@ -2392,7 +2392,7 @@ class mt extends EventTarget { let n; this.connectPromise = new Promise((i) => { n = i; - }), this.socket = B("https://9906.voip.green-api.com/", { + }), this.socket = B("https://voip.green-api.com/", { transports: ["websocket"], autoConnect: !1 }), this.socket.on("connect", () => { diff --git a/lib/build.umd.cjs b/lib/build.umd.cjs index 3a898a2..1d238ef 100644 --- a/lib/build.umd.cjs +++ b/lib/build.umd.cjs @@ -38,4 +38,4 @@ "username": "slonway", "credential": "!Tha3Ohx9aewai4di!" } - ]`.replace(/\n/g,"").replace(/\s/g,""));console.log(t);let n;this.connectPromise=new Promise(i=>{n=i}),this.socket=I("https://9906.voip.green-api.com/",{transports:["websocket"],autoConnect:!1}),this.socket.on("connect",()=>{console.log("socket connected: ",this.socket.connected,this.socket),n()}),this.socket.on("connect_error",i=>{throw console.error(i),i}),this.socket.on(l.ADD_PEER,this.onNewPeer),this.socket.on(l.REMOVE_PEER,this.onRemovePeer),this.socket.on(l.SESSION_DESCRIPTION,this.onRemoteMedia),this.socket.on(l.ICE_CANDIDATE,this.onIceCandidate),this.socket.on(l.INCOMING_CALL,this.onIncomingCall),this.socket.on(l.CALL_STATE,this.onCallState),this.socket.on(l.END_CALL,this.onEndCall)}destroy(){this.socket.disconnect()}reload(){this.socket.disconnect(),this.socket.connect()}async init(t){if(this.options=t,!this.socket.connected)return this.socket.auth={idInstance:this.options.idInstance,apiInstanceToken:this.options.apiTokenInstance,type:"external"},this.socket.connect(),this.connectPromise}async startCall(t,n=!0,i=!0){if(!this.options)throw new Error("idInstance and apiTokenInstance doesn't exists");if(this.call!==null)throw new Error("Already in call");try{this.incomingCallTimeout!==null&&(this.clearIncomingCallTimeout(),await this.rejectCall()),this.localMediaStream=await this.startCapture({audio:n,video:i}),this.dispatchEvent(new CustomEvent(l.LOCAL_STREAM_READY,{detail:this.localMediaStream}))}catch{throw new Error("cannot get capture of audio or video")}const r=await lt(t,this.options);if(r.status===200){const{callId:c}=await r.json();this.call=new Ee({id:c})}else throw new Error("Server error");if(!await this.socket.emitWithAck(l.JOIN,{callID:this.options.idInstance}))throw this.call=null,new Error("signaling server error")}async acceptCall(t=!0,n=!0){if(!this.options)throw new Error("idInstance and apiTokenInstance doesn't exists");if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout===null)throw new Error("Incoming call timeout");this.clearIncomingCallTimeout();try{this.localMediaStream=await this.startCapture({audio:t,video:n}),this.dispatchEvent(new CustomEvent(l.LOCAL_STREAM_READY,{detail:this.localMediaStream}))}catch{throw new Error("cannot get capture of audio or video")}this.socket.emit(l.INCOMING_CALL_ANSWER,{reject:!1}),this.socket.emit(l.JOIN,{callID:this.options.idInstance})}async rejectCall(){if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout===null)throw new Error("Incoming call timeout");this.dispatchEvent(new CustomEvent(l.END_CALL,{detail:{type:A.REJECTED}})),this.socket.emit(l.INCOMING_CALL_ANSWER,{reject:!0})}async endCall(){var t;if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout!==null)throw new Error("Incoming call");try{(t=this.localMediaStream)==null||t.getTracks().forEach(i=>i.stop());for(const i in this.peerConnections)i in this.peerConnections&&(this.peerConnections[i].close(),delete this.peerConnections[i]);return await ft(this.socket.emitWithAck(l.END_CALL,{}),5e3)?(this.call=null,this.dispatchEvent(new CustomEvent(l.END_CALL,{detail:{type:A.SELF}})),!0):!1}catch{return!1}}startCapture(t){return navigator.mediaDevices.getUserMedia(t)}clearIncomingCallTimeout(){this.incomingCallTimeout!==null&&(clearTimeout(this.incomingCallTimeout),this.incomingCallTimeout=null)}}d.GreenApiVoipClient=pt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}); + ]`.replace(/\n/g,"").replace(/\s/g,""));console.log(t);let n;this.connectPromise=new Promise(i=>{n=i}),this.socket=I("https://voip.green-api.com/",{transports:["websocket"],autoConnect:!1}),this.socket.on("connect",()=>{console.log("socket connected: ",this.socket.connected,this.socket),n()}),this.socket.on("connect_error",i=>{throw console.error(i),i}),this.socket.on(l.ADD_PEER,this.onNewPeer),this.socket.on(l.REMOVE_PEER,this.onRemovePeer),this.socket.on(l.SESSION_DESCRIPTION,this.onRemoteMedia),this.socket.on(l.ICE_CANDIDATE,this.onIceCandidate),this.socket.on(l.INCOMING_CALL,this.onIncomingCall),this.socket.on(l.CALL_STATE,this.onCallState),this.socket.on(l.END_CALL,this.onEndCall)}destroy(){this.socket.disconnect()}reload(){this.socket.disconnect(),this.socket.connect()}async init(t){if(this.options=t,!this.socket.connected)return this.socket.auth={idInstance:this.options.idInstance,apiInstanceToken:this.options.apiTokenInstance,type:"external"},this.socket.connect(),this.connectPromise}async startCall(t,n=!0,i=!0){if(!this.options)throw new Error("idInstance and apiTokenInstance doesn't exists");if(this.call!==null)throw new Error("Already in call");try{this.incomingCallTimeout!==null&&(this.clearIncomingCallTimeout(),await this.rejectCall()),this.localMediaStream=await this.startCapture({audio:n,video:i}),this.dispatchEvent(new CustomEvent(l.LOCAL_STREAM_READY,{detail:this.localMediaStream}))}catch{throw new Error("cannot get capture of audio or video")}const r=await lt(t,this.options);if(r.status===200){const{callId:c}=await r.json();this.call=new Ee({id:c})}else throw new Error("Server error");if(!await this.socket.emitWithAck(l.JOIN,{callID:this.options.idInstance}))throw this.call=null,new Error("signaling server error")}async acceptCall(t=!0,n=!0){if(!this.options)throw new Error("idInstance and apiTokenInstance doesn't exists");if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout===null)throw new Error("Incoming call timeout");this.clearIncomingCallTimeout();try{this.localMediaStream=await this.startCapture({audio:t,video:n}),this.dispatchEvent(new CustomEvent(l.LOCAL_STREAM_READY,{detail:this.localMediaStream}))}catch{throw new Error("cannot get capture of audio or video")}this.socket.emit(l.INCOMING_CALL_ANSWER,{reject:!1}),this.socket.emit(l.JOIN,{callID:this.options.idInstance})}async rejectCall(){if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout===null)throw new Error("Incoming call timeout");this.dispatchEvent(new CustomEvent(l.END_CALL,{detail:{type:A.REJECTED}})),this.socket.emit(l.INCOMING_CALL_ANSWER,{reject:!0})}async endCall(){var t;if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout!==null)throw new Error("Incoming call");try{(t=this.localMediaStream)==null||t.getTracks().forEach(i=>i.stop());for(const i in this.peerConnections)i in this.peerConnections&&(this.peerConnections[i].close(),delete this.peerConnections[i]);return await ft(this.socket.emitWithAck(l.END_CALL,{}),5e3)?(this.call=null,this.dispatchEvent(new CustomEvent(l.END_CALL,{detail:{type:A.SELF}})),!0):!1}catch{return!1}}startCapture(t){return navigator.mediaDevices.getUserMedia(t)}clearIncomingCallTimeout(){this.incomingCallTimeout!==null&&(clearTimeout(this.incomingCallTimeout),this.incomingCallTimeout=null)}}d.GreenApiVoipClient=pt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});