/** * Project the committed kit index out of a design map and a page walk. * * WHY THIS IS GENERATED AND NOT HAND-WRITTEN. The index is an input to variant * resolution, and a hand-built one goes quietly out of date the first time the * kit gains a variant. Quiet is the whole problem: a missing variant reads as * "no counterpart in the kit" rather than "nobody looked", and the two call for * opposite responses from whoever reads the report. * * WHY IT CALLS THE API AT ALL, given a walk already happened. The walk sees * variant *names*, which carry the axes. It does not see * `componentPropertyDefinitions` — Figma returns those only for nodes requested * directly, never for one reached by descending a page. Properties are where a * kit keeps everything the axes do not (whether a button draws its icon, * whether a card has an action row), and an index that omits them describes * something other than what a reader will see. * * The index is scoped to what the map references. A kit has thousands of nodes * and a catalog points at dozens; keeping the rest would make the committed * file a second copy of the design document, which is exactly the thing a * committed index exists to avoid needing. */ import type { DesignMap } from "@design-parity/core"; import type { FigmaRestClient } from "@design-parity/adapter-figma"; import type { InventoryInstance, KitIndex, KitInventory, KitPropertyValue, KitSet, KitStandalone } from "./types.js"; /** * Every node id the map points at in `fileKey`, across both the string and the * tagged-list form of `ref`. * * Refs naming a different file are skipped rather than stripped of their key: a * repo may map some components to one kit and some to another, and an index is * always about one file. */ export declare function referencedNodeIds(map: Pick, fileKey: string): Set; /** The vocabulary skeleton: which sets, standalones and specimens to keep. */ export interface KitSkeleton { sets: Record; standalone: Record; /** Referenced ids that are no component at all — specimen frames. */ specimenIds: string[]; } /** * Decide what the index keeps, from the walk alone. * * A referenced node is either one variant of a set — in which case the whole * set is the vocabulary for that component — or a standalone component. Keep * the standalone itself unconditionally; when its name has a `Horizontal/…` * style folder, its siblings form the variant vocabulary and are kept beside * it. * * Pure, so the keep/drop decisions can be pinned without a kit or a network. */ export declare function buildSkeleton(inventory: KitInventory, referenced: ReadonlySet): KitSkeleton; /** * Attach a set's component properties and its configured-instance render * handles, given the definitions fetched for that set. * * Pure, and the heart of the property-instance pairing: it decides which * instances are worth committing and what property vector each one stands for. */ export declare function attachProperties(set: KitSet, definitions: Record, candidateInstances: InventoryInstance[]): { properties: number; instances: number; }; export interface BuildKitIndexOptions { map: Pick; inventory: KitInventory; fileKey: string; /** * Client used to read component-property definitions and specimen names. * Omit for an offline rebuild: the skeleton is derivable from the walk alone, * and the result is then an index with no property vocabulary — honest, but * unable to pair a property-shaped variant. */ client?: FigmaRestClient; /** * A previously generated index, used only when `client` is absent: its * specimen names are carried forward so an offline rebuild does not silently * drop vocabulary an authenticated run had established. */ previous?: Pick; /** What to record as having written the file. */ generatedBy?: string; log?: (message: string) => void; } export interface BuildKitIndexResult { index: KitIndex; stats: { sets: number; variants: number; renderAliases: number; standalone: number; specimens: number; propertied: number; configuredInstances: number; }; } /** Build the committed index. */ export declare function buildKitIndex(opts: BuildKitIndexOptions): Promise; //# sourceMappingURL=build.d.ts.map