G-code Preview — API Reference
    Preparing search index...

    @chestnutlabs/gcode-bgcode — Binary G-code (.bgcode) decode adapter (DD-011, epic #188).

    A license-clean, in-memory decoder for Prusa's binary G-code container. .bgcode is a container of ordinary G-code, so decoding it (block walk → CRC verify → decompress → decode → concatenate) yields plain G-code the existing parser/dialect/IR/renderer stack consumes unchanged. Decode-only.

    Clean-room from the published spec (RR-003) — no AGPL libbgcode/MeatPack code. Depends only on @chestnutlabs/toolpath-core and @chestnutlabs/gcode-containers (for crc32/ContainerError); no three, framework, filesystem, or network.

    All spec codecs are decoded (None/DEFLATE/heatshrink × None/MeatPack), validated against real Prusa files (golden-equivalence). Phase 4c registers a container adapter so .bgcode flows through the parser pipeline via containers: 'auto', surfacing machine geometry + settings + thumbnails.

    • Decode a .bgcode v1 buffer to plain G-code. Walks every block, verifies per-block CRC32 (when the file declares it), decompresses + decodes the GCode blocks, and concatenates them in file order. Non-GCode blocks are walked past (their metadata/thumbnails are surfaced in phase 4). Every failure is a structured, bounded ContainerError (from @chestnutlabs/gcode-containers) — never a crash or an unbounded read/allocation.

      Parameters

      Returns Promise<BgcodeDecodeResult>