webserial-core 1.2.0 → 2.0.0-dev.1
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.
- package/{LICENSE → LICENSE.md} +1 -1
- package/README.md +142 -287
- package/dist/adapters/web-bluetooth/WebBluetoothProvider.d.ts +19 -0
- package/dist/adapters/web-bluetooth/index.d.ts +6 -0
- package/dist/adapters/web-usb/WebUsbProvider.d.ts +127 -0
- package/dist/adapters/web-usb/index.d.ts +6 -0
- package/dist/adapters/websocket/WebSocketProvider.d.ts +20 -0
- package/dist/adapters/websocket/index.d.ts +6 -0
- package/dist/core/AbstractSerialDevice.d.ts +108 -0
- package/dist/core/SerialEventEmitter.d.ts +37 -0
- package/dist/core/SerialRegistry.d.ts +53 -0
- package/dist/errors/index.d.ts +40 -0
- package/dist/index.d.ts +10 -0
- package/dist/parsers/DelimiterParser.d.ts +22 -0
- package/dist/parsers/FixedLengthParser.d.ts +23 -0
- package/dist/parsers/RawParser.d.ts +22 -0
- package/dist/parsers/index.d.ts +7 -0
- package/dist/queue/CommandQueue.d.ts +98 -0
- package/dist/types/index.d.ts +124 -0
- package/dist/webserial-core.cjs +1 -0
- package/dist/webserial-core.mjs +853 -0
- package/dist/webserial-core.umd.js +1 -0
- package/package.json +62 -68
- package/dist/types/Core.d.ts +0 -268
- package/dist/types/Core.d.ts.map +0 -1
- package/dist/types/Devices.d.ts +0 -62
- package/dist/types/Devices.d.ts.map +0 -1
- package/dist/types/Dispatcher.d.ts +0 -98
- package/dist/types/Dispatcher.d.ts.map +0 -1
- package/dist/types/SerialError.d.ts +0 -61
- package/dist/types/SerialError.d.ts.map +0 -1
- package/dist/types/SerialEvent.d.ts +0 -4
- package/dist/types/SerialEvent.d.ts.map +0 -1
- package/dist/types/Socket.d.ts +0 -29
- package/dist/types/Socket.d.ts.map +0 -1
- package/dist/types/main.d.ts +0 -15
- package/dist/types/main.d.ts.map +0 -1
- package/dist/types/utils.d.ts +0 -3
- package/dist/types/utils.d.ts.map +0 -1
- package/dist/webserial-core.js +0 -1236
- package/dist/webserial-core.js.map +0 -1
- package/dist/webserial-core.umd.cjs +0 -5
- package/dist/webserial-core.umd.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.WebSerialCore={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class{listeners={};on(e,t){return this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),this}off(e,t){return this.listeners[e]&&this.listeners[e].delete(t),this}emit(e,...t){let n=this.listeners[e];if(!n||n.size===0)return!1;for(let e of n)e(...t);return!0}},n=class{static instances=new Set;static portInstanceMap=new WeakMap;static getInstances(){return Array.from(this.instances)}static register(e){this.instances.add(e)}static unregister(e){this.instances.delete(e)}static isPortInUse(e,t){let n=this.portInstanceMap.get(e);return n!==void 0&&n!==t}static lockPort(e,t){this.portInstanceMap.set(e,t)}static unlockPort(e){this.portInstanceMap.delete(e)}},r=class{queue=[];isProcessing=!1;isPaused=!0;timeoutId=null;commandTimeout;onSend;onTimeout;constructor(e){this.commandTimeout=e.commandTimeout,this.onSend=e.onSend,this.onTimeout=e.onTimeout}get queueSize(){return this.queue.length}enqueue(e){this.queue.push(e),this.tryProcessNext()}advance(){this.clearCommandTimeout(),this.isProcessing=!1,this.tryProcessNext()}pause(){this.isPaused=!0,this.clearCommandTimeout(),this.isProcessing=!1}resume(){this.isPaused=!1,this.tryProcessNext()}clear(){this.queue=[],this.clearCommandTimeout(),this.isProcessing=!1}snapshot(){return[...this.queue]}restore(e){this.queue=[...e,...this.queue]}tryProcessNext(){if(this.isPaused||this.isProcessing||this.queue.length===0)return;this.isProcessing=!0;let e=this.queue.shift();this.commandTimeout>0&&(this.timeoutId=setTimeout(()=>{this.timeoutId=null,this.onTimeout(e),this.advance()},this.commandTimeout)),this.onSend(e).catch(()=>{this.advance()})}clearCommandTimeout(){this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}},i=class e extends Error{constructor(t){super(t),this.name=`SerialPortConflictError`,Object.setPrototypeOf(this,e.prototype)}},a=class e extends Error{constructor(t){super(t),this.name=`SerialPermissionError`,Object.setPrototypeOf(this,e.prototype)}},o=class e extends Error{constructor(t){super(t),this.name=`SerialTimeoutError`,Object.setPrototypeOf(this,e.prototype)}},s=class e extends Error{constructor(t){super(t),this.name=`SerialReadError`,Object.setPrototypeOf(this,e.prototype)}},c=class e extends Error{constructor(t){super(t),this.name=`SerialWriteError`,Object.setPrototypeOf(this,e.prototype)}},l=class e extends t{port=null;reader=null;writer=null;queue;options;isConnecting=!1;abortController=null;userInitiatedDisconnect=!1;reconnectTimerId=null;isHandshaking=!1;static customProvider=null;static polyfillOptions;constructor(e){super(),this.options={baudRate:e.baudRate,dataBits:e.dataBits??8,stopBits:e.stopBits??1,parity:e.parity??`none`,bufferSize:e.bufferSize??255,flowControl:e.flowControl??`none`,filters:e.filters??[],commandTimeout:e.commandTimeout??0,parser:e.parser,autoReconnect:e.autoReconnect??!1,autoReconnectInterval:e.autoReconnectInterval??1500,handshakeTimeout:e.handshakeTimeout??2e3,provider:e.provider,polyfillOptions:e.polyfillOptions},this.queue=new r({commandTimeout:this.options.commandTimeout,onSend:async e=>{await this.writeToPort(e),this.emit(`serial:sent`,e,this)},onTimeout:e=>{this.emit(`serial:timeout`,e,this)}}),this.on(`serial:data`,()=>{this.queue.advance()}),n.register(this)}async handshake(){return!0}async connect(){if(!this.isConnecting&&!this.port){this.isConnecting=!0,this.emit(`serial:connecting`,this);try{let t=this.getSerial();if(!t)throw Error(`Web Serial API is not supported in this browser. Use AbstractSerialDevice.setProvider() to set a WebUSB polyfill.`);if(this.port=await this.findAndValidatePort(),!this.port){let n;try{n=await t.requestPort({filters:this.options.filters},this.options.polyfillOptions??e.polyfillOptions)}catch(e){throw e instanceof DOMException&&(e.name===`NotFoundError`||e.name===`SecurityError`||e.name===`AbortError`)?new a(e instanceof Error?e.message:String(e)):e instanceof Error?e:Error(String(e))}if(!await this.openAndHandshake(n))throw Error(`Handshake failed: the selected device did not respond correctly.`);this.port=n}this.abortController=new AbortController,this.queue.resume(),this.emit(`serial:connected`,this)}catch(e){if(e instanceof a?this.emit(`serial:need-permission`,this):this.emit(`serial:error`,e instanceof Error?e:Error(String(e)),this),this.port){n.unlockPort(this.port);try{await this.port.close()}catch{}this.port=null}throw e}finally{this.isConnecting=!1}}}async disconnect(){this.port&&(this.userInitiatedDisconnect=!0,this.stopReconnecting(),await this.cleanupPort())}async cleanupPort(){if(this.port){this.queue.pause(),this.abortController?.abort(),this.abortController=null;try{let e=this.reader,t=this.writer;if(this.reader=null,this.writer=null,e){try{await e.cancel()}catch{}try{e.releaseLock()}catch{}}if(t){try{await t.close()}catch{}try{t.releaseLock()}catch{}}try{await this.port.close()}catch{}}catch(e){this.emit(`serial:error`,e instanceof Error?e:Error(String(e)),this)}finally{this.port&&n.unlockPort(this.port),this.port=null,this.options.parser?.reset?.(),this.emit(`serial:disconnected`,this),!this.userInitiatedDisconnect&&this.options.autoReconnect&&this.startReconnecting(),this.userInitiatedDisconnect=!1}}}async forget(){await this.disconnect(),this.port&&typeof this.port.forget==`function`&&await this.port.forget(),n.unregister(this)}async send(e){let t;t=typeof e==`string`?new TextEncoder().encode(e):e,t.length>0&&this.queue.enqueue(t)}clearQueue(){this.queue.clear(),this.emit(`serial:queue-empty`,this)}async writeToPort(e){if(!this.port||!this.port.writable)throw new c(`Port not writable.`);this.writer=this.port.writable.getWriter();try{await this.writer.write(e)}catch(e){throw new c(e instanceof Error?e.message:String(e))}finally{this.writer.releaseLock(),this.writer=null}}async readLoop(){if(!(!this.port||!this.port.readable)&&!this.reader){this.reader=this.port.readable.getReader();try{for(;;){let{value:e,done:t}=await this.reader.read();if(t)break;e&&(this.options.parser?this.options.parser.parse(e,e=>{this.emit(`serial:data`,e,this)}):this.emit(`serial:data`,e,this))}}catch(e){if(this.port)throw new s(e instanceof Error?e.message:String(e))}finally{if(this.reader){try{this.reader.releaseLock()}catch{}this.reader=null}}}}async openAndHandshake(e){let t=this;if(n.isPortInUse(e,t))return!1;n.lockPort(e,t);try{await e.open({baudRate:this.options.baudRate,dataBits:this.options.dataBits,stopBits:this.options.stopBits,parity:this.options.parity,bufferSize:this.options.bufferSize,flowControl:this.options.flowControl})}catch(t){throw n.unlockPort(e),t instanceof Error?t:Error(String(t))}this.port=e,this.abortController=new AbortController;let r=this.queue.snapshot();this.isHandshaking=!0,this.readLoop().catch(e=>{!this.isHandshaking&&this.port&&(this.emit(`serial:error`,e,this),this.cleanupPort())}),this.queue.resume();try{let t=await this.runHandshakeWithTimeout();return this.isHandshaking=!1,t?(this.queue.pause(),this.queue.clear(),this.queue.restore(r),this.options.parser?.reset?.(),!0):(await this.teardownHandshake(e,r),!1)}catch{return this.isHandshaking=!1,await this.teardownHandshake(e,r),!1}}async teardownHandshake(e,t){this.queue.pause(),this.queue.clear(),this.queue.restore(t),await this.stopReader(),this.port=null,this.abortController=null,this.options.parser?.reset?.();try{await e.close()}catch{}n.unlockPort(e)}async stopReader(){let e=this.reader;if(this.reader=null,e){try{await e.cancel()}catch{}try{e.releaseLock()}catch{}}}async runHandshakeWithTimeout(){let e=this.options.handshakeTimeout??2e3;return Promise.race([this.handshake(),new Promise(t=>setTimeout(()=>t(!1),e))])}async findAndValidatePort(){let t=this.getSerial();if(!t)return null;let r=await t.getPorts(this.options.polyfillOptions??e.polyfillOptions);if(r.length===0)return null;let i=this.options.filters??[],a=this;for(let e of r)if(!n.isPortInUse(e,a)){if(i.length>0){let t=e.getInfo();if(!i.some(e=>{let n=e.usbVendorId===void 0||e.usbVendorId===t.usbVendorId,r=e.usbProductId===void 0||e.usbProductId===t.usbProductId;return n&&r}))continue}try{if(await this.openAndHandshake(e))return e}catch{}}return null}startReconnecting(){this.reconnectTimerId||=(this.emit(`serial:reconnecting`,this),setInterval(async()=>{if(this.port||this.isConnecting){this.stopReconnecting();return}try{let e=await this.findAndValidatePort();e&&(this.stopReconnecting(),await this.reconnect(e))}catch{}},this.options.autoReconnectInterval))}stopReconnecting(){this.reconnectTimerId&&=(clearInterval(this.reconnectTimerId),null)}async reconnect(e){if(!(this.isConnecting||this.port)){this.isConnecting=!0,this.emit(`serial:connecting`,this);try{this.port=e,this.abortController=new AbortController,this.queue.resume(),this.emit(`serial:connected`,this)}catch(e){this.emit(`serial:error`,e instanceof Error?e:Error(String(e)),this),this.port&&=(n.unlockPort(this.port),null),this.options.autoReconnect&&this.startReconnecting()}finally{this.isConnecting=!1}}}static getInstances(){return n.getInstances()}static async connectAll(){let e=n.getInstances();for(let t of e)try{await t.connect()}catch{}}static setProvider(t,n){e.customProvider=t,e.polyfillOptions=n}getSerial(){return this.options.provider?this.options.provider:e.customProvider?e.customProvider:typeof navigator<`u`&&navigator.serial?navigator.serial:null}};function u(e){if(e<=0)throw Error(`FixedLengthParser: length must be greater than 0`);let t=new Uint8Array;return{parse(n,r){let i=new Uint8Array(t.length+n.length);for(i.set(t),i.set(n,t.length),t=i;t.length>=e;)r(t.slice(0,e)),t=t.slice(e)},reset(){t=new Uint8Array}}}function d(e){let t=``,n=new TextDecoder;return{parse(r,i){t+=n.decode(r,{stream:!0});let a;for(;(a=t.indexOf(e))!==-1;)i(t.slice(0,a)),t=t.slice(a+e.length)},reset(){t=``,n=new TextDecoder}}}function f(){return{parse(e,t){t(e)},reset(){}}}var p=32,m=34,h=0,g=30,_=3,v=7,y=1,b=0,x=771,S=768,C=255,w=8,T=`none`,E=1,D=[16,8,7,6,5],O=[1,2],k=[`none`,`even`,`odd`],A=[`none`,`odd`,`even`],j=[1,1.5,2],M={usbControlInterfaceClass:2,usbTransferInterfaceClass:10,protocol:void 0};function N(e,t){let n=e.configurations[0];if(!n)return null;for(let e of n.interfaces)if(e.alternates[0]?.interfaceClass===t)return e;return null}function P(e,t){let n=e.configurations[0];if(!n)return null;for(let e of n.interfaces){let n=e.alternates[0];if(!n||n.interfaceClass!==t)continue;let r=n.endpoints.some(e=>e.direction===`in`),i=n.endpoints.some(e=>e.direction===`out`);if(r&&i)return e}return null}function F(e,t){let n=e.alternates[0];if(n){for(let e of n.endpoints)if(e.direction===t)return e}throw TypeError(`Interface ${e.interfaceNumber} does not have an ${t} endpoint.`)}function I(e,t){return t===2?`cdc_acm`:e.vendorId===4292?`cp210x`:`none`}var L=class{device_;endpoint_;onError_;constructor(e,t,n){this.device_=e,this.endpoint_=t,this.onError_=n}pull(e){(async()=>{let t=this.endpoint_.packetSize;try{let n=await this.device_.transferIn(this.endpoint_.endpointNumber,t);if(n.status!==`ok`){e.error(`USB error: ${n.status}`),this.onError_();return}if(n.data?.buffer&&n.data.byteLength>0){let t=new Uint8Array(n.data.buffer,n.data.byteOffset,n.data.byteLength);t.length>0&&e.enqueue(t)}}catch(t){e.error(String(t)),this.onError_()}})()}},R=class{device_;endpoint_;onError_;constructor(e,t,n){this.device_=e,this.endpoint_=t,this.onError_=n}async write(e,t){try{let n=await this.device_.transferOut(this.endpoint_.endpointNumber,e.buffer);n.status!==`ok`&&(t.error(n.status),this.onError_())}catch(e){t.error(String(e)),this.onError_()}}},z=class{device_;protocol_;controlInterface_;transferInterface_;inEndpoint_;outEndpoint_;serialOptions_;readable_=null;writable_=null;cdcOutputSignals_={dataTerminalReady:!1,requestToSend:!1,break:!1};constructor(e,t){this.device_=e;let n={...M,...t};this.protocol_=n.protocol??I(e,n.usbControlInterfaceClass);let r=n.usbControlInterfaceClass,i=n.usbTransferInterfaceClass;if(r===i){let t=P(e,i);if(!t)throw TypeError(`Unable to find interface with class ${i} that has both IN and OUT endpoints.`);this.controlInterface_=t,this.transferInterface_=t}else{let t=N(e,r);if(!t)throw TypeError(`Unable to find control interface with class ${r}.`);let n=P(e,i)??N(e,i);if(!n)throw TypeError(`Unable to find transfer interface with class ${i}.`);this.controlInterface_=t,this.transferInterface_=n}this.inEndpoint_=F(this.transferInterface_,`in`),this.outEndpoint_=F(this.transferInterface_,`out`)}get readable(){return!this.readable_&&this.device_.opened&&(this.readable_=new ReadableStream(new L(this.device_,this.inEndpoint_,()=>{this.readable_=null}),{highWaterMark:this.serialOptions_?.bufferSize??C})),this.readable_}get writable(){return!this.writable_&&this.device_.opened&&(this.writable_=new WritableStream(new R(this.device_,this.outEndpoint_,()=>{this.writable_=null}),new ByteLengthQueuingStrategy({highWaterMark:this.serialOptions_?.bufferSize??C}))),this.writable_}async open(e){this.serialOptions_=e,this.validateOptions();try{switch(await this.device_.open(),this.device_.configuration===null&&await this.device_.selectConfiguration(1),await this.device_.claimInterface(this.controlInterface_.interfaceNumber),this.controlInterface_!==this.transferInterface_&&await this.device_.claimInterface(this.transferInterface_.interfaceNumber),this.protocol_){case`cdc_acm`:await this.cdcInit();break;case`cp210x`:await this.cp210xInit();break;case`none`:break}}catch(e){throw this.device_.opened&&await this.device_.close(),Error(`Error setting up device: `+(e instanceof Error?e.message:String(e)),{cause:e})}}async close(){let e=[];if(this.readable_&&e.push(this.readable_.cancel()),this.writable_&&e.push(this.writable_.abort()),await Promise.all(e),this.readable_=null,this.writable_=null,this.device_.opened){switch(this.protocol_){case`cdc_acm`:await this.cdcSetSignals({dataTerminalReady:!1,requestToSend:!1});break;case`cp210x`:await this.cp210xDeinit();break}await this.device_.close()}}async forget(){return this.device_.forget()}getInfo(){return{usbVendorId:this.device_.vendorId,usbProductId:this.device_.productId}}async cdcInit(){await this.cdcSetLineCoding(),await this.cdcSetSignals({dataTerminalReady:!0})}async cdcSetSignals(e){if(this.cdcOutputSignals_={...this.cdcOutputSignals_,...e},e.dataTerminalReady!==void 0||e.requestToSend!==void 0){let e=(this.cdcOutputSignals_.dataTerminalReady?1:0)|(this.cdcOutputSignals_.requestToSend?2:0);await this.device_.controlTransferOut({requestType:`class`,recipient:`interface`,request:m,value:e,index:this.controlInterface_.interfaceNumber})}}async cdcSetLineCoding(){let e=new ArrayBuffer(7),t=new DataView(e);if(t.setUint32(0,this.serialOptions_.baudRate,!0),t.setUint8(4,j.indexOf(this.serialOptions_.stopBits??E)),t.setUint8(5,A.indexOf(this.serialOptions_.parity??T)),t.setUint8(6,this.serialOptions_.dataBits??w),(await this.device_.controlTransferOut({requestType:`class`,recipient:`interface`,request:p,value:0,index:this.controlInterface_.interfaceNumber},e)).status!==`ok`)throw new DOMException(`Failed to set line coding.`,`NetworkError`)}async cp210xInit(){let e=this.controlInterface_.interfaceNumber;await this.device_.controlTransferOut({requestType:`vendor`,recipient:`interface`,request:h,value:y,index:e});let t=new ArrayBuffer(4);new DataView(t).setUint32(0,this.serialOptions_.baudRate,!0),await this.device_.controlTransferOut({requestType:`vendor`,recipient:`interface`,request:g,value:0,index:e},t);let n=this.serialOptions_.dataBits??w,r={none:0,odd:16,even:32}[this.serialOptions_.parity??T]??0,i=({1:0,2:2}[this.serialOptions_.stopBits??E]??0)<<8|r|n;await this.device_.controlTransferOut({requestType:`vendor`,recipient:`interface`,request:_,value:i,index:e}),await this.device_.controlTransferOut({requestType:`vendor`,recipient:`interface`,request:v,value:x,index:e})}async cp210xDeinit(){let e=this.controlInterface_.interfaceNumber;await this.device_.controlTransferOut({requestType:`vendor`,recipient:`interface`,request:v,value:S,index:e}),await this.device_.controlTransferOut({requestType:`vendor`,recipient:`interface`,request:h,value:b,index:e})}validateOptions(){if(this.serialOptions_.baudRate%1!=0)throw RangeError(`Invalid baud rate: ${this.serialOptions_.baudRate}`);if(this.serialOptions_.dataBits!==void 0&&!D.includes(this.serialOptions_.dataBits))throw RangeError(`Invalid dataBits: ${this.serialOptions_.dataBits}`);if(this.serialOptions_.stopBits!==void 0&&!O.includes(this.serialOptions_.stopBits))throw RangeError(`Invalid stopBits: ${this.serialOptions_.stopBits}`);if(this.serialOptions_.parity!==void 0&&!k.includes(this.serialOptions_.parity))throw RangeError(`Invalid parity: ${this.serialOptions_.parity}`)}},B=class{options_;constructor(e){this.options_={...M,...e}}async requestPort(e,t){let n={...this.options_,...t},r=[];if(e?.filters&&e.filters.length>0)for(let t of e.filters){let e={};t.usbVendorId!==void 0&&(e.vendorId=t.usbVendorId),t.usbProductId!==void 0&&(e.productId=t.usbProductId),n.usbControlInterfaceClass!==void 0&&n.usbControlInterfaceClass!==255?e.classCode=n.usbControlInterfaceClass:e.vendorId===void 0&&e.productId===void 0&&(e.classCode=n.usbControlInterfaceClass??2),r.push(e)}else r.push({classCode:n.usbControlInterfaceClass??2});return new z(await navigator.usb.requestDevice({filters:r}),n)}async getPorts(e){let t={...this.options_,...e},n=await navigator.usb.getDevices(),r=[];for(let e of n)try{let n=new z(e,t);r.push(n)}catch{}return r}},V=`6e400001-b5a3-f393-e0a9-e50e24dcca9e`,H=`6e400003-b5a3-f393-e0a9-e50e24dcca9e`,U=`6e400002-b5a3-f393-e0a9-e50e24dcca9e`,W=20,G=10;function K(e){let t=null,n=null,r=null;return{get readable(){return t},get writable(){return n},getInfo(){return{}},async open(){if(!e.gatt)throw Error(`GATT not available on this Bluetooth device.`);r=await e.gatt.connect();let i=await r.getPrimaryService(V),a=await i.getCharacteristic(H),o=await i.getCharacteristic(U);await a.startNotifications(),t=new ReadableStream({start(e){a.addEventListener(`characteristicvaluechanged`,t=>{let n=t.target.value.buffer;e.enqueue(new Uint8Array(n))})}}),n=new WritableStream({async write(e){for(let t=0;t<e.length;t+=W){let n=e.slice(t,t+W);await o.writeValueWithoutResponse(n),t+W<e.length&&await new Promise(e=>setTimeout(e,G))}}})},async close(){r?.connected&&r.disconnect(),t=null,n=null}}}function q(){return{async requestPort(){if(!navigator.bluetooth)throw Error(`Web Bluetooth API is not supported in this browser. Use Chrome on Android, macOS, or ChromeOS.`);return K(await navigator.bluetooth.requestDevice({filters:[{services:[V]}]}))},async getPorts(){return[]}}}function J(e){return new Promise((t,n)=>{e.addEventListener(`open`,()=>t(),{once:!0}),e.addEventListener(`error`,e=>n(e),{once:!0})})}function Y(e,t){return new Promise(n=>{let r=i=>{let a=JSON.parse(i.data);a.type===t&&(e.removeEventListener(`message`,r),n(a.payload))};e.addEventListener(`message`,r)})}function X(e,t){let n=null,r=null;return{get readable(){return n},get writable(){return r},getInfo(){return{usbVendorId:t.vendorId,usbProductId:t.productId}},async open(i){e.send(JSON.stringify({type:`open`,path:t.path,baudRate:i.baudRate,dataBits:i.dataBits,stopBits:i.stopBits,parity:i.parity,parser:{type:`delimiter`,value:`\\n`}})),await Y(e,`opened`);let a=[],o=null,s=!1;function c(e){let t=JSON.parse(e.data);if(t.type===`data`&&t.bytes){let e=new Uint8Array(t.bytes);o?o.enqueue(e):a.push(e)}t.type===`closed`&&(s=!0,o&&o.close())}e.addEventListener(`message`,c),n=new ReadableStream({start(e){o=e;for(let t of a)e.enqueue(t);a.length=0,s&&e.close()},cancel(){e.removeEventListener(`message`,c),o=null}}),r=new WritableStream({write(t){e.send(JSON.stringify({type:`write`,bytes:Array.from(t)}))}})},async close(){e.send(JSON.stringify({type:`close`})),n=null,r=null,e.close()}}}function Z(e){return{async requestPort(t){let n=new WebSocket(e);await J(n),n.send(JSON.stringify({type:`list-ports`,filters:t?.filters??[]}));let r=(await Y(n,`port-list`))[0];if(!r)throw Error(`No ports available on the bridge server. Make sure the Node.js server is running and a device is connected.`);return X(n,r)},async getPorts(){let t=new WebSocket(e);return await J(t),t.send(JSON.stringify({type:`list-ports`,filters:[]})),(await Y(t,`port-list`)).map(e=>X(t,e))}}}e.AbstractSerialDevice=l,e.CommandQueue=r,e.SerialEventEmitter=t,e.SerialPermissionError=a,e.SerialPortConflictError=i,e.SerialReadError=s,e.SerialRegistry=n,e.SerialTimeoutError=o,e.SerialWriteError=c,e.WebUsbProvider=B,e.createBluetoothProvider=q,e.createWebSocketProvider=Z,e.delimiter=d,e.fixedLength=u,e.raw=f});
|
package/package.json
CHANGED
|
@@ -1,85 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webserial-core",
|
|
3
|
-
"
|
|
4
|
-
"version": "1.2.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
3
|
+
"version": "2.0.0-dev.1",
|
|
7
4
|
"author": "danidoble",
|
|
8
5
|
"repository": {
|
|
9
6
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/danidoble/webserial-core
|
|
7
|
+
"url": "https://github.com/danidoble/webserial-core"
|
|
11
8
|
},
|
|
12
|
-
"
|
|
13
|
-
|
|
9
|
+
"main": "./dist/webserial-core.cjs",
|
|
10
|
+
"module": "./dist/webserial-core.mjs",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@eslint/js": "^10.0.1",
|
|
13
|
+
"@iconify/vue": "^5.0.0",
|
|
14
|
+
"@types/bun": "^1.3.10",
|
|
15
|
+
"@types/w3c-web-serial": "^1.0.8",
|
|
16
|
+
"@types/w3c-web-usb": "^1.0.13",
|
|
17
|
+
"@types/web-bluetooth": "^0.0.21",
|
|
18
|
+
"eslint": "^10.0.3",
|
|
19
|
+
"globals": "^17.4.0",
|
|
20
|
+
"jiti": "^2.6.1",
|
|
21
|
+
"prettier": "3.8.1",
|
|
22
|
+
"typescript": "~5.9.3",
|
|
23
|
+
"typescript-eslint": "^8.57.1",
|
|
24
|
+
"vite": "^8.0.0",
|
|
25
|
+
"vite-plugin-dts": "^4.5.4",
|
|
26
|
+
"vitepress": "^1.6.4",
|
|
27
|
+
"vitepress-plugin-llms": "^1.11.1"
|
|
14
28
|
},
|
|
15
|
-
"homepage": "https://github.com/danidoble/webserial-core#readme",
|
|
16
|
-
"keywords": [
|
|
17
|
-
"webserial",
|
|
18
|
-
"serial",
|
|
19
|
-
"core",
|
|
20
|
-
"web",
|
|
21
|
-
"iot",
|
|
22
|
-
"device",
|
|
23
|
-
"communication",
|
|
24
|
-
"usb"
|
|
25
|
-
],
|
|
26
|
-
"files": [
|
|
27
|
-
"dist",
|
|
28
|
-
"README.md"
|
|
29
|
-
],
|
|
30
|
-
"main": "./dist/webserial-core.umd.cjs",
|
|
31
|
-
"module": "./dist/webserial-core.js",
|
|
32
|
-
"types": "./dist/types/main.d.ts",
|
|
33
29
|
"exports": {
|
|
34
30
|
".": {
|
|
35
|
-
"types": "./dist/
|
|
36
|
-
"import": "./dist/webserial-core.
|
|
37
|
-
"require": "./dist/webserial-core.
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/webserial-core.mjs",
|
|
33
|
+
"require": "./dist/webserial-core.cjs",
|
|
34
|
+
"default": "./dist/webserial-core.mjs"
|
|
38
35
|
}
|
|
39
36
|
},
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
37
|
+
"description": "A strongly-typed, event-driven, abstract TypeScript library for the Web Serial API with custom parsers, command queue, handshake validation, and auto-reconnect.",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"keywords": [
|
|
42
|
+
"webserial",
|
|
43
|
+
"serial",
|
|
44
|
+
"web-serial-api",
|
|
45
|
+
"typescript",
|
|
46
|
+
"event-driven",
|
|
47
|
+
"abstract",
|
|
48
|
+
"parser",
|
|
49
|
+
"arduino",
|
|
50
|
+
"embedded",
|
|
51
|
+
"usb",
|
|
52
|
+
"hardware"
|
|
53
|
+
],
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"homepage": "https://github.com/danidoble/webserial-core#readme",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/danidoble/webserial-core/issues"
|
|
53
58
|
},
|
|
54
59
|
"engines": {
|
|
55
60
|
"node": ">=18.0.0"
|
|
56
61
|
},
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"vitest": "^4.0.18"
|
|
71
|
-
},
|
|
72
|
-
"lint-staged": {
|
|
73
|
-
"lib/**/*.ts": [
|
|
74
|
-
"prettier --write",
|
|
75
|
-
"eslint --fix"
|
|
76
|
-
],
|
|
77
|
-
"tests/**/*.ts": [
|
|
78
|
-
"prettier --write",
|
|
79
|
-
"eslint --fix"
|
|
80
|
-
]
|
|
62
|
+
"scripts": {
|
|
63
|
+
"dev": "vite",
|
|
64
|
+
"build": "tsc --noEmit && vite build",
|
|
65
|
+
"preview": "vite preview",
|
|
66
|
+
"lint": "eslint . --fix",
|
|
67
|
+
"format": "prettier ./demos ./docs ./scripts ./src ./tests --write",
|
|
68
|
+
"docs:prepare": "vite build && node scripts/prepare-docs.mjs",
|
|
69
|
+
"docs:dev": "vitepress dev docs",
|
|
70
|
+
"docs:build": "vite build && node scripts/prepare-docs.mjs && vitepress build docs",
|
|
71
|
+
"docs:preview": "vitepress preview docs",
|
|
72
|
+
"docs:index": "node scripts/algolia-index.mjs",
|
|
73
|
+
"release": "node scripts/publish.mjs",
|
|
74
|
+
"release:simulate": "node scripts/publish.mjs --dry-run"
|
|
81
75
|
},
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
"sideEffects": false,
|
|
77
|
+
"type": "module",
|
|
78
|
+
"types": "./dist/index.d.ts"
|
|
85
79
|
}
|
package/dist/types/Core.d.ts
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { Dispatcher } from "./Dispatcher";
|
|
2
|
-
interface LastError {
|
|
3
|
-
message: string | null;
|
|
4
|
-
action: string | null;
|
|
5
|
-
code: string | Uint8Array | Array<string> | Array<number> | null | number;
|
|
6
|
-
no_code: number;
|
|
7
|
-
}
|
|
8
|
-
interface DeviceData {
|
|
9
|
-
type: string;
|
|
10
|
-
id: string;
|
|
11
|
-
listen_on_port: number | null;
|
|
12
|
-
}
|
|
13
|
-
type SerialResponseAs = "hex" | "uint8" | "string" | "arraybuffer";
|
|
14
|
-
interface SerialResponse {
|
|
15
|
-
length: number | null;
|
|
16
|
-
buffer: Uint8Array;
|
|
17
|
-
as: SerialResponseAs;
|
|
18
|
-
replacer: RegExp | string;
|
|
19
|
-
limiter: null | string | RegExp;
|
|
20
|
-
prefixLimiter: boolean;
|
|
21
|
-
sufixLimiter: boolean;
|
|
22
|
-
delimited: boolean;
|
|
23
|
-
}
|
|
24
|
-
interface QueueData {
|
|
25
|
-
bytes: string | Uint8Array | Array<string> | Array<number>;
|
|
26
|
-
action: string;
|
|
27
|
-
}
|
|
28
|
-
type ParserSocketPort = {
|
|
29
|
-
name: "byte-length" | "inter-byte-timeout";
|
|
30
|
-
length?: number;
|
|
31
|
-
interval?: number;
|
|
32
|
-
};
|
|
33
|
-
type PortInfo = {
|
|
34
|
-
path: string | null;
|
|
35
|
-
vendorId: number | string | null;
|
|
36
|
-
productId: number | string | null;
|
|
37
|
-
parser: ParserSocketPort;
|
|
38
|
-
};
|
|
39
|
-
type SerialData = {
|
|
40
|
-
transformStream: false | TransformStream;
|
|
41
|
-
socket: boolean;
|
|
42
|
-
portInfo: PortInfo;
|
|
43
|
-
aux_connecting: string;
|
|
44
|
-
connecting: boolean;
|
|
45
|
-
connected: boolean;
|
|
46
|
-
port: SerialPort | null;
|
|
47
|
-
last_action: string | null;
|
|
48
|
-
response: SerialResponse;
|
|
49
|
-
reader: ReadableStreamDefaultReader<Uint8Array> | null;
|
|
50
|
-
input_done: Promise<void> | null;
|
|
51
|
-
output_done: Promise<void> | null;
|
|
52
|
-
input_stream: ReadableStream<Uint8Array> | null;
|
|
53
|
-
output_stream: WritableStream<Uint8Array> | null;
|
|
54
|
-
keep_reading: boolean;
|
|
55
|
-
time_until_send_bytes: number | undefined | ReturnType<typeof setTimeout>;
|
|
56
|
-
delay_first_connection: number;
|
|
57
|
-
bytes_connection: string | Uint8Array | string[] | number[] | null;
|
|
58
|
-
filters: SerialPortFilter[];
|
|
59
|
-
config_port: SerialOptions;
|
|
60
|
-
queue: QueueData[];
|
|
61
|
-
running_queue: boolean;
|
|
62
|
-
auto_response: any;
|
|
63
|
-
free_timeout_ms: number;
|
|
64
|
-
useRTSCTS: boolean;
|
|
65
|
-
};
|
|
66
|
-
interface TimeResponse {
|
|
67
|
-
response_connection: number;
|
|
68
|
-
response_engines: number;
|
|
69
|
-
response_general: number;
|
|
70
|
-
}
|
|
71
|
-
interface Timeout {
|
|
72
|
-
until_response: number | ReturnType<typeof setTimeout>;
|
|
73
|
-
}
|
|
74
|
-
interface InternalIntervals {
|
|
75
|
-
reconnection: number;
|
|
76
|
-
}
|
|
77
|
-
export type Internal = {
|
|
78
|
-
bypassSerialBytesConnection: boolean;
|
|
79
|
-
auto_response: boolean;
|
|
80
|
-
device_number: number;
|
|
81
|
-
aux_port_connector: number;
|
|
82
|
-
last_error: LastError;
|
|
83
|
-
serial: SerialData;
|
|
84
|
-
device: DeviceData;
|
|
85
|
-
time: TimeResponse;
|
|
86
|
-
timeout: Timeout;
|
|
87
|
-
interval: InternalIntervals;
|
|
88
|
-
};
|
|
89
|
-
interface CoreConstructorParams {
|
|
90
|
-
filters?: SerialPortFilter[] | null;
|
|
91
|
-
config_port?: SerialOptions;
|
|
92
|
-
no_device?: number;
|
|
93
|
-
device_listen_on_channel?: number | string;
|
|
94
|
-
bypassSerialBytesConnection?: boolean;
|
|
95
|
-
socket?: boolean;
|
|
96
|
-
transformStream?: false | TransformStream;
|
|
97
|
-
}
|
|
98
|
-
interface CustomCode {
|
|
99
|
-
code: string | Uint8Array | Array<string> | Array<number>;
|
|
100
|
-
}
|
|
101
|
-
interface ICore {
|
|
102
|
-
lastAction: string | null;
|
|
103
|
-
set listenOnChannel(channel: string | number);
|
|
104
|
-
set serialFilters(filters: SerialPortFilter[]);
|
|
105
|
-
get serialFilters(): SerialPortFilter[];
|
|
106
|
-
set serialConfigPort(config_port: SerialOptions);
|
|
107
|
-
get serialConfigPort(): SerialOptions;
|
|
108
|
-
get isConnected(): boolean;
|
|
109
|
-
get isConnecting(): boolean;
|
|
110
|
-
get isDisconnected(): boolean;
|
|
111
|
-
get useRTSCTS(): boolean;
|
|
112
|
-
set useRTSCTS(value: boolean);
|
|
113
|
-
get deviceNumber(): number;
|
|
114
|
-
get uuid(): string;
|
|
115
|
-
get typeDevice(): string;
|
|
116
|
-
get queue(): QueueData[];
|
|
117
|
-
get timeoutBeforeResponseBytes(): number;
|
|
118
|
-
set timeoutBeforeResponseBytes(value: number);
|
|
119
|
-
get fixedBytesMessage(): number | null;
|
|
120
|
-
set fixedBytesMessage(length: number | null);
|
|
121
|
-
get responseDelimited(): boolean;
|
|
122
|
-
set responseDelimited(value: boolean);
|
|
123
|
-
get responsePrefixLimited(): boolean;
|
|
124
|
-
set responsePrefixLimited(value: boolean);
|
|
125
|
-
get responseSufixLimited(): boolean;
|
|
126
|
-
set responseSufixLimited(value: boolean);
|
|
127
|
-
get responseLimiter(): string | RegExp | null;
|
|
128
|
-
set responseLimiter(limiter: string | RegExp | null);
|
|
129
|
-
get bypassSerialBytesConnection(): boolean;
|
|
130
|
-
set bypassSerialBytesConnection(value: boolean);
|
|
131
|
-
timeout(bytes: string[], event: string): Promise<void>;
|
|
132
|
-
disconnect(detail?: null): Promise<void>;
|
|
133
|
-
connect(): Promise<boolean>;
|
|
134
|
-
serialDisconnect(): Promise<void>;
|
|
135
|
-
serialPortsSaved(ports: SerialPort[]): Promise<void>;
|
|
136
|
-
serialErrors(error: unknown | Error | DOMException): void;
|
|
137
|
-
serialConnect(): Promise<void>;
|
|
138
|
-
serialForget(): Promise<boolean>;
|
|
139
|
-
decToHex(dec: number | string): string;
|
|
140
|
-
hexToDec(hex: string): number;
|
|
141
|
-
hexMaker(val?: string, min?: number): string;
|
|
142
|
-
add0x(bytes: string[]): string[];
|
|
143
|
-
bytesToHex(bytes: string[]): string[];
|
|
144
|
-
appendToQueue(arr: string[], action: string): Promise<void>;
|
|
145
|
-
serialSetConnectionConstant(listen_on_port?: number): string | Uint8Array | string[] | number[] | null;
|
|
146
|
-
serialMessage(code: string[]): void;
|
|
147
|
-
serialCorruptMessage(data: Uint8Array | number[] | string[] | never | null | string | ArrayBuffer): void;
|
|
148
|
-
clearSerialQueue(): void;
|
|
149
|
-
sumHex(arr: string[]): string;
|
|
150
|
-
softReload(): void;
|
|
151
|
-
sendConnect(): Promise<void>;
|
|
152
|
-
sendCustomCode(customCode: CustomCode): Promise<void>;
|
|
153
|
-
stringToArrayHex(string: string): string[];
|
|
154
|
-
stringToArrayBuffer(string: string, end: string): ArrayBufferLike;
|
|
155
|
-
parseStringToBytes(string: string, end: string): string[];
|
|
156
|
-
parseUint8ToHex(array: Uint8Array): string[];
|
|
157
|
-
parseHexToUint8(array: string[]): Uint8Array;
|
|
158
|
-
stringArrayToUint8Array(strings: string[]): Uint8Array;
|
|
159
|
-
parseUint8ArrayToString(array: string[]): string;
|
|
160
|
-
parseStringToTextEncoder(string: string, end: string): Uint8Array;
|
|
161
|
-
hexToAscii(hex: string | number): string;
|
|
162
|
-
asciiToHex(asciiString: string): string;
|
|
163
|
-
getResponseAsArrayBuffer(): void;
|
|
164
|
-
getResponseAsArrayHex(): void;
|
|
165
|
-
getResponseAsUint8Array(): void;
|
|
166
|
-
getResponseAsString(): void;
|
|
167
|
-
}
|
|
168
|
-
export declare class Core extends Dispatcher implements ICore {
|
|
169
|
-
#private;
|
|
170
|
-
protected __internal__: Internal;
|
|
171
|
-
constructor({ filters, config_port, no_device, device_listen_on_channel, bypassSerialBytesConnection, socket, transformStream, }?: CoreConstructorParams);
|
|
172
|
-
set listenOnChannel(channel: string | number);
|
|
173
|
-
get lastAction(): string | null;
|
|
174
|
-
get listenOnChannel(): number;
|
|
175
|
-
set serialFilters(filters: SerialPortFilter[]);
|
|
176
|
-
get serialFilters(): SerialPortFilter[];
|
|
177
|
-
set serialConfigPort(config_port: SerialOptions);
|
|
178
|
-
get serialConfigPort(): SerialOptions;
|
|
179
|
-
get useRTSCTS(): boolean;
|
|
180
|
-
set useRTSCTS(value: boolean);
|
|
181
|
-
get isConnected(): boolean;
|
|
182
|
-
get isConnecting(): boolean;
|
|
183
|
-
get isDisconnected(): boolean;
|
|
184
|
-
get deviceNumber(): number;
|
|
185
|
-
get uuid(): string;
|
|
186
|
-
get typeDevice(): string;
|
|
187
|
-
get queue(): QueueData[];
|
|
188
|
-
get responseDelimited(): boolean;
|
|
189
|
-
set responseDelimited(value: boolean);
|
|
190
|
-
get responsePrefixLimited(): boolean;
|
|
191
|
-
set responsePrefixLimited(value: boolean);
|
|
192
|
-
get responseSufixLimited(): boolean;
|
|
193
|
-
set responseSufixLimited(value: boolean);
|
|
194
|
-
get responseLimiter(): string | RegExp | null;
|
|
195
|
-
set responseLimiter(limiter: string | RegExp | null);
|
|
196
|
-
get fixedBytesMessage(): number | null;
|
|
197
|
-
set fixedBytesMessage(length: number | null);
|
|
198
|
-
get timeoutBeforeResponseBytes(): number;
|
|
199
|
-
set timeoutBeforeResponseBytes(value: number);
|
|
200
|
-
get bypassSerialBytesConnection(): boolean;
|
|
201
|
-
set bypassSerialBytesConnection(value: boolean);
|
|
202
|
-
get useSocket(): boolean;
|
|
203
|
-
get connectionBytes(): Uint8Array;
|
|
204
|
-
set portPath(path: string | null);
|
|
205
|
-
get portPath(): string | null;
|
|
206
|
-
set portVendorId(vendorId: number | string | null);
|
|
207
|
-
get portVendorId(): number | string | null;
|
|
208
|
-
set portProductId(productId: number | string | null);
|
|
209
|
-
get portProductId(): number | string | null;
|
|
210
|
-
set socketPortParser(string: "byte-length" | "inter-byte-timeout");
|
|
211
|
-
get socketPortParser(): "byte-length" | "inter-byte-timeout";
|
|
212
|
-
set socketPortParserInterval(value: number);
|
|
213
|
-
get socketPortParserInterval(): number;
|
|
214
|
-
set socketPortParserLength(value: number);
|
|
215
|
-
get socketPortParserLength(): number;
|
|
216
|
-
get parserForSocket(): {
|
|
217
|
-
name: "byte-length";
|
|
218
|
-
length: number;
|
|
219
|
-
interval?: undefined;
|
|
220
|
-
} | {
|
|
221
|
-
name: "inter-byte-timeout";
|
|
222
|
-
interval: number;
|
|
223
|
-
length?: undefined;
|
|
224
|
-
};
|
|
225
|
-
get configDeviceSocket(): object;
|
|
226
|
-
timeout(bytes: string | Uint8Array | Array<string> | Array<number>, event: string): Promise<void>;
|
|
227
|
-
disconnect(detail?: null): Promise<void>;
|
|
228
|
-
socketResponse(data: any): void;
|
|
229
|
-
connect(): Promise<boolean>;
|
|
230
|
-
serialDisconnect(): Promise<void>;
|
|
231
|
-
getResponseAsArrayBuffer(): void;
|
|
232
|
-
getResponseAsArrayHex(): void;
|
|
233
|
-
getResponseAsUint8Array(): void;
|
|
234
|
-
getResponseAsString(): void;
|
|
235
|
-
serialPortsSaved(ports: SerialPort[]): Promise<void>;
|
|
236
|
-
serialErrors(error: any): void;
|
|
237
|
-
serialConnect(): Promise<void>;
|
|
238
|
-
serialForget(): Promise<boolean>;
|
|
239
|
-
decToHex(dec: number | string): string;
|
|
240
|
-
hexToDec(hex: string): number;
|
|
241
|
-
hexMaker(val?: string, min?: number): string;
|
|
242
|
-
add0x(bytes: string[]): string[];
|
|
243
|
-
bytesToHex(bytes: string[]): string[];
|
|
244
|
-
validateBytes(data: string | Uint8Array | Array<string> | Array<number>): Uint8Array;
|
|
245
|
-
appendToQueue(arr: string | Uint8Array | string[] | number[], action: string): Promise<void>;
|
|
246
|
-
serialSetConnectionConstant(listen_on_port?: number): string | Uint8Array | string[] | number[] | null;
|
|
247
|
-
serialMessage(code: string[] | Uint8Array<ArrayBufferLike> | string | ArrayBuffer): void;
|
|
248
|
-
serialCorruptMessage(code: Uint8Array | number[] | string[] | never | null | string | ArrayBuffer): void;
|
|
249
|
-
clearSerialQueue(): void;
|
|
250
|
-
sumHex(arr: string[]): string;
|
|
251
|
-
toString(): string;
|
|
252
|
-
softReload(): void;
|
|
253
|
-
sendConnect(): Promise<void>;
|
|
254
|
-
sendCustomCode({ code }?: CustomCode): Promise<void>;
|
|
255
|
-
stringToArrayHex(string: string): string[];
|
|
256
|
-
stringToArrayBuffer(string: string, end?: string): ArrayBufferLike;
|
|
257
|
-
parseStringToTextEncoder(string?: string, end?: string): Uint8Array;
|
|
258
|
-
parseStringToBytes(string?: string, end?: string): string[];
|
|
259
|
-
parseUint8ToHex(array: Uint8Array): string[];
|
|
260
|
-
parseHexToUint8(array: string[]): Uint8Array;
|
|
261
|
-
stringArrayToUint8Array(strings: string[]): Uint8Array;
|
|
262
|
-
parseUint8ArrayToString(array: Uint8Array | string[]): string;
|
|
263
|
-
hexToAscii(hex: string | number): string;
|
|
264
|
-
asciiToHex(asciiString: string): string;
|
|
265
|
-
$checkAndDispatchConnection(): boolean;
|
|
266
|
-
}
|
|
267
|
-
export {};
|
|
268
|
-
//# sourceMappingURL=Core.d.ts.map
|
package/dist/types/Core.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Core.d.ts","sourceRoot":"","sources":["../../lib/Core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,UAAU,SAAS;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC;IAC1E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,KAAK,gBAAgB,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEnE,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,EAAE,EAAE,gBAAgB,CAAC;IACrB,QAA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AC,MAAM,GAAE,MAAW,EAAE,GAAG,GAAE,MAAa,GAAG,UAAU;IAM7E,kBAAkB,CAAC,MAAM,GAAE,MAAW,EAAE,GAAG,GAAE,MAAa,GAAG,MAAM,EAAE;IAKrE,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE;IAI5C,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU;IAI5C,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU;IAatD,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,GAAG,MAAM;IAgB7D,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IASxC,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IASvC,2BAA2B,IAAI,OAAO;CAG9C"}
|
package/dist/types/Devices.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Core } from "./Core";
|
|
2
|
-
import { Dispatcher } from "./Dispatcher";
|
|
3
|
-
interface IDevice {
|
|
4
|
-
[key: string]: Core;
|
|
5
|
-
}
|
|
6
|
-
interface IDevices {
|
|
7
|
-
[key: string]: IDevice;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Manages and tracks all serial devices in the application
|
|
11
|
-
* Provides a centralized registry for device instances
|
|
12
|
-
* @extends Dispatcher
|
|
13
|
-
*/
|
|
14
|
-
export declare class Devices extends Dispatcher {
|
|
15
|
-
static instance: Devices;
|
|
16
|
-
static devices: IDevices;
|
|
17
|
-
constructor();
|
|
18
|
-
static $dispatchChange(device?: Core | null): void;
|
|
19
|
-
static typeError(type: string): void;
|
|
20
|
-
/**
|
|
21
|
-
* Registers a new device type in the registry
|
|
22
|
-
* @param type - The type name of the device (e.g., 'arduino', 'esp32')
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
static registerType(type: string): void;
|
|
26
|
-
/**
|
|
27
|
-
* Adds a device to the registry
|
|
28
|
-
* @param device - The Core device instance to add
|
|
29
|
-
* @returns The index of the device in its type registry
|
|
30
|
-
* @throws {Error} If device with the same ID already exists
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* const arduino = new Arduino();
|
|
34
|
-
* Devices.add(arduino);
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
static add(device: Core): number;
|
|
38
|
-
/**
|
|
39
|
-
* Gets a specific device by type and UUID
|
|
40
|
-
* @param type - The device type
|
|
41
|
-
* @param id - The device UUID
|
|
42
|
-
* @returns The device instance
|
|
43
|
-
* @throws {Error} If the device type is not supported
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* const device = Devices.get('arduino', 'uuid-123');
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
static get(type: string, id: string): Core;
|
|
50
|
-
static getAll(type?: string | null): IDevice | IDevices;
|
|
51
|
-
static getList(): Core[];
|
|
52
|
-
static getByNumber(type: string, device_number: number): Core | null;
|
|
53
|
-
static getCustom(type: string, device_number?: number): Core | null;
|
|
54
|
-
static connectToAll(): Promise<boolean>;
|
|
55
|
-
static disconnectAll(): Promise<boolean>;
|
|
56
|
-
static areAllConnected(): Promise<boolean>;
|
|
57
|
-
static areAllDisconnected(): Promise<boolean>;
|
|
58
|
-
static getAllConnected(): Promise<Core[]>;
|
|
59
|
-
static getAllDisconnected(): Promise<Core[]>;
|
|
60
|
-
}
|
|
61
|
-
export {};
|
|
62
|
-
//# sourceMappingURL=Devices.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Devices.d.ts","sourceRoot":"","sources":["../../lib/Devices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,UAAU,OAAO;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB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vailableListeners = AvailableListener[];
|
|
6
|
-
type DataType = string | number | boolean | object | null;
|
|
7
|
-
interface IDispatcher {
|
|
8
|
-
dispatch(type: string, data?: DataType): void;
|
|
9
|
-
dispatchAsync(type: string, data?: DataType, ms?: number): void;
|
|
10
|
-
on(type: string, callback: EventListener): void;
|
|
11
|
-
off(type: string, callback: EventListener): void;
|
|
12
|
-
serialRegisterAvailableListener(type: string): void;
|
|
13
|
-
availableListeners: AvailableListeners;
|
|
14
|
-
}
|
|
15
|
-
interface Listeners {
|
|
16
|
-
[key: string]: boolean;
|
|
17
|
-
debug: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare class Dispatcher extends EventTarget implements IDispatcher {
|
|
20
|
-
__listeners__: Listeners;
|
|
21
|
-
__debug__: boolean;
|
|
22
|
-
__listenersCallbacks__: {
|
|
23
|
-
key: string;
|
|
24
|
-
callback: EventListenerOrEventListenerObject;
|
|
25
|
-
}[];
|
|
26
|
-
/**
|
|
27
|
-
* Dispatches an event with the specified type and data
|
|
28
|
-
* @param type - The event type to dispatch
|
|
29
|
-
* @param data - Optional data to attach to the event
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* dispatcher.dispatch('connected', { port: 'COM3' });
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
dispatch(type: string, data?: DataType): void;
|
|
36
|
-
/**
|
|
37
|
-
* Dispatches an event asynchronously after a specified delay
|
|
38
|
-
* @param type - The event type to dispatch
|
|
39
|
-
* @param data - Optional data to attach to the event
|
|
40
|
-
* @param ms - Delay in milliseconds (default: 100)
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* dispatcher.dispatchAsync('timeout', { reason: 'no response' }, 500);
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
dispatchAsync(type: string, data?: null, ms?: number): void;
|
|
47
|
-
/**
|
|
48
|
-
* Registers an event listener for the specified event type
|
|
49
|
-
* @param type - The event type to listen to
|
|
50
|
-
* @param callback - The callback function to execute when the event is triggered
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* dispatcher.on('connected', (event) => {
|
|
54
|
-
* console.log('Device connected', event.detail);
|
|
55
|
-
* });
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
on(type: string, callback: EventListenerOrEventListenerObject): void;
|
|
59
|
-
/**
|
|
60
|
-
* Removes an event listener for the specified event type
|
|
61
|
-
* @param type - The event type to stop listening to
|
|
62
|
-
* @param callback - The callback function to remove
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const handler = (event) => console.log(event.detail);
|
|
66
|
-
* dispatcher.on('data', handler);
|
|
67
|
-
* dispatcher.off('data', handler);
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
off(type: string, callback: EventListenerOrEventListenerObject): void;
|
|
71
|
-
/**
|
|
72
|
-
* Registers an available listener type for tracking
|
|
73
|
-
* @param type - The event type to register
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
serialRegisterAvailableListener(type: string): void;
|
|
77
|
-
/**
|
|
78
|
-
* Gets the list of all available listeners and their state
|
|
79
|
-
* @returns Array of listener objects with type and listening status
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* const listeners = dispatcher.availableListeners;
|
|
83
|
-
* console.log(listeners); // [{ type: 'connected', listening: true }, ...]
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
get availableListeners(): AvailableListeners;
|
|
87
|
-
/**
|
|
88
|
-
* Removes all event listeners except internal ones (like queue listeners)
|
|
89
|
-
* Resets all listener states to false
|
|
90
|
-
* @example
|
|
91
|
-
* ```typescript
|
|
92
|
-
* dispatcher.removeAllListeners();
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
removeAllListeners(): void;
|
|
96
|
-
}
|
|
97
|
-
export {};
|
|
98
|
-
//# sourceMappingURL=Dispatcher.d.ts.map
|
|
@@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