This documents framework v1, which is deprecated. Games already on it keep running and their authors can keep editing them, but new games are created on the current framework — start with React frontends.
Images
GameImageKey is string. Image keys are dynamic — generated per game from uploaded media, not an enum baked into the framework.
class XToken extends PieceDef {
readonly kind = "x-token";
readonly width = 110;
readonly height = 110;
readonly orientations = [
{ imageSrc: "XPiece" }, // GameImageKey string
{ imageSrc: null }, // blank tile
];
}
Where images bind
PieceDef.orientations[i].imageSrc: GameImageKey | null— primary use. The current orientation'simageSrcis rendered as the piece.- BWSS
Imagenodesrc: GameImageKey— used insiderender()returns. Seestyling.
Upload flow
Image keys are created when an author uploads media to the game (via the Boardweaver editor's Images panel). Each upload produces a stable string key (e.g. "XPiece", "CardBack"). The author then references that key by string in imageSrc / Image.src.
Authors writing code in this package do not invent image keys — they reference ones the game already has.
null vs missing
imageSrc value |
Rendered as |
|---|---|
null |
Blank tile (transparent at the piece's width×height). |
"ValidKey" |
The uploaded image. |
"UnknownKey" |
Nothing (renders empty). Never as a URL the author chose — the renderer resolves through the game's images map. |
Don't rely on the missing-key fallback to communicate UI state — use null explicitly so intent is clear.
In render mode
A render() function that uses an image uses the Image BWSS node:
readonly render: PieceRenderFn = (piece) => ({
type: "Image",
src: "XPiece",
style: { width: piece.width, height: piece.height },
});
Same key resolution — unknown keys render nothing.
Gotchas
GameImageKeyisstringat the type level — the compiler can't tell you a key is wrong. Typos resolve to "renders nothing."- Per-orientation
width/height(on aPieceOrientation) override thePieceDefclass default for that orientation. Use this when the same piece has multiple sizes per face. - A piece can mix image and shape mode across orientations:
[{ imageSrc: null }, { imageSrc: "FlippedCard" }]is valid. - For dynamic visuals that depend on state (a counter, an animated highlight), use
rendermode — image keys are static lookups.