@danidoble/webserial 4.4.0-beta.2 → 4.4.0-beta.3

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.
Files changed (58) hide show
  1. package/dist/boardroid.cjs +1 -1
  2. package/dist/boardroid.js +99 -95
  3. package/dist/hopper.cjs +2 -2
  4. package/dist/hopper.js +66 -51
  5. package/dist/jofemar.cjs +1 -1
  6. package/dist/jofemar.js +57 -141
  7. package/dist/kernel-C1HLYiV1.cjs +1 -0
  8. package/dist/kernel-C8ISUhzV.cjs +1 -0
  9. package/dist/kernel-CQcZ_OiG.js +831 -0
  10. package/dist/{kernel-CXM5xoJD.js → kernel-DkC7Kj3m.js} +147 -124
  11. package/dist/kernel-DtXV8d8B.js +831 -0
  12. package/dist/kernel-DyNuXvtW.cjs +1 -0
  13. package/dist/kernel-aqBCxtkj.js +831 -0
  14. package/dist/kernel-pO_elWba.cjs +1 -0
  15. package/dist/kernel.cjs +2 -2
  16. package/dist/kernel.d.ts +14 -0
  17. package/dist/kernel.d.ts.map +1 -0
  18. package/dist/kernel.js +3 -4
  19. package/dist/locker.cjs +1 -1
  20. package/dist/locker.js +32 -26
  21. package/dist/main.d.ts +28 -0
  22. package/dist/main.d.ts.map +1 -0
  23. package/dist/pinpad.cjs +14 -14
  24. package/dist/pinpad.js +816 -791
  25. package/dist/pinpax.cjs +4 -4
  26. package/dist/pinpax.js +54 -54
  27. package/dist/relay.cjs +1 -1
  28. package/dist/relay.js +11 -18
  29. package/dist/serial/boardroid.d.ts +206 -0
  30. package/dist/serial/boardroid.d.ts.map +1 -0
  31. package/dist/serial/hopper.d.ts +85 -0
  32. package/dist/serial/hopper.d.ts.map +1 -0
  33. package/dist/serial/jofemar.d.ts +218 -0
  34. package/dist/serial/jofemar.d.ts.map +1 -0
  35. package/dist/serial/kernel.d.ts +137 -0
  36. package/dist/serial/kernel.d.ts.map +1 -0
  37. package/dist/serial/locker.d.ts +33 -0
  38. package/dist/serial/locker.d.ts.map +1 -0
  39. package/dist/serial/pinpad.d.ts +263 -0
  40. package/dist/serial/pinpad.d.ts.map +1 -0
  41. package/dist/serial/pinpax.d.ts +60 -0
  42. package/dist/serial/pinpax.d.ts.map +1 -0
  43. package/dist/serial/relay.d.ts +13 -0
  44. package/dist/serial/relay.d.ts.map +1 -0
  45. package/dist/utils/devices.d.ts +26 -0
  46. package/dist/utils/devices.d.ts.map +1 -0
  47. package/dist/utils/dispatcher.d.ts +17 -0
  48. package/dist/utils/dispatcher.d.ts.map +1 -0
  49. package/dist/utils/emulator.d.ts +80 -0
  50. package/dist/utils/emulator.d.ts.map +1 -0
  51. package/dist/utils/utils.d.ts +7 -0
  52. package/dist/utils/utils.d.ts.map +1 -0
  53. package/dist/webserial-core-CH2Xov2y.js +3325 -0
  54. package/dist/webserial-core-Cj_EZjAU.cjs +4 -0
  55. package/dist/webserial.cjs +2 -2
  56. package/dist/webserial.js +16 -16
  57. package/package.json +10 -7
  58. package/dist/kernel-Dizfdw3M.cjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";const p=require("./webserial-core-Cj_EZjAU.cjs");function u(o=100){return new Promise(n=>setTimeout(()=>n(),o))}function b(){return"serial"in navigator}function g(){return"geolocation"in navigator}function k(){return"crypto"in window}function y(o=1){return o*1e3}function w(o){return o==null||o===""}class e{static enable=!1;static instance=null;static#i=null;static#r=1;static#d(){if(e.enable===!1)throw new Error("Emulator is disabled");return e.enable}static#o(n){return e.instance=n,e.#i=n.typeDevice,e.#r=n.deviceNumber,!0}static#n(n=null){return!e.#d()||n===null&&e.instance===null?!1:(e.instance===null&&n!==null&&e.#o(n),!0)}static#l(){if(e.#i!=="locker")throw new Error("This function is only available for Locker devices");return!0}static#s(){if(e.#i!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0}static#t(){if(e.#i!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0}static#c(){if(e.#i==="locker")throw new Error("This function is not available for Locker devices");return!0}static#e(n){e.instance!==null&&e.instance.__emulate({code:n})}static status(n=null){if(!e.#n(n))return!1;let t=[];switch(e.#i){case"locker":t=["0","8"];break;case"boardroid":t=["2",(5+e.#r).toString(16).toUpperCase()];break;case"jofemar":t=["6"];break;default:return!1}e.#e(t)}static dispensed(n=null){if(!e.#n(n))return!1;let t=[];switch(e.#i){case"locker":t=["0","7","4","4","4"];break;case"boardroid":t=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","30"];break;default:return!1}e.#e(t)}static notDispensed(n=null){if(!e.#n(n))return!1;let t=[];switch(e.#i){case"locker":t=["0","7","5","5","5"];break;case"boardroid":t=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","34"];break;default:return!1}e.#e(t)}static gateInactive(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","7","5","5","5"])}static gateConfigured(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","6"])}static keyPressed(n=null){if(!e.#n(n)||!e.#t())return!1;const t=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],s=(128+e.#r).toString(16),i=Math.floor(Math.random()*15);e.#e(["2",s,"54",t[i]])}static doorOpened(n=null){if(!e.#n(n)||!this.#c())return!1;let t=[];const s=(128+e.#r).toString(16);switch(e.#i){case"boardroid":t=["2","D8","dc"];break;case"jofemar":t=["2",s,"50","4F"];break}e.#e(t)}static doorClosed(n=null){if(!e.#n(n)||!this.#c())return!1;let t=[];const s=(128+e.#r).toString(16);switch(e.#i){case"boardroid":t=["2","D8","db"];break;case"jofemar":t=["2",s,"50","43"];break}e.#e(t)}static channelDisconnected(n=null){if(!e.#n(n)||!e.#t())return!1;const t=(128+e.#r).toString(16);e.#e(["2",t,"43","43","43","FD"])}static channelConnected(n=null){if(!e.#n(n)||!e.#t())return!1;const t=(128+e.#r).toString(16);e.#e(["2",t,"43","43","43","FC"])}static channelEmpty(n=null){if(!e.#n(n)||!e.#t())return!1;const t=(128+e.#r).toString(16);e.#e(["2",t,"43","43","43","FF"])}static workingTemperature(n=null){if(!e.#n(n)||!e.#t())return!1;const t=(128+e.#r).toString(16);e.#e(["2",t,"43","54","16"])}static currentTemperature(n=null){if(!e.#n(n)||!e.#c())return!1;let t=[];const s=(128+e.#r).toString(16);switch(e.#i){case"boardroid":t=["2","D9","44","30"];break;case"jofemar":t=["2",s,"43","74","2B","30","39","2E","31","7F","43"];break}e.#e(t)}static ready(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","30"])}static busy(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","31"])}static invalidTray(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","32"])}static invalidChannel(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","33"])}static emptyChannel(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","34"])}static elevatorJam(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","35"])}static elevatorMalfunction(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","36"])}static phototransistorFailure(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","37"])}static allChannelsEmpty(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","38"])}static productDetectorFailure(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","39"])}static displayDisconnected(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","41"])}static productUnderElevator(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","42"])}static elevatorSettingAlarm(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","43"])}static buttonPanelFailure(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","44"])}static errorWritingEeprom(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","45"])}static errorControlTemperature(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","46"])}static thermometerDisconnected(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","47"])}static thermometerMisconfigured(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","48"])}static thermometerFailure(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","49"])}static errorExtractorConsumption(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4A"])}static channelSearchError(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4B"])}static productExitMouthSearchError(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4C"])}static elevatorInteriorLocked(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4D"])}static productDetectorVerifierError(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4E"])}static waitingForProductRecall(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4F"])}static productExpiredByTemperature(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","50"])}static faultyAutomaticDoor(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","51"])}static rejectLever(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","A0","1"])}static resetCoinPurse(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","A0","2"])}static#f(n,t=null){let s=n[Math.floor(Math.random()*5)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"0.5":s=n[1];break;case"1":s=n[2];break;case"2":s=n[3];break;case"5":s=n[4];break;case"10":s=n[5];break}return s}static coinInsertedBox(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["40","41","42","43","44","45"],i=e.#f(s,t);e.#e(["2","A0",i])}static coinInsertedTube(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["50","51","52","53","54","55"],i=e.#f(s,t);e.#e(["2","A0",i])}static#a(n,t=null){let s=n[Math.floor(Math.random()*4)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"20":s=n[0];break;case"50":s=n[1];break;case"100":s=n[2];break;case"200":s=n[3];break;case"500":s=n[4];break}return s}static banknoteInsertedStacker(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["80","81","82","83","84"],i=e.#a(s,t);e.#e(["2","B0",i])}static banknoteInsertedEscrow(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["90","91","92","93","94"],i=e.#a(s,t);e.#e(["2","B0",i])}static banknoteEjected(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["A0","A1","A2","A3","A4"],i=e.#a(s,t);e.#e(["2","B0",i])}static banknoteInsertedRecycler(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["B0","B1","B2","B3","B4"],i=e.#a(s,t);e.#e(["2","B0",i])}static banknoteTaken(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","B0","2a"])}static coinPurseEnabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D0","1"])}static coinPurseDisabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D0","0"])}static billPurseDisabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D1","0","0"])}static billPurseEnabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D1","1","1"])}static readTubes(n=null){if(!e.#n(n)||!e.#s())return!1;const t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[s,i,a,c,l,f]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)]];e.#e(["2","D2",s,i,a,c,l,f])}static readBillPurse(n=null,t=null){if(!e.#n(n)||!e.#s()||e.instance===null)return!1;const s=e.instance,i=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(s.__banknote_purse.recycler.ict){const a=i[Math.floor(Math.random()*31)];let c="0",l="0",f="0",d="0",h="0";if(t!==null&&!isNaN(parseInt(t)))switch(t.toString()){case"20":c=a;break;case"50":l=a;break;case"100":f=a;break;case"200":d=a;break;case"500":h=a;break}else switch(s.__banknote_purse.recycler.banknote){case 0:c=a;break;case 1:l=a;break;case 2:f=a;break;case 3:d=a;break;case 4:h=a;break}e.#e(["2","D3",c,l,f,d,h,"0"])}else{const[a,c,l,f,d,h]=[i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*2)],i[Math.floor(Math.random())],i[Math.floor(Math.random())]];e.#e(["2","D3",a,c,l,f,d,h])}}static banknoteAccepted(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D4","1"])}static banknoteRejected(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D4","0"])}static banknotesDispensed(n=null){if(!e.#n(n)||!e.#s()||e.instance===null)return!1;const t=e.instance,s=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(t.__banknote_purse.recycler.ict){const i=s[Math.floor(Math.random()*30)];let a="0",c="0",l="0",f="0",d="0";switch(t.__banknote_purse.recycler.banknote){case 0:a=i;break;case 1:c=i;break;case 2:l=i;break;case 3:f=i;break;case 4:d=i;break}e.#e(["2","D5",a,c,l,f,d,"0"])}else{const[i,a,c,l,f,d]=[s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*2)],s[Math.floor(Math.random())],s[Math.floor(Math.random())]];e.#e(["2","D5",i,a,c,l,f,d])}}static coinsDispensed(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D6"])}static relayOn(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DA","1"])}static relayOff(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DA","0"])}static nayaxEnabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","1"])}static nayaxDisabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","0"])}static nayaxPreCreditAuthorized(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","3"])}static nayaxCancelRequest(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","4"])}static nayaxSellApproved(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","5"])}static nayaxSellDenied(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","6"])}static nayaxEndSession(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","7"])}static nayaxCancelled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","8"])}static nayaxDispensed(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","A","0"])}static nayaxNotDispensed(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","A","1"])}static fullTray(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4F"])}static setConnection(n=null){if(!e.#n(n)||e.instance===null)return!1;e.instance.__internal__.serial.connected=!0}}class r extends p.a{constructor(){super(),r.registerType("relay"),r.registerType("locker"),r.registerType("jofemar"),r.registerType("boardroid"),r.registerType("pinpad"),r.registerType("pinpax"),r.registerType("hopper")}static addCustom(n,t){r.registerType(n),r.add(t)}static getCustomByUuid(n,t){return r.get(n,t)}static getJofemarByUuid(n){return r.get("jofemar",n)}static getLockerByUuid(n){return r.get("locker",n)}static getRelayByUuid(n){return r.get("relay",n)}static getBoardroidByUuid(n){return r.get("boardroid",n)}static getPinPadByUuid(n){return r.get("pinpad",n)}static getPinPaxByUuid(n){return r.get("pinpax",n)}static getHopperByUuid(n){return r.get("hopper",n)}static getJofemar(n=1){return r.getByNumber("jofemar",n)}static getBoardroid(n=1){return r.getByNumber("boardroid",n)}static getLocker(n=1){return r.getByNumber("locker",n)}static getRelay(n=1){return r.getByNumber("relay",n)}static getPinPad(n=1){return r.getByNumber("pinpad",n)}static getPinPax(n=1){return r.getByNumber("pinpax",n)}static getHopper(n=1){return r.getByNumber("hopper",n)}}r.instance=new r;class M extends p.ut{constructor(n={}){super(n),this.__internal__=structuredClone(this.__internal__),this.getResponseAsArrayHex(),this.__internal__.device.door_open=!1,this.__internal__.time.response_engines=2e3,this.__internal__.time.sense=100,this.__internal__.interval.waiting_sense=0,this.__internal__.dispense={must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}}get isDoorOpen(){return this.__internal__.device.door_open}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(n,t){await super.timeout(n,t),t==="dispense"&&(this.__internal__.dispense.status="no-response")}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let n=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(n=this.__internal__.dispense.custom_limit_counter),n+=Math.ceil(n*.6),this.__internal__.dispense.counter>=n?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:n}),null)}async internalDispenseStatus(){return this.__internal__.dispense.must_response&&(await u(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response")?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"}):(this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{}),new Promise(n=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(this.__internal__.dispense.status){case null:this.internalDispensingProcess()===!1&&(this.internalClearSensing(),this.dispatch("not-dispensed",{reason:"timeout"}),n({status:!1,error:"timeout"}));break;case!0:this.internalClearSensing(),this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),n({status:!0,error:null});break;case!1:this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-stock"}),n({status:!1,error:null});break;case"elevator-locked":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"elevator-locked"}),n({status:!1,error:"elevator-locked"});break;case"no-response":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),n({status:!1,error:"no-response"});break}},this.__internal__.time.sense)}))}async internalDispense(n){if(this.isDispensing)throw new Error("Another dispensing process is running");if(this.__internal__.dispense.dispensing=!0,!e.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw this.__internal__.dispense.dispensing=!1,new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(n,"dispense"),await this.internalDispenseStatus()):new Promise(t=>{const s=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(s),await this.appendToQueue(n,"dispense");const i=await this.internalDispenseStatus();t(i)},100)})}__emulate(n){if(typeof n.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),r.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const t=[];for(const s in n.code)t.push(n.code[s].toString().padStart(2,"0").toLowerCase());this.serialMessage(t)}set listenOnPort(n){this.listenOnChannel=n}get listenOnPort(){return this.__internal__.device.listen_on_port??1}fixHexArray(n){return n.map(t=>typeof t=="string"?t.padStart(2,"0").toLowerCase():t.toString(16).padStart(2,"0").toLowerCase())}}exports.Devices=r;exports.Emulator=e;exports.Kernel=M;exports.getSeconds=y;exports.isEmpty=w;exports.supportCrypto=k;exports.supportGeolocation=g;exports.supportWebSerial=b;exports.wait=u;
package/dist/kernel.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./kernel-Dizfdw3M.cjs"),r=require("./webserial-core-YjdXyVOx.cjs");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./kernel-C1HLYiV1.cjs");/**
2
2
  * @license Webserial
3
3
  * webserial
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */const n=void 0;exports.Kernel=e.Kernel;exports.Devices=r.a;exports.version=n;
9
+ */const r="4.1.9";exports.Devices=e.Devices;exports.Kernel=e.Kernel;exports.version=r;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license Webserial
3
+ * webserial
4
+ *
5
+ * Created by (c) Danidoble.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import { Kernel } from './serial/kernel';
11
+ import { Devices } from './utils/devices';
12
+ export declare const version: any;
13
+ export { Devices, Kernel };
14
+ //# sourceMappingURL=kernel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../lib/kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,eAAO,MAAM,OAAO,KAAmC,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/kernel.js CHANGED
@@ -1,5 +1,4 @@
1
- import { K as n } from "./kernel-CXM5xoJD.js";
2
- import { a as t } from "./webserial-core-D3luFguv.js";
1
+ import { D as s, K as n } from "./kernel-DtXV8d8B.js";
3
2
  /**
4
3
  * @license Webserial
5
4
  * webserial
@@ -9,9 +8,9 @@ import { a as t } from "./webserial-core-D3luFguv.js";
9
8
  * This source code is licensed under the MIT license found in the
10
9
  * LICENSE file in the root directory of this source tree.
11
10
  */
12
- const e = void 0;
11
+ const e = "4.1.9";
13
12
  export {
14
- t as Devices,
13
+ s as Devices,
15
14
  n as Kernel,
16
15
  e as version
17
16
  };
package/dist/locker.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./kernel-Dizfdw3M.cjs"),t=require("./relay-E3NCcSjS.cjs"),a=require("./webserial-core-YjdXyVOx.cjs");class h extends n.Kernel{#s=!1;#e=0;#t=0;constructor({filters:s=null,config_port:e=null,no_device:i=1,device_listen_on_port:l=3,socket:r=!1}={}){if(super({filters:s,config_port:e,no_device:i,device_listen_on_port:l,socket:r}),this.__internal__.device.type="locker",a.a.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_engines=1e3,this.__internal__.device.milliseconds=666,this.__internal__.dispense.limit_counter=1,a.a.add(this),this.#r()}#r(){const s=["percentage:disable","percentage:enable","percentage:open"];for(const e of s)this.serialRegisterAvailableListener(e)}serialMessage(s){s=this.fixHexArray(s);const e={code:s,name:null,description:null,request:null,no_code:0};switch(s[1]){case"08":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"07":switch(s[4]){case"00":e.name="Cell closed.",e.description="The selected cell is closed.",e.request="dispense",e.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"01":case"04":e.name="Cell open.",e.description="The selected cell was open successfully.",e.request="dispense",e.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"05":e.name="Cell inactive.",e.description="The selected cell is inactive or doesn't exist.",e.request="dispense",e.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break}break;case"06":e.name="Configuration applied.",e.description="The configuration was successfully applied.",e.request="configure cell",e.no_code=103;break;default:e.request="undefined",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(s=3){return t.u.connection({channel:s})}#i(){this.#s=!1,this.#e=0,this.#t=0}#n(s=null){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:open",{percentage:this.#t,dispensed:s})}#a(){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:enable",{percentage:this.#t})}#l(){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:disable",{percentage:this.#t})}async dispense({cell:s=1,status:e=!0}={}){return setTimeout(()=>{e===!0?this.#h():this.#c()},this.__internal__.time.response_engines/2),await this.internalDispense(t.u.openCell({cell:s,channel:this.__internal__.device.listen_on_port}))}#h(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)}#c(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)}async status({cell:s=1}={}){return await this.appendToQueue(t.u.statusCell({cell:s,channel:this.__internal__.device.listen_on_port}),"status")}async lightScan({since:s=0,until:e=10}={}){return await this.appendToQueue(t.u.lightScan({channel:this.__internal__.device.listen_on_port,since:s,until:e}),"light-scan")}async enable({cell:s=1}={}){return await this.appendToQueue(t.u.enableCell({cell:s,channel:this.__internal__.device.listen_on_port}),"activate")}async disable({cell:s=1}={}){await this.appendToQueue(t.u.disableCell({cell:s,channel:this.__internal__.device.listen_on_port}),"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");this.#i(),this.#s=!0,this.#n();const s=[];for(let e=1;e<=80;e++){const i=await this.dispense({cell:e,status:!0});s.push(i),this.#e=e,this.#n()}this.#e=80,this.#n(s),this.#i()}async enableAll(){this.#i(),this.#s=!0,this.#a();for(let s=1;s<=80;s++)await this.enable({cell:s}),await n.wait(100),this.#e=s,this.#a();this.#e=80,this.#a(),this.#i()}async disableAll(){this.#i(),this.#s=!0,this.#l();for(let s=1;s<=80;s++)await this.disable({cell:s}),await n.wait(100),this.#e=s,this.#l();this.#e=80,this.#l(),this.#i()}}exports.Locker=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./kernel-C1HLYiV1.cjs"),i=require("./relay-E3NCcSjS.cjs");class r extends n.Kernel{#s=!1;#e=0;#t=0;_default_fallback_listen_on_channel=3;constructor({filters:s=null,config_port:e,no_device:t=1,device_listen_on_channel:a=3,socket:l=!1}={}){if(super({filters:s,config_port:e,no_device:t,device_listen_on_channel:a,socket:l}),this.__internal__.device.type="locker",n.Devices.getCustom(this.typeDevice,t))throw new Error(`Device ${this.typeDevice} ${t} already exists`);this.__internal__.time.response_engines=1e3,this.__internal__.dispense.limit_counter=1,n.Devices.add(this),this.#r()}#r(){const s=["percentage:disable","percentage:enable","percentage:open"];for(const e of s)this.serialRegisterAvailableListener(e)}serialMessage(s){s=this.fixHexArray(s);const e={code:s,name:null,description:null,request:null,no_code:0};switch(s[1]){case"08":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"07":switch(s[4]){case"00":e.name="Cell closed.",e.description="The selected cell is closed.",e.request="dispense",e.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"01":case"04":e.name="Cell open.",e.description="The selected cell was open successfully.",e.request="dispense",e.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"05":e.name="Cell inactive.",e.description="The selected cell is inactive or doesn't exist.",e.request="dispense",e.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break}break;case"06":e.name="Configuration applied.",e.description="The configuration was successfully applied.",e.request="configure cell",e.no_code=103;break;default:e.request="undefined",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(s=3){return i.u.connection({channel:s})}#i(){this.#s=!1,this.#e=0,this.#t=0}#n(s=null){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:open",{percentage:this.#t,dispensed:s})}#a(){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:enable",{percentage:this.#t})}#l(){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:disable",{percentage:this.#t})}async dispense({cell:s=1,status:e=!0}={}){return setTimeout(()=>{e===!0?this.#h():this.#c()},this.__internal__.time.response_engines/2),await this.internalDispense(i.u.openCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}))}#h(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)}#c(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)}async status({cell:s=1}={}){return await this.appendToQueue(i.u.statusCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}),"status")}async lightScan({since:s=0,until:e=10}={}){return await this.appendToQueue(i.u.lightScan({channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel,since:s,until:e}),"light-scan")}async enable({cell:s=1}={}){return await this.appendToQueue(i.u.enableCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}),"activate")}async disable({cell:s=1}={}){await this.appendToQueue(i.u.disableCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}),"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");this.#i(),this.#s=!0,this.#n();const s=[];for(let e=1;e<=80;e++){const t=await this.dispense({cell:e,status:!0});s.push(t),this.#e=e,this.#n()}this.#e=80,this.#n(s),this.#i()}async enableAll(){this.#i(),this.#s=!0,this.#a();for(let s=1;s<=80;s++)await this.enable({cell:s}),await n.wait(100),this.#e=s,this.#a();this.#e=80,this.#a(),this.#i()}async disableAll(){this.#i(),this.#s=!0,this.#l();for(let s=1;s<=80;s++)await this.disable({cell:s}),await n.wait(100),this.#e=s,this.#l();this.#e=80,this.#l(),this.#i()}}exports.Locker=r;
package/dist/locker.js CHANGED
@@ -1,16 +1,22 @@
1
- import { K as h, w as n } from "./kernel-CXM5xoJD.js";
2
- import { u as t } from "./relay-DP8PLsDP.js";
3
- import { a } from "./webserial-core-D3luFguv.js";
4
- class d extends h {
1
+ import { K as r, D as n, w as a } from "./kernel-DtXV8d8B.js";
2
+ import { u as i } from "./relay-DP8PLsDP.js";
3
+ class d extends r {
5
4
  #s = !1;
6
5
  #e = 0;
7
6
  #t = 0;
8
- constructor({ filters: s = null, config_port: e = null, no_device: i = 1, device_listen_on_port: l = 3, socket: r = !1 } = {}) {
9
- if (super({ filters: s, config_port: e, no_device: i, device_listen_on_port: l, socket: r }), this.__internal__.device.type = "locker", a.getCustom(this.typeDevice, i))
10
- throw new Error(`Device ${this.typeDevice} ${i} already exists`);
11
- this.__internal__.time.response_engines = 1e3, this.__internal__.device.milliseconds = 666, this.__internal__.dispense.limit_counter = 1, a.add(this), this.#r();
7
+ _default_fallback_listen_on_channel = 3;
8
+ constructor({
9
+ filters: s = null,
10
+ config_port: e,
11
+ no_device: t = 1,
12
+ device_listen_on_channel: l = 3,
13
+ socket: h = !1
14
+ } = {}) {
15
+ if (super({ filters: s, config_port: e, no_device: t, device_listen_on_channel: l, socket: h }), this.__internal__.device.type = "locker", n.getCustom(this.typeDevice, t))
16
+ throw new Error(`Device ${this.typeDevice} ${t} already exists`);
17
+ this.__internal__.time.response_engines = 1e3, this.__internal__.dispense.limit_counter = 1, n.add(this), this.#h();
12
18
  }
13
- #r() {
19
+ #h() {
14
20
  const s = ["percentage:disable", "percentage:enable", "percentage:open"];
15
21
  for (const e of s)
16
22
  this.serialRegisterAvailableListener(e);
@@ -53,7 +59,7 @@ class d extends h {
53
59
  this.dispatch("serial:message", e);
54
60
  }
55
61
  serialSetConnectionConstant(s = 3) {
56
- return t.connection({ channel: s });
62
+ return i.connection({ channel: s });
57
63
  }
58
64
  #i() {
59
65
  this.#s = !1, this.#e = 0, this.#t = 0;
@@ -69,15 +75,15 @@ class d extends h {
69
75
  }
70
76
  async dispense({ cell: s = 1, status: e = !0 } = {}) {
71
77
  return setTimeout(() => {
72
- e === !0 ? this.#h() : this.#c();
78
+ e === !0 ? this.#r() : this.#c();
73
79
  }, this.__internal__.time.response_engines / 2), await this.internalDispense(
74
- t.openCell({
80
+ i.openCell({
75
81
  cell: s,
76
- channel: this.__internal__.device.listen_on_port
82
+ channel: this.__internal__.device.listen_on_port || this._default_fallback_listen_on_channel
77
83
  })
78
84
  );
79
85
  }
80
- #h() {
86
+ #r() {
81
87
  this.__internal__.dispense.dispensing && (this.__internal__.dispense.status = !0);
82
88
  }
83
89
  #c() {
@@ -85,17 +91,17 @@ class d extends h {
85
91
  }
86
92
  async status({ cell: s = 1 } = {}) {
87
93
  return await this.appendToQueue(
88
- t.statusCell({
94
+ i.statusCell({
89
95
  cell: s,
90
- channel: this.__internal__.device.listen_on_port
96
+ channel: this.__internal__.device.listen_on_port || this._default_fallback_listen_on_channel
91
97
  }),
92
98
  "status"
93
99
  );
94
100
  }
95
101
  async lightScan({ since: s = 0, until: e = 10 } = {}) {
96
102
  return await this.appendToQueue(
97
- t.lightScan({
98
- channel: this.__internal__.device.listen_on_port,
103
+ i.lightScan({
104
+ channel: this.__internal__.device.listen_on_port || this._default_fallback_listen_on_channel,
99
105
  since: s,
100
106
  until: e
101
107
  }),
@@ -104,18 +110,18 @@ class d extends h {
104
110
  }
105
111
  async enable({ cell: s = 1 } = {}) {
106
112
  return await this.appendToQueue(
107
- t.enableCell({
113
+ i.enableCell({
108
114
  cell: s,
109
- channel: this.__internal__.device.listen_on_port
115
+ channel: this.__internal__.device.listen_on_port || this._default_fallback_listen_on_channel
110
116
  }),
111
117
  "activate"
112
118
  );
113
119
  }
114
120
  async disable({ cell: s = 1 } = {}) {
115
121
  await this.appendToQueue(
116
- t.disableCell({
122
+ i.disableCell({
117
123
  cell: s,
118
- channel: this.__internal__.device.listen_on_port
124
+ channel: this.__internal__.device.listen_on_port || this._default_fallback_listen_on_channel
119
125
  }),
120
126
  "disable"
121
127
  );
@@ -125,21 +131,21 @@ class d extends h {
125
131
  this.#i(), this.#s = !0, this.#n();
126
132
  const s = [];
127
133
  for (let e = 1; e <= 80; e++) {
128
- const i = await this.dispense({ cell: e, status: !0 });
129
- s.push(i), this.#e = e, this.#n();
134
+ const t = await this.dispense({ cell: e, status: !0 });
135
+ s.push(t), this.#e = e, this.#n();
130
136
  }
131
137
  this.#e = 80, this.#n(s), this.#i();
132
138
  }
133
139
  async enableAll() {
134
140
  this.#i(), this.#s = !0, this.#a();
135
141
  for (let s = 1; s <= 80; s++)
136
- await this.enable({ cell: s }), await n(100), this.#e = s, this.#a();
142
+ await this.enable({ cell: s }), await a(100), this.#e = s, this.#a();
137
143
  this.#e = 80, this.#a(), this.#i();
138
144
  }
139
145
  async disableAll() {
140
146
  this.#i(), this.#s = !0, this.#l();
141
147
  for (let s = 1; s <= 80; s++)
142
- await this.disable({ cell: s }), await n(100), this.#e = s, this.#l();
148
+ await this.disable({ cell: s }), await a(100), this.#e = s, this.#l();
143
149
  this.#e = 80, this.#l(), this.#i();
144
150
  }
145
151
  }
package/dist/main.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license Webserial
3
+ * webserial
4
+ *
5
+ * Created by (c) Danidoble.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import { wait, getSeconds, supportWebSerial } from './utils/utils';
11
+ export { Kernel } from './serial/kernel';
12
+ export { Relay } from './serial/relay';
13
+ export { Locker } from './serial/locker';
14
+ export { PinPad } from './serial/pinpad';
15
+ export { PinPax } from './serial/pinpax';
16
+ export { Jofemar } from './serial/jofemar';
17
+ export { Boardroid } from './serial/boardroid';
18
+ export { Hopper } from './serial/hopper';
19
+ export { Devices } from './utils/devices';
20
+ export { Emulator } from './utils/emulator';
21
+ export { Socket } from 'webserial-core';
22
+ export declare const utils: {
23
+ wait: typeof wait;
24
+ getSeconds: typeof getSeconds;
25
+ supportWebSerial: typeof supportWebSerial;
26
+ };
27
+ export declare const version: any;
28
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../lib/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,eAAO,MAAM,KAAK;;;;CAIjB,CAAC;AAEF,eAAO,MAAM,OAAO,KAAmC,CAAC"}