@gaidalou/control 1.0.23 → 1.0.24

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.
@@ -46512,7 +46512,7 @@ const Ec = class Ec {
46512
46512
  this.worker = new Worker(f, {
46513
46513
  type: "module"
46514
46514
  }), this.worker.onmessage = async (g) => {
46515
- this.worker && (this.worker.terminate(), this.worker = null), this.firstAudio = !0;
46515
+ this.worker && (this.worker.terminate(), this.worker = null), this.firstAudio = !0, this.buffer = new Uint8Array();
46516
46516
  let h = g.data;
46517
46517
  this.testModel && console.log("<===usb 接收的数据 类型 type==>", s, `\r
46518
46518
  <===命令code decodedString==>`, i, `\r
@@ -109,7 +109,7 @@ onmessage = (e) =>{
109
109
  <===版本heart version==>`,this.version),this.mitt.bus.emit("blueSend",{version:this.version,type:c,code:d,value:p,source:"bluetooth"}),this.soundAddEndTime=null}}this.soundAddEndTime?(u=s.slice(6),this.worker.postMessage({soundValue:u,source:"bluetooth",isEnd:!1})):this.soundAddEndTime=new Date().getTime(),this.soundTimer&&clearTimeout(this.soundTimer),this.soundTimer=setTimeout(()=>{this.worker.postMessage({isEnd:!0})},this.soundDiffTime);return}else u=s[6];else Pk.some(y=>y===f.value)&&(u=i[6]);c==="key"&&d===255&&u===""||(this.testModel&&console.log("<===blue 接收的数据 类型 type==>",c,`\r
110
110
  <===命令code decodedString==>`,d,`\r
111
111
  <===命令value type==>`,u,`\r
112
- <===版本heart version==>`,this.version),this.mitt.bus.emit("blueSend",{version:this.version,type:c,code:d,value:u,source:"bluetooth"}))}),n.startNotifications().then(()=>{o()}).catch(r=>{r.message.indexOf("unknown reason"),o()}).finally(()=>{o()})})}send(n){let{characteristic:o,value:r}=n;if(!o)return;const a=new Uint8Array([90,168,0,6,0,3,20,248,192,0,0,0,0,0,0,0,0,0,0]);o.writeValue(a)}static async sendMsg(n){let o=this.init({namePreFix:Ok,serviceUUIDs:Ik}),{characteristic:r,value:a}=n,l=o.webBleInfosObj[r];if(!l)return;const s=new Uint8Array(a);await l.writeValue(s)}async getVal(n){let{characteristic:o}=n;if(!o)return;let r=await o.readValue();new TextDecoder().decode(r)}async disconnect(n){if(this.server&&this.server.connected&&(await this.server.disconnect(),this.webBleInfos=[],n)){let{back:o}=n;o&&o()}}static async destory(n){this.instance&&(await this.instance.disconnect(n),this.instance.webBleInfosObj={},this.instance.device=null,this.instance.deviceName="",this.instance.server=null,this.instance.allServices=null,this.instance.webBleInfos=[],this.instance=null)}};Il(Xc,"instance",null);let go=Xc;const Zc=class Zc{static init(n){return this.instance==null&&(this.instance=new Zc(n)),this.instance}constructor(n){let o=!1;n&&(o=n.testModel),this.testModel=o,this.serialPort=null,this.reader=null,this.mitt=As.init(),this.firstAudio=!0,this.version=ka[0],this.timerLongData=null,this.timerLongDataFlag=null,this.animationId=null,this.worker=null,this.soundAddEndTime=null,this.soundDiffTime=600}async connect(n){try{if(this.serialPort=await navigator.serial.requestPort(),n){let{back:r}=n;r&&r()}let o=9600;for(await this.serialPort.open({baudRate:o}),await this.serialPort.close(),await this.serialPort.open({baudRate:o}),this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.buffer=new Uint8Array,this.reader=this.serialPort.readable.getReader(),this.autoHandle();;){let{value:r}=await this.reader.read(),a=new Uint8Array(this.buffer.length+r.length);if(a.set(this.buffer,0),a.set(r,this.buffer.length),this.buffer=a,this.buffer.length>=19){let l=this.buffer[5];if(l===26||l===15){if(this.firstAudio){this.firstAudio=!1;let s=this.buffer.slice(0,19);this.buffer=this.buffer.slice(19),this.dataReceived(s)}else if(this.buffer.length>=262){let s=this.buffer.slice(0,262);this.buffer=this.buffer.slice(262),this.dataReceived(s)}}else{let s=this.buffer.slice(0,19);this.buffer=this.buffer.slice(19),this.dataReceived(s)}}}}catch(o){console.error("出现错误:",o)}}autoHandle(){if(this.buffer.length>=19){let n=this.buffer[5];if(n===26||n===15){if(this.firstAudio){this.firstAudio=!1;let o=this.buffer.slice(0,19);this.buffer=this.buffer.slice(19),this.dataReceived(o)}else if(this.buffer.length>=262){let o=this.buffer.slice(0,262);this.buffer=this.buffer.slice(262),this.dataReceived(o)}}else{let o=this.buffer.slice(0,19);this.buffer=this.buffer.slice(19),this.dataReceived(o)}}this.animationId=requestAnimationFrame(this.autoHandle.bind(this))}dataReceived(n){let o=n,r=Sa(),a=new Uint8Array(o.buffer),l=new Int8Array(o.buffer);this.testModel&&(console.log("usb 接受的数据 uint8Array==>",a),console.log("usb 接受的数据 int8Array==>",l));let s=Dk[a[4]],i=a[5],c="";if(s==="sendToYaoKongQi"||(s==="key"&&i===255&&(this.version=ka[a[6]]),!s))return;let d=r.getBlueNum({version:this.version,type:s,code:i});if(d.type==="action")if(Rk.some(u=>u===d.value))if(d.value==="remoteIntercom"||d.value==="realTimeShouting"){if(!this.worker){const u=new Blob([zk],{type:"application/javascript"});let f=URL.createObjectURL(u);this.worker=new Worker(f,{type:"module"}),this.worker.onmessage=async y=>{this.worker&&(this.worker.terminate(),this.worker=null),this.firstAudio=!0;let h=y.data;this.testModel&&console.log("<===usb 接收的数据 类型 type==>",s,`\r
112
+ <===版本heart version==>`,this.version),this.mitt.bus.emit("blueSend",{version:this.version,type:c,code:d,value:u,source:"bluetooth"}))}),n.startNotifications().then(()=>{o()}).catch(r=>{r.message.indexOf("unknown reason"),o()}).finally(()=>{o()})})}send(n){let{characteristic:o,value:r}=n;if(!o)return;const a=new Uint8Array([90,168,0,6,0,3,20,248,192,0,0,0,0,0,0,0,0,0,0]);o.writeValue(a)}static async sendMsg(n){let o=this.init({namePreFix:Ok,serviceUUIDs:Ik}),{characteristic:r,value:a}=n,l=o.webBleInfosObj[r];if(!l)return;const s=new Uint8Array(a);await l.writeValue(s)}async getVal(n){let{characteristic:o}=n;if(!o)return;let r=await o.readValue();new TextDecoder().decode(r)}async disconnect(n){if(this.server&&this.server.connected&&(await this.server.disconnect(),this.webBleInfos=[],n)){let{back:o}=n;o&&o()}}static async destory(n){this.instance&&(await this.instance.disconnect(n),this.instance.webBleInfosObj={},this.instance.device=null,this.instance.deviceName="",this.instance.server=null,this.instance.allServices=null,this.instance.webBleInfos=[],this.instance=null)}};Il(Xc,"instance",null);let go=Xc;const Zc=class Zc{static init(n){return this.instance==null&&(this.instance=new Zc(n)),this.instance}constructor(n){let o=!1;n&&(o=n.testModel),this.testModel=o,this.serialPort=null,this.reader=null,this.mitt=As.init(),this.firstAudio=!0,this.version=ka[0],this.timerLongData=null,this.timerLongDataFlag=null,this.animationId=null,this.worker=null,this.soundAddEndTime=null,this.soundDiffTime=600}async connect(n){try{if(this.serialPort=await navigator.serial.requestPort(),n){let{back:r}=n;r&&r()}let o=9600;for(await this.serialPort.open({baudRate:o}),await this.serialPort.close(),await this.serialPort.open({baudRate:o}),this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.buffer=new Uint8Array,this.reader=this.serialPort.readable.getReader(),this.autoHandle();;){let{value:r}=await this.reader.read(),a=new Uint8Array(this.buffer.length+r.length);if(a.set(this.buffer,0),a.set(r,this.buffer.length),this.buffer=a,this.buffer.length>=19){let l=this.buffer[5];if(l===26||l===15){if(this.firstAudio){this.firstAudio=!1;let s=this.buffer.slice(0,19);this.buffer=this.buffer.slice(19),this.dataReceived(s)}else if(this.buffer.length>=262){let s=this.buffer.slice(0,262);this.buffer=this.buffer.slice(262),this.dataReceived(s)}}else{let s=this.buffer.slice(0,19);this.buffer=this.buffer.slice(19),this.dataReceived(s)}}}}catch(o){console.error("出现错误:",o)}}autoHandle(){if(this.buffer.length>=19){let n=this.buffer[5];if(n===26||n===15){if(this.firstAudio){this.firstAudio=!1;let o=this.buffer.slice(0,19);this.buffer=this.buffer.slice(19),this.dataReceived(o)}else if(this.buffer.length>=262){let o=this.buffer.slice(0,262);this.buffer=this.buffer.slice(262),this.dataReceived(o)}}else{let o=this.buffer.slice(0,19);this.buffer=this.buffer.slice(19),this.dataReceived(o)}}this.animationId=requestAnimationFrame(this.autoHandle.bind(this))}dataReceived(n){let o=n,r=Sa(),a=new Uint8Array(o.buffer),l=new Int8Array(o.buffer);this.testModel&&(console.log("usb 接受的数据 uint8Array==>",a),console.log("usb 接受的数据 int8Array==>",l));let s=Dk[a[4]],i=a[5],c="";if(s==="sendToYaoKongQi"||(s==="key"&&i===255&&(this.version=ka[a[6]]),!s))return;let d=r.getBlueNum({version:this.version,type:s,code:i});if(d.type==="action")if(Rk.some(u=>u===d.value))if(d.value==="remoteIntercom"||d.value==="realTimeShouting"){if(!this.worker){const u=new Blob([zk],{type:"application/javascript"});let f=URL.createObjectURL(u);this.worker=new Worker(f,{type:"module"}),this.worker.onmessage=async y=>{this.worker&&(this.worker.terminate(),this.worker=null),this.firstAudio=!0,this.buffer=new Uint8Array;let h=y.data;this.testModel&&console.log("<===usb 接收的数据 类型 type==>",s,`\r
113
113
  <===命令code decodedString==>`,i,`\r
114
114
  <===命令value type==>`,c),this.mitt.bus.emit("blueSend",{version:this.version,type:s,code:i,value:h,source:"bluetooth"}),this.soundAddEndTime=null}}this.soundAddEndTime?(c=a.slice(6),this.worker.postMessage({soundValue:c,source:"bluetooth",isEnd:!1})):this.soundAddEndTime=new Date().getTime(),this.soundTimer&&clearTimeout(this.soundTimer),this.soundTimer=setTimeout(()=>{this.worker.postMessage({isEnd:!0})},this.soundDiffTime);return}else c=a[6];else Pk.some(u=>u===d.value)&&(c=l[6]);s==="key"&&i===255&&c===""||(this.testModel&&console.log("<===usb 接收的数据 类型 type==>",s,`\r
115
115
  <===命令code decodedString==>`,i,`\r
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaidalou/control",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "Vue3 control component",
5
5
  "type": "module",
6
6
  "author": "Dalou Gai",