UNPKG

webserial-core

Version:

A strongly-typed, event-driven, abstract TypeScript library for the Web Serial API with custom parsers, command queue, handshake validation, and auto-reconnect.

21 lines (20 loc) 811 B
import { SerialProvider } from '../../types/index.js'; /** * Creates a {@link SerialProvider} that communicates with a Node.js serial * bridge server over WebSockets. * * The bridge server must implement the JSON wire protocol described in this * file's module documentation. A reference implementation is provided in * `demos/websocket/server.js`. * * @param serverUrl - The WebSocket URL of the bridge server (e.g. `"ws://localhost:8080"`). * @returns A `SerialProvider` that relays serial I/O over WebSocket. * * @example * ```ts * import { createWebSocketProvider, AbstractSerialDevice } from 'webserial-core'; * * AbstractSerialDevice.setProvider(createWebSocketProvider('ws://localhost:8080')); * ``` */ export declare function createWebSocketProvider(serverUrl: string): SerialProvider;