- Updated dependencies [
1029580,8fec7c3]:- @chestnutlabs/toolpath-core@0.4.0
- @chestnutlabs/gcode-containers@0.4.0
-
#238
75f9f2bThanks @sobechestnut-dev! - Register.bgcodeas a container adapter so it flows through the existing parser pipeline (DD-011 phase 4c, #188). A.bgcodefile now "just works" throughGcodeParseSessionwithcontainers: 'auto'— sniffed by magic, decoded to plain G-code, and parsed to the same IR as the plain.gcode(proven by the golden-equivalence test).gcode-bgcode:openBgcodeContainer(bytes)implements the DD-005 §4.4{ id, sniff, open }shape (single plate;openPlate(0)streams the decoded G-code).openBgcode(bytes, { metadata: true })now also decodes the metadata (INI) and thumbnail blocks, so the adapter surfaces machine geometry frombed_shape, whitelisted slicer settings (feeding dialect detection + provenance), and thumbnails.gcode-parser: the batteries worker registers thebgcodeadapter besidegcode-3mf.
Verified end-to-end: a real Prusa XL cube
.bgcodeparses through the session to 11,417 segments with a 360×360 bed andprinter_modelmetadata. -
#233
83f0336Thanks @sobechestnut-dev! - New package@chestnutlabs/gcode-bgcode— binary G-code (.bgcode) decode, phase 1 (DD-011, epic #188). A license-clean, in-memory block walker that decodes Prusa.bgcodeto plain G-code for the existing parser/dialect/IR/renderer pipeline. Decode-only.Phase 1 ships the block walker + per-block CRC32 verification +
sniffBgcode/openBgcode, with None and DEFLATE compression and None encoding decoded end-to-end. MeatPack (phase 2) and heatshrink (phase 3) return honest, structuredContainerErrors (E_BGCODE_UNSUPPORTED_ENCODING/E_BGCODE_UNSUPPORTED_COMPRESSION) until then. All failures — bad magic/version, CRC mismatch, truncation, decompression bomb — are bounded structured errors.Clean-room from the published spec (RR-003): no AGPL
libbgcode/MeatPack code. Depends only on@chestnutlabs/toolpath-coreand@chestnutlabs/gcode-containers(forcrc32/ContainerError); nothree, framework, filesystem, or network. Container-adapter + worker registration + metadata/ thumbnail surfacing + the plain-vs-.bgcodegolden-equivalence test land in phase 4. -
#235
bb3085aThanks @sobechestnut-dev! - Binary G-code decode phase 3 (DD-011, #188): heatshrink decompression (windows 11 & 12, lookahead 4). With this, all four.bgcodecompression codecs and all encodings the spec defines are decoded — a.bgcodeGCode block compressed with heatshrink now decodes end-to-end to plain G-code.The decoder is a TypeScript port of the LZSS decoder from the ISC
atomicobject/heatshrink(© 2013–2015 Scott Vokes) — attribution preserved, no AGPLlibbgcode(RR-003 §8). It is validated against vectors built by an independent MSB-first bit-packer from the wire format (literal, single and multi-byte back-references, self-referential runs, window 11 & 12, a realistic repeated G-code fragment) plus block-level integration throughopenBgcode. Output is bounded (decompression-bomb defense). Container-adapter integration + real PrusaSlicer-file golden-equivalence follow in phase 4. -
#234
8c0ee6eThanks @sobechestnut-dev! - Binary G-code decode phase 2 (DD-011, #188): the MeatPack G-code encoding (both variants —MeatPackandMeatPack (comments preserved)). A.bgcodeGCode block encoded with MeatPack now decodes end-to-end (optionally after DEFLATE) to plain G-code.The decoder is a faithful TypeScript port of the MIT
jamesgopsill/meatpackunpacker (© 2025 James Gopsill), which is itself derived from the published Prusa spec — attribution preserved, and no AGPLlibbgcode/OctoPrint-MeatPack code (RR-003 §8). It is validated against hand-computed vectors (the nibble table applied by hand as an independent oracle: packing, left/right/double full-width escapes, the newline special case, and the no-spaces + disable-packing commands), plus block-level integration throughopenBgcode. Output is bounded (decompression-bomb defense) and invalid command bytes are structured errors. heatshrink compression remains phase 3.
-
#236
852db93Thanks @sobechestnut-dev! - Fix the.bgcodeDEFLATE flavor: it is zlib-wrapped, not raw (DD-011 phase 4 confirmation, #188). Verified against a real Prusa XL.bgcodefile — its DEFLATE-compressed Slicer/Print metadata blocks decode only with the zlib header and fail as raw. (GCode blocks use heatshrink, so this was invisible until a real file's metadata was exercised.) The decoder now usesDecompressionStream('deflate'), and a flavor-lock test asserts a raw-DEFLATE block is rejected so this can't regress. -
#237
f2e79e4Thanks @sobechestnut-dev! - Add the.bgcodegolden-equivalence killer test (DD-011 §D6, #188): a PrusaSlicer 2.9.6 primitive cube, committed in both.gcodeand.bgcode, is decoded and parsed, and its IR is asserted byte-identical to the IR of the plain.gcodeacross every geometry channel (positions, extrusion, kind, tool, layer). This pins decode correctness against the already-trusted plain-G-code path and exercises the real Prusa codec stack end-to-end (heatshrink-12 + MeatPack comments/no-spaces, DEFLATE metadata, thumbnails, per-block CRC32). Test/fixtures only — no code or public-API change. -
#239
b0ef69fThanks @sobechestnut-dev! -.bgcodesecurity hardening (DD-011 §7 + phase 5, #188): a deterministic adversarial fuzz corpus (adversarial.test.ts) — ~1600 inputs across pure-random bytes,GCDE-prefixed random, bit-flip mutations of a real file, and garbage payloads through every codec — asserting that only bounded, structuredContainerErrors ever escape (never a crash, unbounded allocation, or hang). Plus edge cases: an oversized declared size can't balloon memory, and unknown block types are walked past.Adds the §7 security-review record (
docs/design/SECURITY-REVIEW-DD-011-bgcode.md, prepared for maintainer sign-off) and a decode benchmark (tools/benchmark/results/) with real numbers (cube: 15.7 ms; 21 MB Prusa XL ColorMix: 3.3 s decode → 51 MB, all 856 CRC32s verified). Tests + docs only. -
Updated dependencies [
39348de,d161e80,82bd7ae]:- @chestnutlabs/toolpath-core@0.3.0
- @chestnutlabs/gcode-containers@0.3.0