@types/dom-serial
Version:
TypeScript definitions for dom-serial
77 lines (61 loc) • 2.21 kB
Markdown
# Installation
> `npm install --save @types/dom-serial`
# Summary
This package contains type definitions for dom-serial (https://wicg.github.io/serial/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/dom-serial.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/dom-serial/index.d.ts)
````ts
type EventHandler = (event: Event) => void;
interface SerialPortInfoBase {
serialNumber: string;
manufacturer: string;
locationId: string;
vendorId: string;
vendor: string;
productId: string;
product: string;
}
interface SerialPortFilter {
usbVendorId: number;
usbProductId?: number | undefined;
}
interface SerialPortInfo extends SerialPortInfoBase, SerialPortFilter {} // mix spec and Chromium implementation
type ParityType = "none" | "even" | "odd" | "mark" | "space";
type FlowControlType = "none" | "hardware";
interface SerialOptions {
baudRate: number;
dataBits?: number | undefined;
stopBits?: number | undefined;
parity?: ParityType | undefined;
bufferSize?: number | undefined;
flowControl?: FlowControlType | undefined;
}
interface SerialPort extends EventTarget {
onconnect: EventHandler;
ondisconnect: EventHandler;
readonly readable: ReadableStream; // Chromium implementation (spec: in)
readonly writable: WritableStream; // Chromium implementation (spec: out)
open(options: SerialOptions): Promise<void>;
close(): Promise<void>;
getInfo(): Partial<SerialPortInfo>;
forget(): Promise<void>;
}
interface SerialPortRequestOptions {
filters: SerialPortFilter[];
}
interface Serial extends EventTarget {
onconnect: EventHandler;
ondisconnect: EventHandler;
getPorts(): Promise<SerialPort[]>;
requestPort(options?: SerialPortRequestOptions): Promise<SerialPort>; // Chromium implementation (spec: SerialOptions)
}
interface Navigator {
readonly serial: Serial;
}
````
### Additional Details
* Last updated: Mon, 06 Nov 2023 22:41:05 GMT
* Dependencies: none
# Credits
These definitions were written by [Maciej Mroziński](https://github.com/maciejmrozinski).