Skip to main content

Module codec

Module codec 

Source
Expand description

Wire codec for the stdin/stdout protocol.

The renderer communicates with the host process over stdin (incoming messages) and stdout (outgoing events). Two wire formats are supported:

  • JSON – newline-delimited JSON (JSONL). Each message is a UTF-8 JSON object terminated by \n. Human-readable, easy to debug.

  • MsgPack – 4-byte big-endian length-prefixed MessagePack. Each message is [u32 BE length][msgpack payload]. Compact, faster to parse, supports native binary fields (e.g. pixel data).

The codec is auto-detected from the first byte of stdin ({ = JSON, anything else = MsgPack) and stored in a process-global OnceLock so that all emit paths (events, queries, screenshots) use the same format without threading the codec through every call site.

Enums§

Codec
Wire codec for the stdin/stdout protocol.

Constants§

MAX_MESSAGE_SIZE
Maximum size for a single wire message (64 MiB). Applied to both JSON line reads and msgpack length-prefixed frames.