Build sprite sheets
Use packStyle for one lockfile style or packSprites for an explicit list:
import { packSprites, packStyle } from "pixelkiln"
const sheet = packStyle(lock, "ground", loaded.root, {
outputRoles: ["tile-00", "tile-01"],
})
const shared = packSprites([
{ id: "anvil", path: "/absolute/art/anvil.png" },
{ id: "hammer", path: "/absolute/art/hammer.png" },
])
Both return PNG bytes, a deterministic JSON-compatible atlas, and details for
skipped files plus source hashes for provenance. packStyle also lists the
sheet's sets: each multi-output asset with its member frame ids, and for a
frame set the fps its provider recorded (12 when none was). renderSheetDocument(format, atlas, { imageName })
turns that atlas into the document an engine reads, aseprite (sheet JSON
with a frameTag per set and per-frame durations) or godot (a
SpriteFrames resource with one looping animation per frame set), or the
generic atlas itself; renderAsepriteSheet and renderGodotSpriteFrames
are the two writers. Common non-interlaced PNG color
modes and bit depths are accepted as inputs; packed output is always RGBA.
Corrupt and interlaced inputs are skipped with a specific reason. mountStyle
and mountSprites provide declared-cell placement when existing atlas
coordinates must remain stable.
The CLI adds a .pixelkiln.json companion, stages the three members together,
restores the previous bundle after ordinary write failures, and leaves
byte-identical members untouched. Library consumers can apply the same behavior
with writeManagedArtifactBundle(), then use verifyArtifactBundle() to detect
changed sources, outputs, or metadata without rendering again. The managed
writer adopts pre-companion files only when byte-identical, refuses to replace
unowned or manually modified output, and accepts { force: true } as an
explicit takeover. writeArtifactBundle() remains the lower-level transactional
primitive for callers with their own ownership policy.
Managed writes also keep a short-lived transaction journal beside the companion. The next invocation rolls back an interrupted pre-commit promotion or completes post-commit cleanup before checking ownership. Journal recovery is restricted to the current bundle's exact destinations and same-directory PixelKiln temp names; an unsafe journal or live concurrent writer is refused.