yjz-web-sdk 1.0.8-beta.18 → 1.0.8-beta.19

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.
@@ -3,3 +3,4 @@ export declare class FileTypeUtils {
3
3
  /** 读取文件头并判断类型 */
4
4
  static detectFileType(file: File): Promise<FileKind>;
5
5
  }
6
+ export declare const formattedTime: (timestamp: number) => string;
@@ -3562,6 +3562,14 @@ class FileTypeUtils {
3562
3562
  return "unknown";
3563
3563
  }
3564
3564
  }
3565
+ const formattedTime = (timestamp) => {
3566
+ const date = new Date(timestamp);
3567
+ const h = String(date.getHours()).padStart(2, "0");
3568
+ const m = String(date.getMinutes()).padStart(2, "0");
3569
+ const s = String(date.getSeconds()).padStart(2, "0");
3570
+ const ms = String(date.getMilliseconds()).padStart(3, "0");
3571
+ return `${h}:${m}:${s}.${ms}`;
3572
+ };
3565
3573
  class WebRTCClient extends EventEmitter {
3566
3574
  // private isFireFox: boolean = false;
3567
3575
  constructor(config) {
@@ -3754,9 +3762,9 @@ class WebRTCClient extends EventEmitter {
3754
3762
  try {
3755
3763
  this.localStream = await navigator.mediaDevices.getUserMedia({
3756
3764
  video: {
3757
- width: { ideal: 640 },
3758
- height: { ideal: 480 },
3759
- facingMode: useBackCamera ? { ideal: "environment" } : { ideal: "user" },
3765
+ width: { ideal: 1280 },
3766
+ height: { ideal: 720 },
3767
+ facingMode: useBackCamera ? { ideal: "user" } : { ideal: "user" },
3760
3768
  frameRate: { ideal: 20, max: 30 }
3761
3769
  },
3762
3770
  audio: true
@@ -3801,8 +3809,8 @@ class WebRTCClient extends EventEmitter {
3801
3809
  this.isPushingStream = true;
3802
3810
  this.localStream = await navigator.mediaDevices.getUserMedia({
3803
3811
  video: {
3804
- width: { ideal: 640 },
3805
- height: { ideal: 480 },
3812
+ width: { ideal: 1280 },
3813
+ height: { ideal: 720 },
3806
3814
  facingMode: useBackCamera ? { ideal: "environment" } : { ideal: "user" },
3807
3815
  frameRate: { ideal: 20, max: 30 }
3808
3816
  },
@@ -3837,8 +3845,8 @@ class WebRTCClient extends EventEmitter {
3837
3845
  }
3838
3846
  async getRotatedStream(localStream, useBackCamera) {
3839
3847
  const canvas = document.createElement("canvas");
3840
- canvas.width = 640;
3841
- canvas.height = 480;
3848
+ canvas.width = 1280;
3849
+ canvas.height = 720;
3842
3850
  canvas.style.position = "absolute";
3843
3851
  canvas.style.top = "-9999px";
3844
3852
  canvas.style.left = "-9999px";
@@ -4323,6 +4331,7 @@ class WebRTCSdk extends EventEmitter {
4323
4331
  var _a, _b, _c, _d, _e, _f, _g;
4324
4332
  if (!this.config) return;
4325
4333
  Logger.debug("调试信息:", `信令消息=========>`, message);
4334
+ console.log(`信令消息=========>`, message);
4326
4335
  switch (message.type) {
4327
4336
  case MessageType.Peers:
4328
4337
  this.config.myId = message.myId;
@@ -4764,6 +4773,7 @@ class WebRTCSdk extends EventEmitter {
4764
4773
  switch (type) {
4765
4774
  case ChannelDataType.ClickData:
4766
4775
  actionData = ChannelData.click(data);
4776
+ Logger.debug("群控控制事件===>", `Grp=${data.groupIndex}, Idx=${data.index}, action=${data.action}, time=${formattedTime(Date.now())}`);
4767
4777
  break;
4768
4778
  case ChannelDataType.ClipboardData:
4769
4779
  actionData = ChannelData.clipboard(data);
@@ -68,10 +68,10 @@ sdp:Re};switch(i.browser){case"chrome":if(!q||!H||!t.shimChrome)return n("Chrome
68
68
  /** 读取文件头并判断类型 */
69
69
  static async detectFileType(e){const t=await e.slice(0,16).arrayBuffer(),n=new Uint8Array(t);return 255===n[0]&&216===n[1]&&255===n[2]||137===n[0]&&80===n[1]&&78===n[2]&&71===n[3]||71===n[0]&&73===n[1]&&70===n[2]&&56===n[3]||82===n[0]&&73===n[1]&&70===n[2]&&70===n[3]&&87===n[8]&&69===n[9]&&66===n[10]&&80===n[11]?"image":"ftyp"===String.fromCharCode(...n.slice(4,8))||26===n[0]&&69===n[1]&&223===n[2]&&163===n[3]||79===n[0]&&103===n[1]&&103===n[2]&&83===n[3]?"video":"unknown"}}class qe extends d{
70
70
  // private isFireFox: boolean = false;
71
- constructor(e){super(),i(this,"config"),i(this,"peerConnection",null),i(this,"localStream",null),i(this,"rotatedStream",null),i(this,"isPushingStream",!1),i(this,"isPushingLocalStream",!1),i(this,"dataChannel",null),i(this,"statsTimer"),i(this,"lastReportTime",0),i(this,"lastBytesReceived",0),i(this,"lastPacketsLost",0),i(this,"lastPacketsReceived",0),i(this,"lostPacketCount",0),i(this,"maxLostRate",0),i(this,"lastSecondDecodedCount",0),i(this,"fileVideo"),i(this,"canvas"),i(this,"canvasStream",null),i(this,"rafId",0),i(this,"currentMedia",null),i(this,"fileImage"),i(this,"startPushLocal",async e=>{var t;if(!this.isPushingLocalStream&&e)try{await this.loadMedia(e),this.startCanvasStream();const n=[];null==(t=this.canvasStream)||t.getTracks().forEach(e=>{e.contentHint="detail";const t=this.peerConnection.addTrack(e,this.canvasStream);n.push(t)}),n.forEach(e=>this.setVideoParams(e)),await xe(this.peerConnection,e=>{this.emit(y.sendOffer,e)}),this.isPushingLocalStream=!0}catch(n){let e;this.isPushingLocalStream=!1,e=n instanceof Error?n.message:String(n),this.emit(y.cameraError,C(m.LOCAL_STREAM_FAIL,e))}}),this.config=e}async startPush(e=!0){this.isPushingLocalStream&&this.stopLocal();try{this.isPushingStream=!0,await this.readyCapture(e)}catch(t){let e;this.isPushingStream=!1,e=t instanceof Error?t.message:String(t),this.emit(y.cameraError,C(m.CAMERA_STREAM_FAIL,e))}}handleOffer(e){this.resetPeerConnection(),((e,t,n,i)=>{w.info("信息日志:","设置远程offer Description=======>");const r=new RTCSessionDescription({type:"offer",sdp:t});e.setRemoteDescription(r).then(()=>Me(e,n,i)).catch(e=>null==i?void 0:i(g(u.HANDLE_OFFER,e)))})(this.peerConnection,e,e=>{this.emit(y.sendAnswer,e)},e=>this.emit(y.webrtcError,e))}handleAnswer(e){((e,t,n)=>{const i=new RTCSessionDescription({type:"answer",sdp:t});e.setRemoteDescription(i).catch(e=>null==n?void 0:n(g(u.REMOTE_DES,e)))})(this.peerConnection,e??"",e=>this.emit(y.webrtcError,e))}handleIceCandidate(e){((e,t,n)=>{w.info("信息日志:","接收远程ice 并设置=======>"),e.addIceCandidate(t).catch(e=>null==n?void 0:n(g(u.HANDLE_ICE,e)))})(this.peerConnection,e,e=>this.emit(y.webrtcError,e))}sendChannelData(e,t){var n;try{let i=null;switch(e){case je.ClickData:i=He.click(t);break;case je.ClipboardData:i=He.clipboard(t);break;case je.ActionInput:i=He.input(t,this.config.myId);break;case je.ActionChinese:i=He.chinese(t);break;case je.ActionRequestCloudDeviceInfo:i=He.requestCloudDeviceInfo();break;case je.ActionClarity:i=He.clarity(t);break;case je.ActionWheel:i=He.wheel(t);break;case je.ActionGesture:i=He.gesture(t);break;case je.ActionCommand:i=He.action(t);break;case je.ActionCommandEvent:i=He.switchAudio(t);break;case je.ActionTrack:i=He.changeSender(t)}if(i){const e=JSON.stringify(i),t=(new TextEncoder).encode(e).buffer;null==(n=this.dataChannel)||n.send(t),i=null}}catch(i){this.emit(y.webrtcError,g(u.DATACHANNEL_ERR,i))}}closeConnection(){w.info("信息日志:","关闭webrtc连接=======>"),this.statsTimer&&(clearInterval(this.statsTimer),this.statsTimer=void 0),this.stopPush(),this.stopLocal(),this.peerConnection&&("function"==typeof this.peerConnection.getSenders&&this.peerConnection.getSenders&&this.peerConnection.getSenders().forEach(e=>{var t,n;e.track&&(null==(n=(t=e.track).stop)||n.call(t))}),"function"==typeof this.peerConnection.getReceivers&&this.peerConnection.getReceivers&&this.peerConnection.getReceivers().forEach(e=>{var t,n;e.track&&(null==(n=(t=e.track).stop)||n.call(t))}),this.peerConnection.getTransceivers&&this.peerConnection.getTransceivers().forEach(e=>{var t;null==(t=e.stop)||t.call(e)}),this.removeAllListeners(),this.dataChannel=null,this.peerConnection.onicecandidate=null,this.peerConnection.ontrack=null,this.peerConnection.ondatachannel=null,this.peerConnection.onconnectionstatechange=null,this.peerConnection.oniceconnectionstatechange=null,this.peerConnection.onsignalingstatechange=null,this.peerConnection.onnegotiationneeded=null,this.peerConnection.onicegatheringstatechange=null,this.peerConnection.close(),this.peerConnection=null)}async readyCapture(e){this.resetPeerConnection(),this.stopPush(),w.info("信息日志:","启用摄像头推流到云机=======>",e);try{this.localStream=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:e?{ideal:"environment"}:{ideal:"user"},frameRate:{ideal:20,max:30}},audio:!0});const t=[],n=await this.getRotatedStream(this.localStream,e);this.rotatedStream=n,n.getTracks().forEach(e=>{e.contentHint="motion";const i=this.peerConnection.addTrack(e,n);t.push(i)}),await xe(this.peerConnection,e=>{this.emit(y.sendOffer,e)}),t.forEach(e=>this.setVideoParams(e))}catch(t){if(t instanceof DOMException)switch(t.name){case"NotAllowedError":throw new Error("用户拒绝了摄像头或麦克风权限");case"NotFoundError":throw new Error("未找到摄像头或麦克风设备");case"OverconstrainedError":throw new Error("设备无法满足指定约束");case"NotReadableError":throw new Error("设备忙或无法访问");default:throw new Error(`其他错误: ${t.message}`)}throw new Error(`mediaDevices 异常: ${t}`)}}
71
+ constructor(e){super(),i(this,"config"),i(this,"peerConnection",null),i(this,"localStream",null),i(this,"rotatedStream",null),i(this,"isPushingStream",!1),i(this,"isPushingLocalStream",!1),i(this,"dataChannel",null),i(this,"statsTimer"),i(this,"lastReportTime",0),i(this,"lastBytesReceived",0),i(this,"lastPacketsLost",0),i(this,"lastPacketsReceived",0),i(this,"lostPacketCount",0),i(this,"maxLostRate",0),i(this,"lastSecondDecodedCount",0),i(this,"fileVideo"),i(this,"canvas"),i(this,"canvasStream",null),i(this,"rafId",0),i(this,"currentMedia",null),i(this,"fileImage"),i(this,"startPushLocal",async e=>{var t;if(!this.isPushingLocalStream&&e)try{await this.loadMedia(e),this.startCanvasStream();const n=[];null==(t=this.canvasStream)||t.getTracks().forEach(e=>{e.contentHint="detail";const t=this.peerConnection.addTrack(e,this.canvasStream);n.push(t)}),n.forEach(e=>this.setVideoParams(e)),await xe(this.peerConnection,e=>{this.emit(y.sendOffer,e)}),this.isPushingLocalStream=!0}catch(n){let e;this.isPushingLocalStream=!1,e=n instanceof Error?n.message:String(n),this.emit(y.cameraError,C(m.LOCAL_STREAM_FAIL,e))}}),this.config=e}async startPush(e=!0){this.isPushingLocalStream&&this.stopLocal();try{this.isPushingStream=!0,await this.readyCapture(e)}catch(t){let e;this.isPushingStream=!1,e=t instanceof Error?t.message:String(t),this.emit(y.cameraError,C(m.CAMERA_STREAM_FAIL,e))}}handleOffer(e){this.resetPeerConnection(),((e,t,n,i)=>{w.info("信息日志:","设置远程offer Description=======>");const r=new RTCSessionDescription({type:"offer",sdp:t});e.setRemoteDescription(r).then(()=>Me(e,n,i)).catch(e=>null==i?void 0:i(g(u.HANDLE_OFFER,e)))})(this.peerConnection,e,e=>{this.emit(y.sendAnswer,e)},e=>this.emit(y.webrtcError,e))}handleAnswer(e){((e,t,n)=>{const i=new RTCSessionDescription({type:"answer",sdp:t});e.setRemoteDescription(i).catch(e=>null==n?void 0:n(g(u.REMOTE_DES,e)))})(this.peerConnection,e??"",e=>this.emit(y.webrtcError,e))}handleIceCandidate(e){((e,t,n)=>{w.info("信息日志:","接收远程ice 并设置=======>"),e.addIceCandidate(t).catch(e=>null==n?void 0:n(g(u.HANDLE_ICE,e)))})(this.peerConnection,e,e=>this.emit(y.webrtcError,e))}sendChannelData(e,t){var n;try{let i=null;switch(e){case je.ClickData:i=He.click(t);break;case je.ClipboardData:i=He.clipboard(t);break;case je.ActionInput:i=He.input(t,this.config.myId);break;case je.ActionChinese:i=He.chinese(t);break;case je.ActionRequestCloudDeviceInfo:i=He.requestCloudDeviceInfo();break;case je.ActionClarity:i=He.clarity(t);break;case je.ActionWheel:i=He.wheel(t);break;case je.ActionGesture:i=He.gesture(t);break;case je.ActionCommand:i=He.action(t);break;case je.ActionCommandEvent:i=He.switchAudio(t);break;case je.ActionTrack:i=He.changeSender(t)}if(i){const e=JSON.stringify(i),t=(new TextEncoder).encode(e).buffer;null==(n=this.dataChannel)||n.send(t),i=null}}catch(i){this.emit(y.webrtcError,g(u.DATACHANNEL_ERR,i))}}closeConnection(){w.info("信息日志:","关闭webrtc连接=======>"),this.statsTimer&&(clearInterval(this.statsTimer),this.statsTimer=void 0),this.stopPush(),this.stopLocal(),this.peerConnection&&("function"==typeof this.peerConnection.getSenders&&this.peerConnection.getSenders&&this.peerConnection.getSenders().forEach(e=>{var t,n;e.track&&(null==(n=(t=e.track).stop)||n.call(t))}),"function"==typeof this.peerConnection.getReceivers&&this.peerConnection.getReceivers&&this.peerConnection.getReceivers().forEach(e=>{var t,n;e.track&&(null==(n=(t=e.track).stop)||n.call(t))}),this.peerConnection.getTransceivers&&this.peerConnection.getTransceivers().forEach(e=>{var t;null==(t=e.stop)||t.call(e)}),this.removeAllListeners(),this.dataChannel=null,this.peerConnection.onicecandidate=null,this.peerConnection.ontrack=null,this.peerConnection.ondatachannel=null,this.peerConnection.onconnectionstatechange=null,this.peerConnection.oniceconnectionstatechange=null,this.peerConnection.onsignalingstatechange=null,this.peerConnection.onnegotiationneeded=null,this.peerConnection.onicegatheringstatechange=null,this.peerConnection.close(),this.peerConnection=null)}async readyCapture(e){this.resetPeerConnection(),this.stopPush(),w.info("信息日志:","启用摄像头推流到云机=======>",e);try{this.localStream=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720},facingMode:{ideal:"user"},frameRate:{ideal:20,max:30}},audio:!0});const t=[],n=await this.getRotatedStream(this.localStream,e);this.rotatedStream=n,n.getTracks().forEach(e=>{e.contentHint="motion";const i=this.peerConnection.addTrack(e,n);t.push(i)}),await xe(this.peerConnection,e=>{this.emit(y.sendOffer,e)}),t.forEach(e=>this.setVideoParams(e))}catch(t){if(t instanceof DOMException)switch(t.name){case"NotAllowedError":throw new Error("用户拒绝了摄像头或麦克风权限");case"NotFoundError":throw new Error("未找到摄像头或麦克风设备");case"OverconstrainedError":throw new Error("设备无法满足指定约束");case"NotReadableError":throw new Error("设备忙或无法访问");default:throw new Error(`其他错误: ${t.message}`)}throw new Error(`mediaDevices 异常: ${t}`)}}
72
72
  /**
73
73
  * ✅ 切换前后摄像头(无缝)
74
- */async switchCamera(e){var t;try{w.info("信息日志:","切换摄像头 => "+(e?"后置":"前置")),this.isPushingStream=!0,this.localStream=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:e?{ideal:"environment"}:{ideal:"user"},frameRate:{ideal:20,max:30}},audio:!1});const n=await this.getRotatedStream(this.localStream,e);this.rotatedStream=n;const i=this.rotatedStream.getVideoTracks()[0],r=null==(t=this.peerConnection)?void 0:t.getSenders().find(e=>e.track&&"video"===e.track.kind);r&&await r.replaceTrack(i)}catch(n){if(this.isPushingStream=!1,n instanceof DOMException)switch(n.name){case"NotAllowedError":throw new Error("用户拒绝了摄像头或麦克风权限");case"NotFoundError":throw new Error("未找到摄像头或麦克风设备");case"OverconstrainedError":throw new Error("设备无法满足指定约束");case"NotReadableError":throw new Error("设备忙或无法访问");default:throw new Error(`其他错误: ${n.message}`)}throw new Error(`mediaDevices 异常: ${n}`)}}async getRotatedStream(e,t){const n=document.createElement("canvas");n.width=640,n.height=480,n.style.position="absolute",n.style.top="-9999px",n.style.left="-9999px",n.style.width="1px",n.style.height="1px",n.style.opacity="0",document.body.appendChild(n);const i=n.getContext("2d"),r=document.createElement("video");r.srcObject=e,r.muted=!0,r.playsInline=!0,r.autoplay=!0,r.setAttribute("playsinline","true"),r.setAttribute("webkit-playsinline","true"),await r.play();const o=r.videoWidth,s=r.videoHeight;let a,c=0;const d=e=>{e-c>=40&&((()=>{i.clearRect(0,0,n.width,n.height),i.save(),i.translate(n.width/2,n.height/2);const e=t?-Math.PI/2:Math.PI/2;i.rotate(e),i.drawImage(r,-o/2,-s/2,o,s),i.restore()})(),c=e),a=requestAnimationFrame(d)};a=requestAnimationFrame(d);const l=n.captureStream(25);return l.getTracks().forEach(e=>{const t=()=>{cancelAnimationFrame(a),n.remove()};e.addEventListener("ended",t),e.addEventListener("stop",t)}),l}
74
+ */async switchCamera(e){var t;try{w.info("信息日志:","切换摄像头 => "+(e?"后置":"前置")),this.isPushingStream=!0,this.localStream=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720},facingMode:e?{ideal:"environment"}:{ideal:"user"},frameRate:{ideal:20,max:30}},audio:!1});const n=await this.getRotatedStream(this.localStream,e);this.rotatedStream=n;const i=this.rotatedStream.getVideoTracks()[0],r=null==(t=this.peerConnection)?void 0:t.getSenders().find(e=>e.track&&"video"===e.track.kind);r&&await r.replaceTrack(i)}catch(n){if(this.isPushingStream=!1,n instanceof DOMException)switch(n.name){case"NotAllowedError":throw new Error("用户拒绝了摄像头或麦克风权限");case"NotFoundError":throw new Error("未找到摄像头或麦克风设备");case"OverconstrainedError":throw new Error("设备无法满足指定约束");case"NotReadableError":throw new Error("设备忙或无法访问");default:throw new Error(`其他错误: ${n.message}`)}throw new Error(`mediaDevices 异常: ${n}`)}}async getRotatedStream(e,t){const n=document.createElement("canvas");n.width=1280,n.height=720,n.style.position="absolute",n.style.top="-9999px",n.style.left="-9999px",n.style.width="1px",n.style.height="1px",n.style.opacity="0",document.body.appendChild(n);const i=n.getContext("2d"),r=document.createElement("video");r.srcObject=e,r.muted=!0,r.playsInline=!0,r.autoplay=!0,r.setAttribute("playsinline","true"),r.setAttribute("webkit-playsinline","true"),await r.play();const o=r.videoWidth,s=r.videoHeight;let a,c=0;const d=e=>{e-c>=40&&((()=>{i.clearRect(0,0,n.width,n.height),i.save(),i.translate(n.width/2,n.height/2);const e=t?-Math.PI/2:Math.PI/2;i.rotate(e),i.drawImage(r,-o/2,-s/2,o,s),i.restore()})(),c=e),a=requestAnimationFrame(d)};a=requestAnimationFrame(d);const l=n.captureStream(25);return l.getTracks().forEach(e=>{const t=()=>{cancelAnimationFrame(a),n.remove()};e.addEventListener("ended",t),e.addEventListener("stop",t)}),l}
75
75
  // private async setVideoParams(sender: RTCRtpSender) {
76
76
  // Logger.info('信息日志:', '设置推流视频参数=======>')
77
77
  // const params = sender.getParameters();
@@ -102,7 +102,7 @@ i(this,"sendICEMessage",e=>{var t,n;if(!this.config)return;const i=(null==(t=thi
102
102
  /** 开始连接 signal 服务 */startConnection(){this.prepareConnection().catch(e=>{w.error("错误信息:","sdk调试错误日志======>",e),this.emit(y.webrtcError,e)})}async prepareConnection(){var e;if(!this.isConnecting){this.isConnecting=!0;try{if(Qe(this.options)){if(!this.options.turnServerUri)return w.error("错误信息:","sdk调试错误日志======> 暂无可用TURN服务器"),void this.emit(y.webrtcError,g(u.OPTION_ERR,"暂无可用TURN服务器"))}else await this.initConfig();this.initConnectConfig(),this.initSignalingClient(),null==(e=this.signalingClient)||e.start()}catch(t){throw this.isConnected=!1,t}finally{this.isConnecting=!1}}}async reconnect(){this.resetConfig();try{await this.prepareConnection()}catch(e){w.error("错误信息:","sdk调试错误日志======>",e),this.emit(y.webrtcError,e)}}initConnectConfig(e=!0){var t,n,i,r,o,s,a,c,d,l;e&&(this.config=new De(this.options)),this.config&&(this.webRTCClient=new qe(this.config)),null==(t=this.webRTCClient)||t.on(y.sendOffer,e=>this.sendOffer(e)),null==(n=this.webRTCClient)||n.on(y.sendAnswer,e=>this.sendAnswer(e)),null==(i=this.webRTCClient)||i.on(y.sendICEMessage,e=>this.sendICEMessage(e)),null==(r=this.webRTCClient)||r.on(y.streamTrack,e=>{w.debug("调试信息:","=========> EmitType.streamTrack callback"),this.emit(y.streamTrack,e)}),null==(o=this.webRTCClient)||o.on(y.iceConnectionState,e=>{this.emit(y.iceConnectionState,e),"connected"===e&&(this.isConnected=!0)}),null==(s=this.webRTCClient)||s.on(y.cloudStatusChanged,e=>this.emit(y.cloudStatusChanged,e)),null==(a=this.webRTCClient)||a.on(y.cloudClipData,e=>this.emit(y.cloudClipData,e)),null==(c=this.webRTCClient)||c.on(y.webrtcError,e=>{e.code===u.ICE_STATE&&this.connectCount<this.MAX_COUNT&&this.isConnected?(this.connectCount++,this.emit(y.reconnect),this.reconnect()):(w.error("错误信息:","sdk调试错误日志======>",e),this.emit(y.webrtcError,e))}),null==(d=this.webRTCClient)||d.on(y.cameraError,e=>{this.emit(y.cameraError,e)}),null==(l=this.webRTCClient)||l.on(y.statisticInfo,e=>{this.emit(y.statisticInfo,e)})}initSignalingClient(){this.config&&(this.signalingClient=new E(this.config),this.signalingClient.on(y.signalMessage,e=>this.handleSignaling(e)),this.signalingClient.on(y.webrtcError,e=>{w.error("错误信息:","sdk 信令调试错误日志======>",e),this.emit(y.webrtcError,e)}))}switchControl(e,t){var n;null==(n=this.signalingClient)||n.sendSwitchControlMessage(e,t)}updateConfig(e){this.config&&(this.config.roomId=e.roomId,this.config.mainRoomIdOfGroup=e.mainRoomIdOfGroup,this.config.subRoomIdsOfGroup=e.subRoomIdsOfGroup)}switchControlToMain(e){var t,n;null==(t=this.webRTCClient)||t.closeConnection(),this.webRTCClient=null,this.initConnectConfig(!1),null==(n=this.signalingClient)||n.sendSwitchControlToMainMessage(e)}resetConfig(){var e,t;this.sendSignOut(),null==(e=this.signalingClient)||e.close(),null==(t=this.webRTCClient)||t.closeConnection(),this.signalingClient=null,this.webRTCClient=null,this.config=null,this.isConnected=!1,this.isConnecting=!1}
103
103
  /** 停止连接,并发送退出信令 */stop(){var e,t;this.sendSignOut(),null==(e=this.signalingClient)||e.close(),null==(t=this.webRTCClient)||t.closeConnection(),this.removeAllListeners(),this.signalingClient=null,this.webRTCClient=null,this.config=null,this.connectCount=0,this.isConnected=!1,this.isConnecting=!1}
104
104
  /** 开始推流:触发媒体采集与轨道添加 */async startPush(){var e;try{await(null==(e=this.webRTCClient)?void 0:e.startPush())}catch(t){let e;e=t instanceof Error?t.message:String(t),this.emit(y.cameraError,C(m.CAMERA_STREAM_FAIL,e))}}async startPushLocal(e){var t;try{await(null==(t=this.webRTCClient)?void 0:t.startPushLocal(e))}catch(n){let e;e=n instanceof Error?n.message:String(n),this.emit(y.cameraError,C(m.LOCAL_STREAM_FAIL,e))}}stopPush(){var e;null==(e=this.webRTCClient)||e.stopPush()}stopPushLocal(){var e;null==(e=this.webRTCClient)||e.stopLocal()}
105
- /** 发送信道数据 */sendChannelData(e,t){var n;null==(n=this.webRTCClient)||n.sendChannelData(e,t)}sendControlEvent(e){var t;const n=new Je(e,0);null==(t=this.webRTCClient)||t.sendChannelData(je.ActionInput,n)}sendGroupAcceptControl(e,t){var n;null==(n=this.signalingClient)||n.sendGroupAcceptControl(e,t)}sendPong(){var e;const t={type:h.Pong},n=JSON.stringify(t);null==(e=this.signalingClient)||e.sendMessage(n)}sendSignOut(){var e,t;if(this.config)if(this.config.connectorType===p.LanForwarding){const t={type:h.GroupSignOut,identity:h.Identity,token:this.config.token,groupId:this.config.groupId};null==(e=this.signalingClient)||e.sendMessage(JSON.stringify(t))}else{const e={type:h.SignOut,identity:h.Identity,roomId:this.config.roomId,myId:this.config.myId};null==(t=this.signalingClient)||t.sendMessage(JSON.stringify(e))}}groupSendAction(e,t){var n,i;try{let r=null;switch(e){case je.ClickData:r=He.click(t);break;case je.ClipboardData:r=He.clipboard(t);break;case je.ActionInput:r=He.input(t,(null==(n=this.config)?void 0:n.myId)??"");break;case je.ActionChinese:r=He.chinese(t);break;case je.ActionRequestCloudDeviceInfo:r=He.requestCloudDeviceInfo();break;case je.ActionClarity:r=He.clarity(t);break;case je.ActionWheel:r=He.wheel(t);break;case je.ActionGesture:r=He.gesture(t);break;case je.ActionCommand:r=He.action(t);break;case je.ActionCommandEvent:r=He.switchAudio(t)}if(r){const e=JSON.stringify(r);null==(i=this.signalingClient)||i.sendGroupAction(e)}}catch(r){this.emit(y.webrtcError,g(u.DATACHANNEL_ERR,r))}}}const et={
105
+ /** 发送信道数据 */sendChannelData(e,t){var n;null==(n=this.webRTCClient)||n.sendChannelData(e,t)}sendControlEvent(e){var t;const n=new Je(e,0);null==(t=this.webRTCClient)||t.sendChannelData(je.ActionInput,n)}sendGroupAcceptControl(e,t){var n;null==(n=this.signalingClient)||n.sendGroupAcceptControl(e,t)}sendPong(){var e;const t={type:h.Pong},n=JSON.stringify(t);null==(e=this.signalingClient)||e.sendMessage(n)}sendSignOut(){var e,t;if(this.config)if(this.config.connectorType===p.LanForwarding){const t={type:h.GroupSignOut,identity:h.Identity,token:this.config.token,groupId:this.config.groupId};null==(e=this.signalingClient)||e.sendMessage(JSON.stringify(t))}else{const e={type:h.SignOut,identity:h.Identity,roomId:this.config.roomId,myId:this.config.myId};null==(t=this.signalingClient)||t.sendMessage(JSON.stringify(e))}}groupSendAction(e,t){var n,i;try{let r=null;switch(e){case je.ClickData:r=He.click(t),w.debug("群控控制事件===>",`Grp=${t.groupIndex}, Idx=${t.index}, action=${t.action}, time=${(e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`})(Date.now())}`);break;case je.ClipboardData:r=He.clipboard(t);break;case je.ActionInput:r=He.input(t,(null==(n=this.config)?void 0:n.myId)??"");break;case je.ActionChinese:r=He.chinese(t);break;case je.ActionRequestCloudDeviceInfo:r=He.requestCloudDeviceInfo();break;case je.ActionClarity:r=He.clarity(t);break;case je.ActionWheel:r=He.wheel(t);break;case je.ActionGesture:r=He.gesture(t);break;case je.ActionCommand:r=He.action(t);break;case je.ActionCommandEvent:r=He.switchAudio(t)}if(r){const e=JSON.stringify(r);null==(i=this.signalingClient)||i.sendGroupAction(e)}}catch(r){this.emit(y.webrtcError,g(u.DATACHANNEL_ERR,r))}}}const et={
106
106
  // 数字键
107
107
  Digit1:8,Digit2:9,Digit3:10,Digit4:11,Digit5:12,Digit6:13,Digit7:14,Digit8:15,Digit9:16,Digit0:7,
108
108
  // 符号键(主键盘区)
package/package.json CHANGED
@@ -1,52 +1,52 @@
1
- {
2
- "name": "yjz-web-sdk",
3
- "private": false,
4
- "version": "1.0.8-beta.18",
5
- "type": "module",
6
- "description": "针对于亚矩阵项目的云手机投屏和屏幕控制",
7
- "license": "Apache-2.0",
8
- "main": "lib/yjz-web-sdk.umd.cjs",
9
- "module": "lib/yjz-web-sdk.js",
10
- "types": "./lib/index.d.ts",
11
- "exports": {
12
- ".": {
13
- "import": "./lib/yjz-web-sdk.js",
14
- "require": "./lib/yjz-web-sdk.umd.cjs",
15
- "types": [
16
- "./lib/index.d.ts"
17
- ]
18
- }
19
- },
20
- "files": [
21
- "package.json",
22
- "README.md",
23
- "lib"
24
- ],
25
- "publishConfig": {
26
- "registry": "https://registry.npmjs.org",
27
- "access": "public"
28
- },
29
- "scripts": {
30
- "dev": "vite --host",
31
- "build": "vite build&& vue-tsc",
32
- "preview": "vite preview"
33
- },
34
- "dependencies": {
35
- "element-plus": "^2.10.5",
36
- "eventemitter3": "^5.0.1",
37
- "terser": "^5.39.0",
38
- "vue": "^3.5.13",
39
- "webrtc-adapter": "^9.0.1"
40
- },
41
- "devDependencies": {
42
- "@types/node": "^22.14.1",
43
- "@vitejs/plugin-vue": "^5.2.1",
44
- "@vue/tsconfig": "^0.7.0",
45
- "rollup-plugin-visualizer": "5.9.3",
46
- "typescript": "~5.7.2",
47
- "vite": "^6.2.0",
48
- "vite-plugin-css-injected-by-js": "3.3.1",
49
- "vite-plugin-dts": "3.6.3",
50
- "vue-tsc": "^2.2.4"
51
- }
52
- }
1
+ {
2
+ "name": "yjz-web-sdk",
3
+ "private": false,
4
+ "version": "1.0.8-beta.19",
5
+ "type": "module",
6
+ "description": "针对于亚矩阵项目的云手机投屏和屏幕控制",
7
+ "license": "Apache-2.0",
8
+ "main": "lib/yjz-web-sdk.umd.cjs",
9
+ "module": "lib/yjz-web-sdk.js",
10
+ "types": "./lib/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./lib/yjz-web-sdk.js",
14
+ "require": "./lib/yjz-web-sdk.umd.cjs",
15
+ "types": [
16
+ "./lib/index.d.ts"
17
+ ]
18
+ }
19
+ },
20
+ "files": [
21
+ "package.json",
22
+ "README.md",
23
+ "lib"
24
+ ],
25
+ "publishConfig": {
26
+ "registry": "https://registry.npmjs.org",
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "dev": "vite --host",
31
+ "build": "vite build&& vue-tsc",
32
+ "preview": "vite preview"
33
+ },
34
+ "dependencies": {
35
+ "element-plus": "^2.10.5",
36
+ "eventemitter3": "^5.0.1",
37
+ "terser": "^5.39.0",
38
+ "vue": "^3.5.13",
39
+ "webrtc-adapter": "^9.0.1"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^22.14.1",
43
+ "@vitejs/plugin-vue": "^5.2.1",
44
+ "@vue/tsconfig": "^0.7.0",
45
+ "rollup-plugin-visualizer": "5.9.3",
46
+ "typescript": "~5.7.2",
47
+ "vite": "^6.2.0",
48
+ "vite-plugin-css-injected-by-js": "3.3.1",
49
+ "vite-plugin-dts": "3.6.3",
50
+ "vue-tsc": "^2.2.4"
51
+ }
52
+ }