mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
Replace hand-written .d.ts with JSDoc + tsc auto-generation
- Delete hand-written index.d.ts that drifted from source - Add JSDoc type annotations to all source files - Create src/types.js with shared typedefs (SelfInfo, Contact, ContactMessage, ChannelInfo, RepeaterStats, etc.) - Add tsconfig.json for declaration generation - Add build:types script and prepublishOnly hook - Add GitHub Actions CI workflow for type checking - Use Uint8Array everywhere (no Buffer references) - Add semantic type aliases (EpochSeconds, Milliseconds, MilliVolts) - Add typed event overloads on Connection (on/once/off) - All 11 PR #15 review comments addressed
This commit is contained in:
parent
de31939a28
commit
2d4cb35e51
23 changed files with 988 additions and 212 deletions
|
|
@ -3,13 +3,15 @@ import SerialConnection from "./serial_connection.js";
|
|||
class NodeJSSerialConnection extends SerialConnection {
|
||||
|
||||
/**
|
||||
* @param path serial port to connect to, e.g: "/dev/ttyACM0" or "/dev/cu.usbmodem14401"
|
||||
* @param {string} path serial port to connect to, e.g: "/dev/ttyACM0" or "/dev/cu.usbmodem14401"
|
||||
*/
|
||||
constructor(path) {
|
||||
super();
|
||||
/** @type {string} */
|
||||
this.serialPortPath = path;
|
||||
}
|
||||
|
||||
/** @returns {Promise<void>} */
|
||||
async connect() {
|
||||
|
||||
// note: serialport module is only available in NodeJS, you shouldn't use NodeJSSerialConnection from a web browser
|
||||
|
|
@ -43,6 +45,7 @@ class NodeJSSerialConnection extends SerialConnection {
|
|||
|
||||
}
|
||||
|
||||
/** @returns {Promise<void>} */
|
||||
async close() {
|
||||
try {
|
||||
await this.serialPort.close();
|
||||
|
|
@ -51,6 +54,10 @@ class NodeJSSerialConnection extends SerialConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Uint8Array} bytes
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
/* override */ async write(bytes) {
|
||||
this.serialPort.write(bytes);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue