/** * Resolves parsed, positional {@link Reference}s against the live grid (via the * {@link FormulaGridAdapter}) into: * * 1. **Values** — {@link resolveCell}/{@link resolveRange} back the evaluator's * {@link EvalContext}, reading the grid's current cell values. * 2. **Dependencies** — {@link resolveDependencies} turns a formula's references * into stable {@link CellId} precedents and rectangular {@link RangeDependency} * regions for the {@link DependencyGraph}. * * Positional (`A1`) coordinates are data-model indices (see the adapter's * addressing contract), so they are stable across sort/filter/scroll; the * adapter maps them to stable `nodeId`/`colId` identities here. * * @packageDocumentation */ import type { FormulaGridAdapter } from '../formula-grid-adapter'; import type { CellId, FormulaValue, FormulaMatrix } from '../types/formula.types'; import type { CellRef, RangeRef, Reference } from './reference.types'; import type { RangeDependency } from '../graph/dependency-graph'; /** The resolved precedents of a single formula: discrete cells plus range regions. */ export interface ResolvedDependencies { /** Stable ids of every single-cell precedent. */ readonly cells: CellId[]; /** Rectangular precedent regions (for range references). */ readonly ranges: RangeDependency[]; } /** * Coerces an arbitrary grid-stored value into a {@link FormulaValue}. * * Numbers/strings/booleans pass through; `null`/`undefined` become blank * (`null`); `Date`s become Excel serial numbers; existing {@link FormulaError}s * propagate; anything else is stringified. * * @param v - The raw stored cell value. * @returns The normalized formula value. */ export declare function coerceGridValue(v: unknown): FormulaValue; /** * Resolver bound to one grid adapter. Stateless beyond the adapter reference, so * a single instance serves the whole engine. */ export declare class ReferenceResolver { private readonly adapter; constructor(adapter: FormulaGridAdapter); /** * Resolves a single-cell reference to its current value, or `#REF!` when it * falls outside the live data bounds. */ resolveCell: (ref: CellRef) => FormulaValue; /** * Resolves a range reference to a dense `[row][col]` matrix, clamping * whole-column/row ranges to the current data bounds. */ resolveRange: (ref: RangeRef) => FormulaMatrix; /** * Resolves a named range/cell string (e.g. `"B2"`, `"A1:C3"`, `"A:A"`) to a * {@link Reference}, or `null` when unparseable. * * @param a1 - The A1-notation target the name points at. */ parseNamedTarget(a1: string): Reference | null; /** * Resolves a **row-relative** bare name to a concrete column identity — by data * `field` first (`quantity`), then by spreadsheet column letter (`B`, `AA`) when * it is in bounds. Returns `null` when it matches neither (the caller yields * `#NAME?`). Field lookup wins so a real field never gets misread as a letter. * * @param name - The bare identifier as written. * @returns The resolved `colId`, or `null`. */ resolveColumnId(name: string): string | null; /** * Resolves a row-relative bare reference to the value in `rowIndex`. `#NAME?` * when the name matches no column; `#REF!` when the row is out of bounds. * * @param name - The bare identifier as written. * @param rowIndex - The data-model row to read from. */ resolveRowRelative: (name: string, rowIndex: number) => FormulaValue; /** * Converts a formula's references into dependency-graph inputs: discrete * precedent {@link CellId}s and rectangular {@link RangeDependency} regions. * * @param dependent - The stable id of the formula cell owning these references. * @param refs - The references extracted from its AST. */ resolveDependencies(dependent: CellId, refs: readonly Reference[]): ResolvedDependencies; } //# sourceMappingURL=reference-resolver.d.ts.map