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:
Manuel Bahamóndez-Honores 2026-02-18 05:49:46 -03:00
parent de31939a28
commit 2d4cb35e51
23 changed files with 988 additions and 212 deletions

View file

@ -2,6 +2,7 @@ import SerialConnection from "./serial_connection.js";
class WebSerialConnection extends SerialConnection {
/** @param {any} serialPort */
constructor(serialPort) {
super();
@ -23,15 +24,18 @@ class WebSerialConnection extends SerialConnection {
}
/** @returns {Promise<WebSerialConnection | null>} */
static async open() {
// ensure browser supports web serial
// @ts-ignore - Web Serial API
if(!navigator.serial){
alert("Web Serial is not supported in this browser");
return null;
}
// ask user to select device
// @ts-ignore - Web Serial API
const serialPort = await navigator.serial.requestPort({
filters: [],
});
@ -45,6 +49,7 @@ class WebSerialConnection extends SerialConnection {
}
/** @returns {Promise<void>} */
async close() {
// release reader lock
@ -63,6 +68,10 @@ class WebSerialConnection extends SerialConnection {
}
/**
* @param {Uint8Array} bytes
* @returns {Promise<void>}
*/
/* override */ async write(bytes) {
const writer = this.writable.getWriter();
try {