/** * projectIndex.ts — build and cache an in-memory model of a whole MV project. * * Instead of re-reading and re-parsing data/*.json on every query, the index is * built once and reused until the data directory changes (detected by a cheap * mtime signature). It exposes a normalised view of every database, map, event, * common event, switch and variable, plus a flat list of "reference sources" * (every command list in the project and what it touches) that powers the graph * and validation layers. * * Roadmap #1 (Comprensión del proyecto). */ import { type RefSet, type WriteSet, type ReadSet } from "./references.js"; export type EntityKind = "actors" | "classes" | "skills" | "items" | "weapons" | "armors" | "enemies" | "states" | "troops" | "tilesets" | "animations"; export interface IndexedEntity { id: number; name: string; } export interface NamedSlot { id: number; name: string; } export interface IndexedEvent { id: number; name: string; x: number; y: number; pageCount: number; refs: RefSet; /** Page appearance conditions (a switch/variable/item gating the page). */ conditionRefs: { switches: number[]; variables: number[]; items: number[]; }; } export interface Transfer { fromMap: number; fromEvent: number | null; toMap: number; x: number; y: number; } export interface IndexedMap { id: number; name: string; displayName: string; parentId: number; tilesetId: number; width: number; height: number; eventCount: number; events: IndexedEvent[]; refs: RefSet; transfers: Transfer[]; encounterTroops: number[]; /** True when MapInfos lists the map but the MapNNN.json file is absent. */ missing: boolean; } export interface IndexedCommonEvent { id: number; name: string; trigger: number; switchId: number; refs: RefSet; } /** One command list in the project and the entities it references. */ export interface RefSource { kind: "map-event" | "common-event" | "troop"; label: string; mapId?: number; eventId?: number; commonEventId?: number; troopId?: number; refs: RefSet; writes: WriteSet; reads: ReadSet; } export interface ProjectIndex { projectPath: string; builtAt: number; signature: string; gameTitle: string; start: { mapId: number; x: number; y: number; }; entities: Record; maps: IndexedMap[]; commonEvents: IndexedCommonEvent[]; switches: NamedSlot[]; variables: NamedSlot[]; refSources: RefSource[]; counts: Record; } /** * Build (or return a cached) index of the project at `projectPath`. * Rebuilds automatically when any data/*.json file changes; pass force to * bypass the cache. */ export declare function getProjectIndex(projectPath: string, force?: boolean): Promise; /** Drop the cached index (used by tests and after bulk external edits). */ export declare function clearProjectIndexCache(): void;