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.
Parameters
Section titled “Parameters”readonly ScannedFile[]
options
Section titled “options”assetRoot
Section titled “assetRoot”string
string
resolveTilesetGrid?
Section titled “resolveTilesetGrid?”(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.
tilesetGrid?
Section titled “tilesetGrid?”{ cellHeight: number; cellWidth: number; cols: number; rows: number; }
Fallback grid for tilesets when no per-tileset grid is resolved.
tilesetGrid.cellHeight
Section titled “tilesetGrid.cellHeight”number
tilesetGrid.cellWidth
Section titled “tilesetGrid.cellWidth”number
tilesetGrid.cols
Section titled “tilesetGrid.cols”number
tilesetGrid.rows
Section titled “tilesetGrid.rows”number
Returns
Section titled “Returns”object
scan:
ScanResult
spec:
object
spec.assetRoot
Section titled “spec.assetRoot”assetRoot:
string
Root directory the asset paths are relative to (e.g. “public/assets”).
spec.assets
Section titled “spec.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.
spec.name
Section titled “spec.name”name:
string
Human-readable source name (e.g. “kaykit-free”, “my-tileset-pack”).
spec.specVersion
Section titled “spec.specVersion”specVersion:
1
Spec format version (this schema is v1).