Public surface of the adapter returned from createFormulaAdapter.

The adapter is stateful only in that it tracks the set of cell ids it has registered with the underlying graph; the graph itself owns the derived nodes once FormulaAdapter.registerFormula returns.

Late-registration recompute (issue #158). A formula that reads a cell the resolver cannot yet map records a dependency on this adapter's private directory-epoch input rather than silently dropping the edge. When the missing cell is later registered, call FormulaAdapter.refreshDirectory to bump the epoch: every formula that touched an unresolved reference recomputes, re-resolves against the now-populated directory, and picks up a real dependency edge on the freshly registered cell so subsequent value changes propagate normally. Without this bridge the derived would stay stale until an unrelated dependency happened to change.

interface FormulaAdapter {
    editFormula(ref: CellRef, ast: Ast): DerivedNode<FormulaResult>;
    refreshDirectory(): void;
    registered(): readonly string[];
    registerFormula(ref: CellRef, ast: Ast): DerivedNode<FormulaResult>;
}

Methods

  • Replace the formula registered at ref with a new AST (the formula-edit path, issue #158). If no formula is registered at ref this behaves exactly like FormulaAdapter.registerFormula.

    Parameters

    • ref: CellRef

      Cell reference whose formula is being edited.

    • ast: Ast

      New parsed formula expression.

    Returns DerivedNode<FormulaResult>

    The freshly registered derived node carrying the tagged FormulaResult.

    NodeHasDependentsError if the formula being replaced still has live dependents; downstream consumers must be released (or edited) before their producer.

    DisposalDuringCommitError if invoked while a commit is in progress on the graph.

  • Bump the directory epoch so every formula that referenced an as-yet-unresolved cell recomputes (issue #158). Call this after registering cells that existing formulas already reference — for example after a late graph.input(...) for a cell inside a previously-registered =SUM(A1:A3) range.

    Returns void

    Runs its own single-node commit, so it MUST be called outside an in-flight commit callback (it throws CommitInProgressError otherwise). It is a cheap no-op for formulas that never touched an unresolved reference: only those recorded a dependency on the epoch.

  • Snapshot of every CellId registered through this adapter so far, in insertion order. Only successful registrations are reflected — a registration that threw (e.g. a duplicate id) leaves this set unchanged (issue #158).

    Returns readonly string[]