/** * Shared Content-Length message framing for the JSON byte streams spoken by the * LSP and DAP stdio clients. Both protocols use the same base-protocol framing: * each message is a `Content-Length: \r\n\r\n` header block followed by `` * bytes of UTF-8 JSON. This module owns both directions so the LSP, DAP, and * LSP-mux transports don't each reimplement header encoding, chunk accumulation, * header scanning, and the mid-message remainder handoff. */ export declare class MessageFramingError extends Error { constructor(message: string); } /** * Encode one JSON-RPC message as a complete Content-Length frame. * * The body is UTF-8 encoded exactly once, straight into the frame buffer, so a * whole-document `didOpen`/`didChange` is not re-encoded or concatenated by the * sink. The returned buffer is never mutated afterwards; it is safe to write the * same frame to several sockets. */ export declare function encodeMessageFrame(message: unknown): Buffer; /** * Incremental Content-Length frame decoder for a JSON message byte stream. * * Incoming bytes are buffered as a list of chunks and only joined when a full * message spans several of them — concatenating the accumulator on every read * is O(n^2) for messages that span many reads (e.g. a large initial diagnostics * burst). Feed raw chunks with {@link push} and pull every complete message with * {@link drain}; {@link remainder} hands unconsumed bytes to another reader. */ export declare class MessageFramer { #private; /** Seed the buffer with bytes already read from the stream (e.g. a handshake leftover). */ constructor(seed: Uint8Array); /** * Append a freshly read chunk to the pending buffer. The bytes are retained * as a zero-copy view until consumed, so callers must not reuse or mutate * the chunk after pushing it. */ push(chunk: Uint8Array): void; /** * Yield the JSON text of every complete message currently buffered. A header * block without a `Content-Length` is non-protocol noise (e.g. a server * printing to stdout); `onResync` is invoked with the offending header text * and the framer drops past the bogus terminator to recover instead of * stalling on the same junk header forever. */ drain(onResync: (headerText: string) => void): Generator; /** Includes the current header so another reader can resume mid-body. */ remainder(): Buffer; }