From 22b6eb6a49aa8b5a2064c5b2bfbc77120777e4fb Mon Sep 17 00:00:00 2001 From: Romain Lamothe Date: Thu, 4 Jan 2024 00:17:26 +0100 Subject: [PATCH] 1.0.2 --- CHANGELOG.md | 3 +++ dist/vue-serial.mjs | 1 + dist/vue-serial.mjs.map | 1 + dist/vue-serial.umd.js | 1 + dist/vue-serial.umd.js.map | 1 + tsconfig.json | 2 +- vite.config.ts | 1 + 7 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 dist/vue-serial.mjs.map create mode 100644 dist/vue-serial.umd.js.map diff --git a/CHANGELOG.md b/CHANGELOG.md index af1f6b5..19bd1c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.0.2 +- Adding source maps for JS files + ## v1.0.1 Small build improvements: - Renaming vue-serial.js => .mjs and vue-serial.umd.cjs => .js diff --git a/dist/vue-serial.mjs b/dist/vue-serial.mjs index dfc7841..be6252d 100644 --- a/dist/vue-serial.mjs +++ b/dist/vue-serial.mjs @@ -413,3 +413,4 @@ T(x, "read"); export { x as default }; +//# sourceMappingURL=vue-serial.mjs.map diff --git a/dist/vue-serial.mjs.map b/dist/vue-serial.mjs.map new file mode 100644 index 0000000..6772ec6 --- /dev/null +++ b/dist/vue-serial.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"vue-serial.mjs","sources":["../src/vue-serial.ts"],"sourcesContent":["/// \nimport { ref } from 'vue';\nimport type { Ref } from 'vue';\n\n// Default values\nconst default_baudRate = 115200;\nconst default_dataBits = 8;\nconst default_stopBits = 1;\nconst default_parity = \"none\";\nconst default_bufferSize = 255;\nconst default_flowControl = \"none\";\n\n// Ignore localStorage if not available\nconst localStorage = window.localStorage ?? {};\n\n// Declare VueSerial class\nexport default class VueSerial extends EventTarget {\n\n /**\n * Event which is triggered when data is received from the open device port.\n * Call `serial.addEventListener(\"read\", ({ value }) => { ... })` to read incoming data.\n * @event\n */\n static read: string;\n \n // Initialize private variables with their default values\n #private = {\n port: null as SerialPort|null,\n reader: null as ReadableStreamDefaultReader|null,\n itv: null as ReturnType | null,\n isPolling: false,\n isOpen: ref(false),\n isConnected: ref(false),\n isClosing: ref(false),\n usbVendorId: ref(undefined) as Ref,\n usbProductId: ref(undefined) as Ref,\n baudRate: ref(localStorage.VueSerial_baudRate ?? default_baudRate) as Ref,\n dataBits: ref(localStorage.VueSerial_dataBits ?? default_dataBits) as Ref,\n stopBits: ref(localStorage.VueSerial_stopBits ?? default_stopBits) as Ref,\n parity: ref(localStorage.VueSerial_parity ?? default_parity) as Ref,\n bufferSize: ref(localStorage.VueSerial_bufferSize ?? default_bufferSize) as Ref,\n flowControl: ref(localStorage.VueSerial_flowControl ?? default_flowControl) as Ref,\n dataCarrierDetect: ref(false),\n clearToSend: ref(false),\n ringIndicator: ref(false),\n dataSetReady: ref(false),\n dataTerminalReady: ref(false),\n requestToSend: ref(false),\n break: ref(false)\n }\n\n // Private asynchronous receiving function\n async #start_receive () {\n if(!this.#private.port) return;\n while (this.#private.port.readable && this.#private.isClosing.value != true) {\n this.#private.reader = this.#private.port.readable.getReader();\n try {\n while (true) {\n const { value, done } = await this.#private.reader.read();\n if (done) {\n this.#private.reader.releaseLock(); // allow the serial port to be closed\n break;\n }\n if(value) {\n const event: any = new Event(\"read\");\n event.value = value;\n this.dispatchEvent(event);\n }\n }\n } catch (error) { console.log(error); } // read error (parity error, device lost, etc.)\n }\n }\n\n // Private port open function\n async #open () {\n if(this.#private.port) {\n const info = this.#private.port.getInfo();\n this.#private.usbVendorId.value = info.usbVendorId;\n this.#private.usbProductId.value = info.usbProductId;\n try {\n await this.#private.port.open({\n baudRate: this.#private.baudRate.value,\n dataBits: this.#private.dataBits.value,\n stopBits: this.#private.stopBits.value,\n parity: this.#private.parity.value,\n bufferSize: this.#private.bufferSize.value,\n flowControl: this.#private.flowControl.value\n });\n // throws here if the serial port is already open in another window\n this.#private.isOpen.value = true;\n this.#private.isConnected.value = true;\n this.#start_receive();\n } catch (e) {\n this.#private_reinitialize();\n throw e;\n }\n }\n }\n\n // Private reset connection function\n async #reconnect () {\n if(!this.#private.port || this.#private.isClosing.value) return; // prevent concurrent close actions\n this.#private.isClosing.value = true;\n try {\n if(this.#private.reader) await this.#private.reader.cancel();\n if(this.#private.port) await this.#private.port.close();\n this.#private.isClosing.value = false;\n await this.#open();\n } catch (e) {\n this.#private_reinitialize();\n this.stopSignalsPolling();\n console.error(e);\n }\n }\n\n // Private function for updating signals values\n async #update_signals () {\n if(!this.#private.port) throw new Error(\"Signals can't be retrieved as the port is closed\");\n const signals = await this.#private.port.getSignals();\n if(signals.clearToSend != this.#private.clearToSend.value) this.#private.clearToSend.value = signals.clearToSend;\n if(signals.dataCarrierDetect != this.#private.dataCarrierDetect.value) this.#private.dataCarrierDetect.value = signals.dataCarrierDetect;\n if(signals.dataSetReady != this.#private.dataSetReady.value) this.#private.dataSetReady.value = signals.dataSetReady;\n if(signals.ringIndicator != this.#private.ringIndicator.value) this.#private.ringIndicator.value = signals.ringIndicator;\n return signals;\n }\n\n // Private function for polling incoming signals periodically\n async #signals_polling () {\n if(this.#private.port) {\n if(!this.#private.isPolling) { // cancel if the previous polling has not finished (if polling interval is too low)\n this.#private.isPolling = true;\n try {\n await this.#update_signals();\n } catch (e) { }\n this.#private.isPolling = false;\n }\n }\n else this.stopSignalsPolling();\n }\n\n // Private function to reinitialize variables after closing the port\n #private_reinitialize () {\n this.#private.isOpen.value = false;\n this.#private.isConnected.value = false;\n this.#private.isClosing.value = false;\n this.#private.reader = null;\n this.#private.port = null;\n this.#private.dataCarrierDetect.value = false;\n this.#private.clearToSend.value = false;\n this.#private.ringIndicator.value = false;\n this.#private.dataSetReady.value = false;\n this.#private.dataTerminalReady.value = false;\n this.#private.requestToSend.value = false;\n this.#private.break.value = false;\n }\n \n /**\n * VueSerial instance constructor\n */\n constructor () {\n super(); // initialize EventTarget functionality\n if(!this.isAvailable) return; // return here if not available\n\n // close connection on hot-reloading (during development), as the status variables are reset to their default values\n import.meta?.hot?.on(\"vite:beforeUpdate\", () => this.close());\n\n // bind event listener for device disconnection\n navigator.serial?.addEventListener(\"disconnect\", (event) => {\n if(event.target == this.#private.port) this.#private.isConnected.value = false;\n });\n }\n\n /**\n * Constant property indicating if the serial feature is available on the client navigator (Web Serial API is implemented and page is served using HTTPS)\n * @readonly\n */\n get isAvailable () { return (navigator.serial && location.protocol == \"https:\"); }\n set isAvailable (x) { throw new Error(\"isAvailable is readonly\"); }\n\n /**\n * Restore defaults settings\n */\n restoreDefaults () {\n // these will also set localStorage values\n this.baudRate = default_baudRate;\n this.dataBits = default_dataBits;\n this.stopBits = default_stopBits;\n this.parity = default_parity;\n this.bufferSize = default_bufferSize;\n this.flowControl = default_flowControl;\n }\n\n /**\n * Ask the user to select the serial port and open it\n * @param filters - A list of objects containing vendor and product IDs used to search for attached devices.\n */\n async connect (filters: SerialPortFilter[] | undefined) {\n let port = null;\n // ask the user to select a port\n try {\n port = await navigator.serial.requestPort({ filters });\n // throws here if no serial port was selected by the user\n } catch (e) { }\n // open the port with the current defined settings\n if(port) {\n if(this.#private.port) await this.close();\n this.#private.port = port;\n await this.#open();\n }\n }\n\n /**\n * Close the current port if open\n */\n async close () {\n if(this.#private.isClosing.value) return; // prevent concurrent close actions\n this.#private.isClosing.value = true;\n try {\n if(this.#private.reader) await this.#private.reader.cancel();\n if(this.#private.port) {\n await this.#private.port.close();\n await this.#private.port.forget();\n }\n } catch (e) {\n throw e;\n } finally {\n this.#private_reinitialize();\n this.stopSignalsPolling();\n }\n }\n\n /**\n * Send data to the open serial port\n * @param value - The content to send\n */\n async write (value: Iterable) {\n if(this.#private.port && this.#private.port.writable) {\n if(typeof value == \"string\") {\n const encoder = new TextEncoder();\n value = encoder.encode(value);\n }\n const data = Uint8Array.from(value);\n const writer = this.#private.port.writable.getWriter();\n await writer.write(data);\n writer.releaseLock();\n }\n }\n\n /**\n * Get the DCD, CTS, RI and DSR signals (alternative to use built-in polling)\n * @returns Object containing \"dataCarrierDetect\", \"clearToSend\", \"ringIndicator\" and \"dataSetReady\" booleans\n * @note You can also get the same values in serial.dataCarrierDetect, serial.clearToSend, serial.ringIndicator and serial.dataSetReady\n */\n async getSignals (): Promise {\n return await this.#update_signals();\n }\n\n /**\n * Set the DTR, RTS and break signals\n * @param signals - object containing either \"dataTerminalReady\", \"requestToSend\" and/or \"break\" booleans\n * @note You can also set the serial.dataTerminalReady, serial.requestToSend, and serial.break variables if you don't need asynchronous control\n */\n async setSignals (signals: SerialOutputSignals) {\n if(this.#private.port) await this.#private.port.setSignals(signals);\n if(\"dataTerminalReady\" in signals && !!signals.dataTerminalReady != this.#private.dataTerminalReady.value) this.#private.dataTerminalReady.value = !!signals.dataTerminalReady;\n if(\"requestToSend\" in signals && !!signals.requestToSend != this.#private.requestToSend.value) this.#private.requestToSend.value = !!signals.requestToSend;\n if(\"break\" in signals && !!signals.break != this.#private.break.value) this.#private.break.value = !!signals.break;\n }\n\n /**\n * Start listening for signals changes and update the corresponding variables\n * @param interval_ms - Polling interval in ms (100ms if not specified)\n */\n startSignalsPolling (interval_ms: number | null) {\n if(this.#private.itv) clearInterval(this.#private.itv);\n this.#private.itv = setInterval(() => this.#signals_polling(), interval_ms ?? 100);\n }\n\n /**\n * Stop listening for signal changes\n */\n stopSignalsPolling () {\n if(this.#private.itv) clearInterval(this.#private.itv);\n this.#private.itv = null;\n }\n\n /**\n * Tracks the active state of the serial port\n * @readonly\n */\n get isOpen () { return this.#private.isOpen.value; }\n set isOpen (x) { throw new Error(\"isOpen value is readonly\"); }\n\n /**\n * Becomes false if the open device has been disconnected\n * @readonly\n */\n get isConnected () { return this.#private.isConnected.value; }\n set isConnected (x) { throw new Error(\"isConnected value is readonly\"); }\n\n /**\n * Becomes true when the device is currently closing (after the close() function has been called)\n * @readonly\n */\n get isClosing () { return this.#private.isClosing.value; }\n set isClosing (x) { throw new Error(\"isClosing value is readonly\"); }\n\n /**\n * Current port USB vendor ID\n * @readonly\n */\n get usbVendorId () { return this.#private.usbVendorId.value; }\n set usbVendorId (x) { throw new Error(\"usbVendorId value is readonly\"); }\n\n /**\n * Current port USB product ID\n * @readonly\n */\n get usbProductId () { return this.#private.usbProductId.value; }\n set usbProductId (x) { throw new Error(\"usbProductId value is readonly\"); }\n\n /**\n * A positive, non-zero value indicating the baud rate at which serial communication should be established\n */\n get baudRate () { return this.#private.baudRate.value; }\n set baudRate(value: number) {\n const new_value = Math.floor(Number(value));\n if(isNaN(new_value) || new_value <= 0) throw new Error(\"baudRate value must be a positive, non-zero value\");\n if(new_value != this.#private.baudRate.value) {\n this.#private.baudRate.value = new_value;\n localStorage.VueSerial_baudRate = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * The number of data bits per frame (either 7 or 8)\n */\n get dataBits () { return this.#private.dataBits.value; }\n set dataBits(value) {\n const new_value = (Math.floor(Number(value)) == 7) ? 7 : 8;\n if(new_value != this.#private.dataBits.value) {\n this.#private.dataBits.value = new_value;\n localStorage.VueSerial_dataBits = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * The number of stop bits per frame (either 1 or 2)\n */\n get stopBits () { return this.#private.stopBits.value; }\n set stopBits (value) {\n const new_value = (Math.floor(Number(value)) == 2) ? 2 : 1;\n if(new_value != this.#private.stopBits.value) {\n this.#private.stopBits.value = new_value;\n localStorage.VueSerial_stopBits = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * The parity mode (either \"none\", \"even\" or \"odd\")\n */\n get parity () { return this.#private.parity.value; }\n set parity (value) {\n const new_value = (value == \"even\") ? \"even\" : ((value == \"odd\") ? \"odd\" : \"none\");\n if(new_value != this.#private.parity.value) {\n this.#private.parity.value = new_value;\n localStorage.VueSerial_parity = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * A positive, non-zero value indicating the size of the read and write buffers that should be created.\n */\n get bufferSize () { return this.#private.bufferSize.value; }\n set bufferSize (value) {\n const new_value = Math.floor(Number(value));\n if(isNaN(new_value) || new_value <= 0) throw new Error(\"bufferSize value must be a positive, non-zero value\");\n if(new_value != this.#private.bufferSize.value) {\n this.#private.bufferSize.value = new_value;\n localStorage.VueSerial_bufferSize = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * The flow control mode (either \"hardware\" or \"none\")\n */\n get flowControl () { return this.#private.flowControl.value; }\n set flowControl (value) {\n const new_value = (value == \"hardware\" ? \"hardware\" : \"none\");\n if(new_value != this.#private.flowControl.value) {\n this.#private.flowControl.value = new_value;\n localStorage.VueSerial_flowControl = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * Data Carrier Detect (DCD) input signal value\n * @remarks This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)\n * @readonly\n */\n get dataCarrierDetect () { return this.#private.dataCarrierDetect.value; }\n set dataCarrierDetect (x) { throw new Error(\"dataCarrierDetect value is readonly\"); }\n\n /**\n * Clear To Send (CTS) input signal value\n * @remarks This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)\n * @readonly\n */\n get clearToSend () { return this.#private.clearToSend.value; }\n set clearToSend (x) { throw new Error(\"clearToSend value is readonly\"); }\n\n /**\n * Ring Indicator (RI) input signal value\n * @remarks This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)\n * @readonly\n */\n get ringIndicator () { return this.#private.ringIndicator.value; }\n set ringIndicator (x) { throw new Error(\"ringIndicator value is readonly\"); }\n\n /**\n * Data Set Ready (DSR) input signal value\n * @remarks This value must be refreshed manually by calling `serial.getSignals()` or automatically with serial.startSignalsPolling(...)\n * @readonly\n */\n get dataSetReady () { return this.#private.dataSetReady.value; }\n set dataSetReady (x) { throw new Error(\"dataSetReady value is readonly\"); }\n\n /**\n * Data Terminal Ready (DTR) output signal value\n */\n get dataTerminalReady () { return this.#private.dataTerminalReady.value; }\n /**\n * @remarks This will be set asynchronously. Prefer `await serial.setSignals({ dataTerminalReady: ... })` for precise asynchronous control\n */\n set dataTerminalReady (value) {\n this.#private.dataTerminalReady.value = !!value;\n if(this.#private.port) this.#private.port.setSignals({ dataTerminalReady: this.#private.dataTerminalReady.value });\n }\n\n /**\n * Request To Send (RTS) output signal value\n */\n get requestToSend () { return this.#private.requestToSend.value; }\n /**\n * @remarks This will be set asynchronously. Prefer `await serial.setSignals({ requestToSend: ... })` for precise asynchronous control\n */\n set requestToSend (value) {\n this.#private.requestToSend.value = !!value;\n if(this.#private.port) this.#private.port.setSignals({ requestToSend: this.#private.requestToSend.value });\n }\n\n /**\n * Break output signal value\n */\n get break () { return this.#private.break.value; }\n /**\n * @remarks This will be set asynchronously. Prefer `await serial.setSignals({ break: ... })` for precise asynchronous control\n */\n set break (value) {\n this.#private.break.value = !!value;\n if(this.#private.port) this.#private.port.setSignals({ break: this.#private.break.value });\n }\n\n}"],"names":["default_baudRate","default_dataBits","default_stopBits","default_parity","default_bufferSize","default_flowControl","localStorage","VueSerial","__privateAdd","_start_receive","_open","_reconnect","_update_signals","_signals_polling","_private_reinitialize","_private","ref","_b","_a","_c","event","__privateGet","x","filters","port","__privateMethod","open_fn","e","private_reinitialize_fn","value","data","writer","update_signals_fn","signals","interval_ms","signals_polling_fn","new_value","reconnect_fn","start_receive_fn","done","error","info","__publicField"],"mappings":";;;;;;;;;;;;;AAKA,MAAMA,IAAmB,QACnBC,IAAmB,GACnBC,IAAmB,GACnBC,IAAiB,QACjBC,IAAqB,KACrBC,IAAsB,QAGtBC,IAAe,OAAO,gBAAgB;;AAG5C,MAAqBC,UAAkB,YAAY;AAAA;AAAA;AAAA;AAAA,EA+IjD,cAAe;;AACP;AA5GR;AAAA,IAAAC,EAAA,MAAMC;AAsBN;AAAA,IAAAD,EAAA,MAAME;AA0BN;AAAA,IAAAF,EAAA,MAAMG;AAgBN;AAAA,IAAAH,EAAA,MAAMI;AAWN;AAAA,IAAAJ,EAAA,MAAMK;AAcN;AAAA,IAAAL,EAAA,MAAAM;AAnHA;AAAA,IAAAN,EAAA,MAAAO,GAAW;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,MAAAN,GAAS,cAAc,QAAQkB,EAAQ,gBACpGA;AACT,GAGMpB,IAAA,eAAAsB,IAAoB,iBAAA;AACrB,MAAAd,EAAA,MAAKN,GAAS;AACZ,QAAA,CAACM,EAAA,MAAKN,GAAS,WAAW;AAC3B,MAAAM,EAAA,MAAKN,GAAS,YAAY;AACtB,UAAA;AACF,cAAMU,EAAA,MAAKb,GAAAoB,GAAL;AAAA,cACI;AAAA,MAAE;AACd,MAAAX,EAAA,MAAKN,GAAS,YAAY;AAAA,IAC5B;AAAA;AAEG,SAAK,mBAAmB;AAC/B,GAGAD,IAAA,eAAAc,IAAyB,WAAA;AAClB,EAAAP,EAAA,MAAAN,GAAS,OAAO,QAAQ,IACxBM,EAAA,MAAAN,GAAS,YAAY,QAAQ,IAC7BM,EAAA,MAAAN,GAAS,UAAU,QAAQ,IAChCM,EAAA,MAAKN,GAAS,SAAS,MACvBM,EAAA,MAAKN,GAAS,OAAO,MAChBM,EAAA,MAAAN,GAAS,kBAAkB,QAAQ,IACnCM,EAAA,MAAAN,GAAS,YAAY,QAAQ,IAC7BM,EAAA,MAAAN,GAAS,cAAc,QAAQ,IAC/BM,EAAA,MAAAN,GAAS,aAAa,QAAQ,IAC9BM,EAAA,MAAAN,GAAS,kBAAkB,QAAQ,IACnCM,EAAA,MAAAN,GAAS,cAAc,QAAQ,IAC/BM,EAAA,MAAAN,GAAS,MAAM,QAAQ;AAC9B;AAAA;AAAA;AAAA;AAAA;AAnIA2B,EAPmBnC,GAOZ;"} \ No newline at end of file diff --git a/dist/vue-serial.umd.js b/dist/vue-serial.umd.js index 8413400..5acf43f 100644 --- a/dist/vue-serial.umd.js +++ b/dist/vue-serial.umd.js @@ -1 +1,2 @@ var V=Object.defineProperty;var z=(i,s,o)=>s in i?V(i,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[s]=o;var _=(i,s,o)=>(z(i,typeof s!="symbol"?s+"":s,o),o),B=(i,s,o)=>{if(!s.has(i))throw TypeError("Cannot "+o)};var t=(i,s,o)=>(B(i,s,"read from private field"),o?o.call(i):s.get(i)),d=(i,s,o)=>{if(s.has(i))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(i):s.set(i,o)};var l=(i,s,o)=>(B(i,s,"access private method"),o);(function(i,s){typeof exports=="object"&&typeof module<"u"?module.exports=s(require("vue")):typeof define=="function"&&define.amd?define(["vue"],s):(i=typeof globalThis<"u"?globalThis:i||self,i.VueSerial=s(i.Vue))})(this,function(i){var e,S,I,v,g,u,h,p,y,w,m,f,b;"use strict";const C="none",T="none",n=window.localStorage??{};class R extends EventTarget{constructor(){var a;super();d(this,S);d(this,v);d(this,u);d(this,p);d(this,w);d(this,f);d(this,e,{port:null,reader:null,itv:null,isPolling:!1,isOpen:i.ref(!1),isConnected:i.ref(!1),isClosing:i.ref(!1),usbVendorId:i.ref(void 0),usbProductId:i.ref(void 0),baudRate:i.ref(n.VueSerial_baudRate??115200),dataBits:i.ref(n.VueSerial_dataBits??8),stopBits:i.ref(n.VueSerial_stopBits??1),parity:i.ref(n.VueSerial_parity??C),bufferSize:i.ref(n.VueSerial_bufferSize??255),flowControl:i.ref(n.VueSerial_flowControl??T),dataCarrierDetect:i.ref(!1),clearToSend:i.ref(!1),ringIndicator:i.ref(!1),dataSetReady:i.ref(!1),dataTerminalReady:i.ref(!1),requestToSend:i.ref(!1),break:i.ref(!1)});this.isAvailable&&((a=navigator.serial)==null||a.addEventListener("disconnect",r=>{r.target==t(this,e).port&&(t(this,e).isConnected.value=!1)}))}get isAvailable(){return navigator.serial&&location.protocol=="https:"}set isAvailable(a){throw new Error("isAvailable is readonly")}restoreDefaults(){this.baudRate=115200,this.dataBits=8,this.stopBits=1,this.parity=C,this.bufferSize=255,this.flowControl=T}async connect(a){let r=null;try{r=await navigator.serial.requestPort({filters:a})}catch{}r&&(t(this,e).port&&await this.close(),t(this,e).port=r,await l(this,v,g).call(this))}async close(){if(!t(this,e).isClosing.value){t(this,e).isClosing.value=!0;try{t(this,e).reader&&await t(this,e).reader.cancel(),t(this,e).port&&(await t(this,e).port.close(),await t(this,e).port.forget())}catch(a){throw a}finally{l(this,f,b).call(this),this.stopSignalsPolling()}}}async write(a){if(t(this,e).port&&t(this,e).port.writable){typeof a=="string"&&(a=new TextEncoder().encode(a));const r=Uint8Array.from(a),c=t(this,e).port.writable.getWriter();await c.write(r),c.releaseLock()}}async getSignals(){return await l(this,p,y).call(this)}async setSignals(a){t(this,e).port&&await t(this,e).port.setSignals(a),"dataTerminalReady"in a&&!!a.dataTerminalReady!=t(this,e).dataTerminalReady.value&&(t(this,e).dataTerminalReady.value=!!a.dataTerminalReady),"requestToSend"in a&&!!a.requestToSend!=t(this,e).requestToSend.value&&(t(this,e).requestToSend.value=!!a.requestToSend),"break"in a&&!!a.break!=t(this,e).break.value&&(t(this,e).break.value=!!a.break)}startSignalsPolling(a){t(this,e).itv&&clearInterval(t(this,e).itv),t(this,e).itv=setInterval(()=>l(this,w,m).call(this),a??100)}stopSignalsPolling(){t(this,e).itv&&clearInterval(t(this,e).itv),t(this,e).itv=null}get isOpen(){return t(this,e).isOpen.value}set isOpen(a){throw new Error("isOpen value is readonly")}get isConnected(){return t(this,e).isConnected.value}set isConnected(a){throw new Error("isConnected value is readonly")}get isClosing(){return t(this,e).isClosing.value}set isClosing(a){throw new Error("isClosing value is readonly")}get usbVendorId(){return t(this,e).usbVendorId.value}set usbVendorId(a){throw new Error("usbVendorId value is readonly")}get usbProductId(){return t(this,e).usbProductId.value}set usbProductId(a){throw new Error("usbProductId value is readonly")}get baudRate(){return t(this,e).baudRate.value}set baudRate(a){const r=Math.floor(Number(a));if(isNaN(r)||r<=0)throw new Error("baudRate value must be a positive, non-zero value");r!=t(this,e).baudRate.value&&(t(this,e).baudRate.value=r,n.VueSerial_baudRate=r,t(this,e).port&&l(this,u,h).call(this))}get dataBits(){return t(this,e).dataBits.value}set dataBits(a){const r=Math.floor(Number(a))==7?7:8;r!=t(this,e).dataBits.value&&(t(this,e).dataBits.value=r,n.VueSerial_dataBits=r,t(this,e).port&&l(this,u,h).call(this))}get stopBits(){return t(this,e).stopBits.value}set stopBits(a){const r=Math.floor(Number(a))==2?2:1;r!=t(this,e).stopBits.value&&(t(this,e).stopBits.value=r,n.VueSerial_stopBits=r,t(this,e).port&&l(this,u,h).call(this))}get parity(){return t(this,e).parity.value}set parity(a){const r=a=="even"?"even":a=="odd"?"odd":"none";r!=t(this,e).parity.value&&(t(this,e).parity.value=r,n.VueSerial_parity=r,t(this,e).port&&l(this,u,h).call(this))}get bufferSize(){return t(this,e).bufferSize.value}set bufferSize(a){const r=Math.floor(Number(a));if(isNaN(r)||r<=0)throw new Error("bufferSize value must be a positive, non-zero value");r!=t(this,e).bufferSize.value&&(t(this,e).bufferSize.value=r,n.VueSerial_bufferSize=r,t(this,e).port&&l(this,u,h).call(this))}get flowControl(){return t(this,e).flowControl.value}set flowControl(a){const r=a=="hardware"?"hardware":"none";r!=t(this,e).flowControl.value&&(t(this,e).flowControl.value=r,n.VueSerial_flowControl=r,t(this,e).port&&l(this,u,h).call(this))}get dataCarrierDetect(){return t(this,e).dataCarrierDetect.value}set dataCarrierDetect(a){throw new Error("dataCarrierDetect value is readonly")}get clearToSend(){return t(this,e).clearToSend.value}set clearToSend(a){throw new Error("clearToSend value is readonly")}get ringIndicator(){return t(this,e).ringIndicator.value}set ringIndicator(a){throw new Error("ringIndicator value is readonly")}get dataSetReady(){return t(this,e).dataSetReady.value}set dataSetReady(a){throw new Error("dataSetReady value is readonly")}get dataTerminalReady(){return t(this,e).dataTerminalReady.value}set dataTerminalReady(a){t(this,e).dataTerminalReady.value=!!a,t(this,e).port&&t(this,e).port.setSignals({dataTerminalReady:t(this,e).dataTerminalReady.value})}get requestToSend(){return t(this,e).requestToSend.value}set requestToSend(a){t(this,e).requestToSend.value=!!a,t(this,e).port&&t(this,e).port.setSignals({requestToSend:t(this,e).requestToSend.value})}get break(){return t(this,e).break.value}set break(a){t(this,e).break.value=!!a,t(this,e).port&&t(this,e).port.setSignals({break:t(this,e).break.value})}}return e=new WeakMap,S=new WeakSet,I=async function(){if(t(this,e).port)for(;t(this,e).port.readable&&t(this,e).isClosing.value!=!0;){t(this,e).reader=t(this,e).port.readable.getReader();try{for(;;){const{value:a,done:r}=await t(this,e).reader.read();if(r){t(this,e).reader.releaseLock();break}if(a){const c=new Event("read");c.value=a,this.dispatchEvent(c)}}}catch(a){console.log(a)}}},v=new WeakSet,g=async function(){if(t(this,e).port){const a=t(this,e).port.getInfo();t(this,e).usbVendorId.value=a.usbVendorId,t(this,e).usbProductId.value=a.usbProductId;try{await t(this,e).port.open({baudRate:t(this,e).baudRate.value,dataBits:t(this,e).dataBits.value,stopBits:t(this,e).stopBits.value,parity:t(this,e).parity.value,bufferSize:t(this,e).bufferSize.value,flowControl:t(this,e).flowControl.value}),t(this,e).isOpen.value=!0,t(this,e).isConnected.value=!0,l(this,S,I).call(this)}catch(r){throw l(this,f,b).call(this),r}}},u=new WeakSet,h=async function(){if(!(!t(this,e).port||t(this,e).isClosing.value)){t(this,e).isClosing.value=!0;try{t(this,e).reader&&await t(this,e).reader.cancel(),t(this,e).port&&await t(this,e).port.close(),t(this,e).isClosing.value=!1,await l(this,v,g).call(this)}catch(a){l(this,f,b).call(this),this.stopSignalsPolling(),console.error(a)}}},p=new WeakSet,y=async function(){if(!t(this,e).port)throw new Error("Signals can't be retrieved as the port is closed");const a=await t(this,e).port.getSignals();return a.clearToSend!=t(this,e).clearToSend.value&&(t(this,e).clearToSend.value=a.clearToSend),a.dataCarrierDetect!=t(this,e).dataCarrierDetect.value&&(t(this,e).dataCarrierDetect.value=a.dataCarrierDetect),a.dataSetReady!=t(this,e).dataSetReady.value&&(t(this,e).dataSetReady.value=a.dataSetReady),a.ringIndicator!=t(this,e).ringIndicator.value&&(t(this,e).ringIndicator.value=a.ringIndicator),a},w=new WeakSet,m=async function(){if(t(this,e).port){if(!t(this,e).isPolling){t(this,e).isPolling=!0;try{await l(this,p,y).call(this)}catch{}t(this,e).isPolling=!1}}else this.stopSignalsPolling()},f=new WeakSet,b=function(){t(this,e).isOpen.value=!1,t(this,e).isConnected.value=!1,t(this,e).isClosing.value=!1,t(this,e).reader=null,t(this,e).port=null,t(this,e).dataCarrierDetect.value=!1,t(this,e).clearToSend.value=!1,t(this,e).ringIndicator.value=!1,t(this,e).dataSetReady.value=!1,t(this,e).dataTerminalReady.value=!1,t(this,e).requestToSend.value=!1,t(this,e).break.value=!1},_(R,"read"),R}); +//# sourceMappingURL=vue-serial.umd.js.map diff --git a/dist/vue-serial.umd.js.map b/dist/vue-serial.umd.js.map new file mode 100644 index 0000000..f8dcfbe --- /dev/null +++ b/dist/vue-serial.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vue-serial.umd.js","sources":["../src/vue-serial.ts"],"sourcesContent":["/// \nimport { ref } from 'vue';\nimport type { Ref } from 'vue';\n\n// Default values\nconst default_baudRate = 115200;\nconst default_dataBits = 8;\nconst default_stopBits = 1;\nconst default_parity = \"none\";\nconst default_bufferSize = 255;\nconst default_flowControl = \"none\";\n\n// Ignore localStorage if not available\nconst localStorage = window.localStorage ?? {};\n\n// Declare VueSerial class\nexport default class VueSerial extends EventTarget {\n\n /**\n * Event which is triggered when data is received from the open device port.\n * Call `serial.addEventListener(\"read\", ({ value }) => { ... })` to read incoming data.\n * @event\n */\n static read: string;\n \n // Initialize private variables with their default values\n #private = {\n port: null as SerialPort|null,\n reader: null as ReadableStreamDefaultReader|null,\n itv: null as ReturnType | null,\n isPolling: false,\n isOpen: ref(false),\n isConnected: ref(false),\n isClosing: ref(false),\n usbVendorId: ref(undefined) as Ref,\n usbProductId: ref(undefined) as Ref,\n baudRate: ref(localStorage.VueSerial_baudRate ?? default_baudRate) as Ref,\n dataBits: ref(localStorage.VueSerial_dataBits ?? default_dataBits) as Ref,\n stopBits: ref(localStorage.VueSerial_stopBits ?? default_stopBits) as Ref,\n parity: ref(localStorage.VueSerial_parity ?? default_parity) as Ref,\n bufferSize: ref(localStorage.VueSerial_bufferSize ?? default_bufferSize) as Ref,\n flowControl: ref(localStorage.VueSerial_flowControl ?? default_flowControl) as Ref,\n dataCarrierDetect: ref(false),\n clearToSend: ref(false),\n ringIndicator: ref(false),\n dataSetReady: ref(false),\n dataTerminalReady: ref(false),\n requestToSend: ref(false),\n break: ref(false)\n }\n\n // Private asynchronous receiving function\n async #start_receive () {\n if(!this.#private.port) return;\n while (this.#private.port.readable && this.#private.isClosing.value != true) {\n this.#private.reader = this.#private.port.readable.getReader();\n try {\n while (true) {\n const { value, done } = await this.#private.reader.read();\n if (done) {\n this.#private.reader.releaseLock(); // allow the serial port to be closed\n break;\n }\n if(value) {\n const event: any = new Event(\"read\");\n event.value = value;\n this.dispatchEvent(event);\n }\n }\n } catch (error) { console.log(error); } // read error (parity error, device lost, etc.)\n }\n }\n\n // Private port open function\n async #open () {\n if(this.#private.port) {\n const info = this.#private.port.getInfo();\n this.#private.usbVendorId.value = info.usbVendorId;\n this.#private.usbProductId.value = info.usbProductId;\n try {\n await this.#private.port.open({\n baudRate: this.#private.baudRate.value,\n dataBits: this.#private.dataBits.value,\n stopBits: this.#private.stopBits.value,\n parity: this.#private.parity.value,\n bufferSize: this.#private.bufferSize.value,\n flowControl: this.#private.flowControl.value\n });\n // throws here if the serial port is already open in another window\n this.#private.isOpen.value = true;\n this.#private.isConnected.value = true;\n this.#start_receive();\n } catch (e) {\n this.#private_reinitialize();\n throw e;\n }\n }\n }\n\n // Private reset connection function\n async #reconnect () {\n if(!this.#private.port || this.#private.isClosing.value) return; // prevent concurrent close actions\n this.#private.isClosing.value = true;\n try {\n if(this.#private.reader) await this.#private.reader.cancel();\n if(this.#private.port) await this.#private.port.close();\n this.#private.isClosing.value = false;\n await this.#open();\n } catch (e) {\n this.#private_reinitialize();\n this.stopSignalsPolling();\n console.error(e);\n }\n }\n\n // Private function for updating signals values\n async #update_signals () {\n if(!this.#private.port) throw new Error(\"Signals can't be retrieved as the port is closed\");\n const signals = await this.#private.port.getSignals();\n if(signals.clearToSend != this.#private.clearToSend.value) this.#private.clearToSend.value = signals.clearToSend;\n if(signals.dataCarrierDetect != this.#private.dataCarrierDetect.value) this.#private.dataCarrierDetect.value = signals.dataCarrierDetect;\n if(signals.dataSetReady != this.#private.dataSetReady.value) this.#private.dataSetReady.value = signals.dataSetReady;\n if(signals.ringIndicator != this.#private.ringIndicator.value) this.#private.ringIndicator.value = signals.ringIndicator;\n return signals;\n }\n\n // Private function for polling incoming signals periodically\n async #signals_polling () {\n if(this.#private.port) {\n if(!this.#private.isPolling) { // cancel if the previous polling has not finished (if polling interval is too low)\n this.#private.isPolling = true;\n try {\n await this.#update_signals();\n } catch (e) { }\n this.#private.isPolling = false;\n }\n }\n else this.stopSignalsPolling();\n }\n\n // Private function to reinitialize variables after closing the port\n #private_reinitialize () {\n this.#private.isOpen.value = false;\n this.#private.isConnected.value = false;\n this.#private.isClosing.value = false;\n this.#private.reader = null;\n this.#private.port = null;\n this.#private.dataCarrierDetect.value = false;\n this.#private.clearToSend.value = false;\n this.#private.ringIndicator.value = false;\n this.#private.dataSetReady.value = false;\n this.#private.dataTerminalReady.value = false;\n this.#private.requestToSend.value = false;\n this.#private.break.value = false;\n }\n \n /**\n * VueSerial instance constructor\n */\n constructor () {\n super(); // initialize EventTarget functionality\n if(!this.isAvailable) return; // return here if not available\n\n // close connection on hot-reloading (during development), as the status variables are reset to their default values\n import.meta?.hot?.on(\"vite:beforeUpdate\", () => this.close());\n\n // bind event listener for device disconnection\n navigator.serial?.addEventListener(\"disconnect\", (event) => {\n if(event.target == this.#private.port) this.#private.isConnected.value = false;\n });\n }\n\n /**\n * Constant property indicating if the serial feature is available on the client navigator (Web Serial API is implemented and page is served using HTTPS)\n * @readonly\n */\n get isAvailable () { return (navigator.serial && location.protocol == \"https:\"); }\n set isAvailable (x) { throw new Error(\"isAvailable is readonly\"); }\n\n /**\n * Restore defaults settings\n */\n restoreDefaults () {\n // these will also set localStorage values\n this.baudRate = default_baudRate;\n this.dataBits = default_dataBits;\n this.stopBits = default_stopBits;\n this.parity = default_parity;\n this.bufferSize = default_bufferSize;\n this.flowControl = default_flowControl;\n }\n\n /**\n * Ask the user to select the serial port and open it\n * @param filters - A list of objects containing vendor and product IDs used to search for attached devices.\n */\n async connect (filters: SerialPortFilter[] | undefined) {\n let port = null;\n // ask the user to select a port\n try {\n port = await navigator.serial.requestPort({ filters });\n // throws here if no serial port was selected by the user\n } catch (e) { }\n // open the port with the current defined settings\n if(port) {\n if(this.#private.port) await this.close();\n this.#private.port = port;\n await this.#open();\n }\n }\n\n /**\n * Close the current port if open\n */\n async close () {\n if(this.#private.isClosing.value) return; // prevent concurrent close actions\n this.#private.isClosing.value = true;\n try {\n if(this.#private.reader) await this.#private.reader.cancel();\n if(this.#private.port) {\n await this.#private.port.close();\n await this.#private.port.forget();\n }\n } catch (e) {\n throw e;\n } finally {\n this.#private_reinitialize();\n this.stopSignalsPolling();\n }\n }\n\n /**\n * Send data to the open serial port\n * @param value - The content to send\n */\n async write (value: Iterable) {\n if(this.#private.port && this.#private.port.writable) {\n if(typeof value == \"string\") {\n const encoder = new TextEncoder();\n value = encoder.encode(value);\n }\n const data = Uint8Array.from(value);\n const writer = this.#private.port.writable.getWriter();\n await writer.write(data);\n writer.releaseLock();\n }\n }\n\n /**\n * Get the DCD, CTS, RI and DSR signals (alternative to use built-in polling)\n * @returns Object containing \"dataCarrierDetect\", \"clearToSend\", \"ringIndicator\" and \"dataSetReady\" booleans\n * @note You can also get the same values in serial.dataCarrierDetect, serial.clearToSend, serial.ringIndicator and serial.dataSetReady\n */\n async getSignals (): Promise {\n return await this.#update_signals();\n }\n\n /**\n * Set the DTR, RTS and break signals\n * @param signals - object containing either \"dataTerminalReady\", \"requestToSend\" and/or \"break\" booleans\n * @note You can also set the serial.dataTerminalReady, serial.requestToSend, and serial.break variables if you don't need asynchronous control\n */\n async setSignals (signals: SerialOutputSignals) {\n if(this.#private.port) await this.#private.port.setSignals(signals);\n if(\"dataTerminalReady\" in signals && !!signals.dataTerminalReady != this.#private.dataTerminalReady.value) this.#private.dataTerminalReady.value = !!signals.dataTerminalReady;\n if(\"requestToSend\" in signals && !!signals.requestToSend != this.#private.requestToSend.value) this.#private.requestToSend.value = !!signals.requestToSend;\n if(\"break\" in signals && !!signals.break != this.#private.break.value) this.#private.break.value = !!signals.break;\n }\n\n /**\n * Start listening for signals changes and update the corresponding variables\n * @param interval_ms - Polling interval in ms (100ms if not specified)\n */\n startSignalsPolling (interval_ms: number | null) {\n if(this.#private.itv) clearInterval(this.#private.itv);\n this.#private.itv = setInterval(() => this.#signals_polling(), interval_ms ?? 100);\n }\n\n /**\n * Stop listening for signal changes\n */\n stopSignalsPolling () {\n if(this.#private.itv) clearInterval(this.#private.itv);\n this.#private.itv = null;\n }\n\n /**\n * Tracks the active state of the serial port\n * @readonly\n */\n get isOpen () { return this.#private.isOpen.value; }\n set isOpen (x) { throw new Error(\"isOpen value is readonly\"); }\n\n /**\n * Becomes false if the open device has been disconnected\n * @readonly\n */\n get isConnected () { return this.#private.isConnected.value; }\n set isConnected (x) { throw new Error(\"isConnected value is readonly\"); }\n\n /**\n * Becomes true when the device is currently closing (after the close() function has been called)\n * @readonly\n */\n get isClosing () { return this.#private.isClosing.value; }\n set isClosing (x) { throw new Error(\"isClosing value is readonly\"); }\n\n /**\n * Current port USB vendor ID\n * @readonly\n */\n get usbVendorId () { return this.#private.usbVendorId.value; }\n set usbVendorId (x) { throw new Error(\"usbVendorId value is readonly\"); }\n\n /**\n * Current port USB product ID\n * @readonly\n */\n get usbProductId () { return this.#private.usbProductId.value; }\n set usbProductId (x) { throw new Error(\"usbProductId value is readonly\"); }\n\n /**\n * A positive, non-zero value indicating the baud rate at which serial communication should be established\n */\n get baudRate () { return this.#private.baudRate.value; }\n set baudRate(value: number) {\n const new_value = Math.floor(Number(value));\n if(isNaN(new_value) || new_value <= 0) throw new Error(\"baudRate value must be a positive, non-zero value\");\n if(new_value != this.#private.baudRate.value) {\n this.#private.baudRate.value = new_value;\n localStorage.VueSerial_baudRate = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * The number of data bits per frame (either 7 or 8)\n */\n get dataBits () { return this.#private.dataBits.value; }\n set dataBits(value) {\n const new_value = (Math.floor(Number(value)) == 7) ? 7 : 8;\n if(new_value != this.#private.dataBits.value) {\n this.#private.dataBits.value = new_value;\n localStorage.VueSerial_dataBits = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * The number of stop bits per frame (either 1 or 2)\n */\n get stopBits () { return this.#private.stopBits.value; }\n set stopBits (value) {\n const new_value = (Math.floor(Number(value)) == 2) ? 2 : 1;\n if(new_value != this.#private.stopBits.value) {\n this.#private.stopBits.value = new_value;\n localStorage.VueSerial_stopBits = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * The parity mode (either \"none\", \"even\" or \"odd\")\n */\n get parity () { return this.#private.parity.value; }\n set parity (value) {\n const new_value = (value == \"even\") ? \"even\" : ((value == \"odd\") ? \"odd\" : \"none\");\n if(new_value != this.#private.parity.value) {\n this.#private.parity.value = new_value;\n localStorage.VueSerial_parity = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * A positive, non-zero value indicating the size of the read and write buffers that should be created.\n */\n get bufferSize () { return this.#private.bufferSize.value; }\n set bufferSize (value) {\n const new_value = Math.floor(Number(value));\n if(isNaN(new_value) || new_value <= 0) throw new Error(\"bufferSize value must be a positive, non-zero value\");\n if(new_value != this.#private.bufferSize.value) {\n this.#private.bufferSize.value = new_value;\n localStorage.VueSerial_bufferSize = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * The flow control mode (either \"hardware\" or \"none\")\n */\n get flowControl () { return this.#private.flowControl.value; }\n set flowControl (value) {\n const new_value = (value == \"hardware\" ? \"hardware\" : \"none\");\n if(new_value != this.#private.flowControl.value) {\n this.#private.flowControl.value = new_value;\n localStorage.VueSerial_flowControl = new_value;\n if(this.#private.port) this.#reconnect();\n }\n }\n\n /**\n * Data Carrier Detect (DCD) input signal value\n * @remarks This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)\n * @readonly\n */\n get dataCarrierDetect () { return this.#private.dataCarrierDetect.value; }\n set dataCarrierDetect (x) { throw new Error(\"dataCarrierDetect value is readonly\"); }\n\n /**\n * Clear To Send (CTS) input signal value\n * @remarks This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)\n * @readonly\n */\n get clearToSend () { return this.#private.clearToSend.value; }\n set clearToSend (x) { throw new Error(\"clearToSend value is readonly\"); }\n\n /**\n * Ring Indicator (RI) input signal value\n * @remarks This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)\n * @readonly\n */\n get ringIndicator () { return this.#private.ringIndicator.value; }\n set ringIndicator (x) { throw new Error(\"ringIndicator value is readonly\"); }\n\n /**\n * Data Set Ready (DSR) input signal value\n * @remarks This value must be refreshed manually by calling `serial.getSignals()` or automatically with serial.startSignalsPolling(...)\n * @readonly\n */\n get dataSetReady () { return this.#private.dataSetReady.value; }\n set dataSetReady (x) { throw new Error(\"dataSetReady value is readonly\"); }\n\n /**\n * Data Terminal Ready (DTR) output signal value\n */\n get dataTerminalReady () { return this.#private.dataTerminalReady.value; }\n /**\n * @remarks This will be set asynchronously. Prefer `await serial.setSignals({ dataTerminalReady: ... })` for precise asynchronous control\n */\n set dataTerminalReady (value) {\n this.#private.dataTerminalReady.value = !!value;\n if(this.#private.port) this.#private.port.setSignals({ dataTerminalReady: this.#private.dataTerminalReady.value });\n }\n\n /**\n * Request To Send (RTS) output signal value\n */\n get requestToSend () { return this.#private.requestToSend.value; }\n /**\n * @remarks This will be set asynchronously. Prefer `await serial.setSignals({ requestToSend: ... })` for precise asynchronous control\n */\n set requestToSend (value) {\n this.#private.requestToSend.value = !!value;\n if(this.#private.port) this.#private.port.setSignals({ requestToSend: this.#private.requestToSend.value });\n }\n\n /**\n * Break output signal value\n */\n get break () { return this.#private.break.value; }\n /**\n * @remarks This will be set asynchronously. Prefer `await serial.setSignals({ break: ... })` for precise asynchronous control\n */\n set break (value) {\n this.#private.break.value = !!value;\n if(this.#private.port) this.#private.port.setSignals({ break: this.#private.break.value });\n }\n\n}"],"names":["default_parity","default_flowControl","localStorage","VueSerial","__privateAdd","_start_receive","_open","_reconnect","_update_signals","_signals_polling","_private_reinitialize","_private","ref","_a","event","__privateGet","x","filters","port","__privateMethod","open_fn","e","private_reinitialize_fn","value","data","writer","update_signals_fn","signals","interval_ms","signals_polling_fn","new_value","reconnect_fn","start_receive_fn","done","error","info","__publicField"],"mappings":"mvBAQA,MAAMA,EAAiB,OAEjBC,EAAsB,OAGtBC,EAAe,OAAO,cAAgB,GAG5C,MAAqBC,UAAkB,WAAY,CA+IjD,aAAe,OACP,QA5GRC,EAAA,KAAMC,GAsBND,EAAA,KAAME,GA0BNF,EAAA,KAAMG,GAgBNH,EAAA,KAAMI,GAWNJ,EAAA,KAAMK,GAcNL,EAAA,KAAAM,GAnHAN,EAAA,KAAAO,EAAW,CACT,KAAM,KACN,OAAQ,KACR,IAAK,KACL,UAAW,GACX,OAAQC,MAAI,EAAK,EACjB,YAAaA,MAAI,EAAK,EACtB,UAAWA,MAAI,EAAK,EACpB,YAAaA,EAAAA,IAAI,MAAS,EAC1B,aAAcA,EAAAA,IAAI,MAAS,EAC3B,SAAUA,EAAA,IAAIV,EAAa,oBAAsB,MAAgB,EACjE,SAAUU,EAAA,IAAIV,EAAa,oBAAsB,CAAgB,EACjE,SAAUU,EAAA,IAAIV,EAAa,oBAAsB,CAAgB,EACjE,OAAQU,EAAA,IAAIV,EAAa,kBAAoBF,CAAc,EAC3D,WAAYY,EAAA,IAAIV,EAAa,sBAAwB,GAAkB,EACvE,YAAaU,EAAA,IAAIV,EAAa,uBAAyBD,CAAmB,EAC1E,kBAAmBW,MAAI,EAAK,EAC5B,YAAaA,MAAI,EAAK,EACtB,cAAeA,MAAI,EAAK,EACxB,aAAcA,MAAI,EAAK,EACvB,kBAAmBA,MAAI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-8,7 +8,7 @@ "declaration": true, "isolatedModules": true, "noEmit": false, - "emitDeclarationOnly": true, + "emitDeclarationOnly": true }, "typedocOptions": { "entryPoints": ["src/vue-serial.ts"], diff --git a/vite.config.ts b/vite.config.ts index 875b3b4..5f9ed03 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -22,6 +22,7 @@ export default defineConfig(({ mode }) => { if(mode == "library") { config.build = { outDir: "dist", + sourcemap: true, lib: { entry: "./src/vue-serial.ts", name: "VueSerial",