All files / web/src/components/toys/euclid/engine macroPreview.ts

0% Statements 0/33
0% Branches 0/1
0% Functions 0/1
0% Lines 0/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                                                   
/**
 * Pure preview geometry functions for macro tool.
 *
 * These compute result-focused preview geometry from raw {x,y} positions — no
 * construction state, no fact store, no side effects. The goal is to show
 * the student what the macro WILL PRODUCE, not the internal proof steps.
 */

import type { GhostElement } from '../types'
import type { Pt } from './recipe/types'
import { recipeToPreview } from './recipe/adapters'
import {
  RECIPE_PROP_1,
  RECIPE_PROP_2,
  RECIPE_PROP_3,
  RECIPE_REGISTRY,
} from './recipe/definitions/registry'

export interface MacroPreviewResult {
  /** Supporting ghost elements (construction circles that explain the result) */
  ghostElements: GhostElement[]
  /** Output geometry (result segments, points) — rendered slightly more opaque */
  resultElements: GhostElement[]
}

// ── Recipe-derived preview functions ──────────────────────────────

/** Registry mapping propId → preview function */
export const MACRO_PREVIEW_REGISTRY: Record<number, (inputs: Pt[]) => MacroPreviewResult | null> = {
  1: recipeToPreview(RECIPE_PROP_1, RECIPE_REGISTRY),
  2: recipeToPreview(RECIPE_PROP_2, RECIPE_REGISTRY),
  3: recipeToPreview(RECIPE_PROP_3, RECIPE_REGISTRY),
}