/** * A dataset: a set of static facts extracted from the player's game files. Each dataset declares what it produces and reads its inputs only through the source * it is given, so the cache knows exactly which files the result depends on. * * A dataset only records what the game files say; deciding what the facts mean for a game * rule belongs to the rules layer. */ import type { BlkBlock } from '@wto/blk'; import type { GamePackName } from '../game-files.ts'; export interface DatasetSource { readBlk(pack: GamePackName, path: string): BlkBlock; readText(pack: GamePackName, path: string): string; readBytes(pack: GamePackName, path: string): Uint8Array; /** Every file path in a pack, sorted. */ listFiles(pack: GamePackName): readonly string[]; } export interface Dataset { /** File name of the cache entry; unique among datasets. */ readonly id: string; /** Raise when the extraction code or the shape of the result changes: old cache entries are then ignored. */ readonly version: number; /** The result must survive JSON.stringify / JSON.parse unchanged. */ extract(source: DatasetSource): T; }