Skip to content

buildAssetSourceSpec

buildAssetSourceSpec(files, options): object

Defined in: packages/declarative-hex-worlds/src/asset-source/scan.ts:246

Build a candidate AssetSourceSpec from a scan. Non-tileset assets are emitted as-is; tilesets are given a placeholder grid (the CLI overwrites it with author input — a placeholder keeps the spec shape valid for preview). Returns the spec plus the scan’s skipped/needs-grid info so the caller can surface it.

readonly ScannedFile[]

string

string

(asset) => { cellHeight: number; cellWidth: number; cols: number; rows: number; } | undefined

Per-tileset grid resolver (the CLI supplies this — it reads the PNG bytes and derives the grid via readPngDimensions + inferTilesetGrid, keeping this function pure of fs/image-decode). Return undefined to fall back to tilesetGrid. When BOTH are absent a tileset keeps the placeholder grid and is reported in scan.tilesetsNeedingGrid so the author can fix it.

{ cellHeight: number; cellWidth: number; cols: number; rows: number; }

Fallback grid for tilesets when no per-tileset grid is resolved.

number

number

number

number

object

scan: ScanResult

spec: object

assetRoot: string

Root directory the asset paths are relative to (e.g. “public/assets”).

assets: ({ biome: string; edgeMask?: number; format: "png" | "glb" | "gltf"; id: string; path: string; role: "tile"; } | { biome?: string; format: "png"; grid: { cellHeight: number; cellWidth: number; cols: number; rows: number; }; id: string; path: string; role: "tileset"; transition?: { edgeCells: Record<string, number>; }; } | { category?: "unit" | "prop" | "structure" | "npc" | "enemy" | "pc" | "encounter"; format: "png"; id: string; path: string; role: "sprite"; } | { category?: "unit" | "prop" | "structure" | "npc" | "enemy" | "pc" | "encounter"; format: "glb" | "gltf"; id: string; path: string; role: "model"; })[]

Ordered asset records.

name: string

Human-readable source name (e.g. “kaykit-free”, “my-tileset-pack”).

specVersion: 1

Spec format version (this schema is v1).