import { SerialEvent, Subscription, SerialOpenRequest, SerialOpenResult } from '@napplet/core'; /** * Napplet NAP serial shim entrypoint. * * @module */ /** * Handle serial.* messages from the shell via the central message listener. * Covers request results and shell-pushed serial.event messages. * * @param msg The shell envelope to route */ declare function handleSerialMessage(msg: { type: string; [key: string]: unknown; }): void; /** * Ask the runtime to select and open a serial session. * * @param request Filters, options, and optional chooser label * @returns Promise resolving to the runtime-assigned serial open result * * @example * ```ts * const { session } = await open({ options: { baudRate: 115200 } }); * ``` */ declare function open(request: SerialOpenRequest): Promise; /** * Write bytes to an open serial session. Uint8Array input is converted to a * plain byte array so the wire payload is JSON-shaped and easy to validate. * * @param sessionId Runtime-assigned serial session id * @param data Byte values to write * @returns Promise resolving after the runtime acknowledges the write */ declare function write(sessionId: string, data: Uint8Array | number[]): Promise; /** * Close an open serial session. * * @param sessionId Runtime-assigned serial session id * @param reason Optional reason for the close request * @returns Promise resolving after the runtime acknowledges the close */ declare function close(sessionId: string, reason?: string): Promise; /** * Register for shell-pushed serial events. * * @param handler Called with each serial event * @returns A Subscription with `close()` to stop listening */ declare function onEvent(handler: (event: SerialEvent) => void): Subscription; /** * Install the serial shim. Registration-only -- serial sessions are opened on demand. * * @returns cleanup function that clears pending requests and event handlers */ declare function installSerialShim(): () => void; export { close, handleSerialMessage, installSerialShim, onEvent, open, write };