/** * Binary IR serialization using MessagePack. * * Provides a compact binary alternative to JSON for storing and transporting * Manifest IR. Binary IR files use the `.mir` extension and include a * format version header so the layout can evolve safely. * * File layout: * bytes 0-2 : magic "MIR" (3 bytes) * byte 3 : format version (currently 0x01) * bytes 4+ : MessagePack-encoded IR payload * * Typical size reduction vs JSON: 40-60% for non-trivial IR. * Round-trip is lossless: pack(unpack(buf)) === unpack(pack(ir)). */ import type { IR } from './ir.js'; /** Magic prefix for `.mir` files: "MIR" */ export declare const MIR_MAGIC: readonly [77, 73, 82]; /** Current binary format version. Bump when the on-disk layout changes. */ export declare const MIR_FORMAT_VERSION = 1; /** Total header size in bytes (3 magic + 1 version). */ export declare const MIR_HEADER_SIZE = 4; /** Default output extension for binary IR files. */ export declare const MIR_EXTENSION = ".mir"; /** Information about a packed binary file. */ export interface BinaryIRInfo { formatVersion: number; payloadSize: number; totalSize: number; } /** Comparison statistics between JSON and binary representations. */ export interface CompressionStats { jsonBytes: number; binaryBytes: number; ratio: number; savingsPercent: number; } /** Error thrown when a `.mir` file cannot be decoded. */ export declare class BinaryIRError extends Error { constructor(message: string); } /** * Encode an IR object into a `.mir` binary buffer. * * The buffer is prefixed with the 4-byte `MIR`+version header, followed by * a MessagePack payload that round-trips losslessly. */ export declare function packIR(ir: IR): Uint8Array; /** * Decode a `.mir` binary buffer back into an IR object. * * Throws {@link BinaryIRError} if the header is missing, the magic bytes * don't match, or the format version is unsupported. */ export declare function unpackIR(buf: Uint8Array): IR; /** * Return structural info about a `.mir` buffer without fully decoding it. */ export declare function inspectBinaryIR(buf: Uint8Array): BinaryIRInfo; /** * Compute size comparison between JSON and binary representations of the * same IR. Useful for reporting compression ratios in CLI output. */ export declare function compareSizes(ir: IR): CompressionStats; /** * Derive a `.mir` output path from a source path by replacing the extension. * If the source already has `.mir` extension, returns it unchanged. * Strips `.ir.json` as a compound extension, then appends `.mir`. */ export declare function deriveMirPath(sourcePath: string): string; /** * Derive a `.ir.json` output path from a `.mir` source path. * If the source does not end in `.mir`, the `.ir.json` suffix is appended. */ export declare function deriveJsonPath(sourcePath: string): string; //# sourceMappingURL=binary-ir.d.ts.map