/** * Types for the website capture pipeline. * * Phase 1: Capture — Extract HTML, CSS, screenshots, tokens, assets from a URL * Phase 2: Split — Decompose into per-section sub-compositions * Phase 3: Verify — Validate each section renders correctly * Phase 4: Scaffold — Assemble standard HyperFrames project */ // ── Phase 1: Capture ──────────────────────────────────────────────────────── export type CapturePhase = | "browser" | "navigation" | "core-extraction" | "fonts" | "assets" | "vision" | "contact-sheets" | "scaffold" | "complete"; export const DEFAULT_MAX_SCREENSHOTS = 21; export const CAPTURE_PHASE_SCHEMA = "hyperframes.capture.phase.v1" as const; export interface CapturePhaseProgress { schema: typeof CAPTURE_PHASE_SCHEMA; phase: CapturePhase; status: "started" | "completed" | "degraded"; /** Null before the post-navigation budget begins. */ remainingMs: number | null; reason?: | "budget-exhausted" | "disabled" | "request-timeout" | "provider-error" | "internal-error" | "blocked" | "webgl-disabled-retry" | "deadline"; } export interface CaptureOptions { /** Public http(s) URL to capture. With `localFile`, the result reports the file's `file://` URL instead. */ url: string; localFile?: string; localRoot?: string; /** Output directory */ outputDir: string; /** Viewport width (default: 1920) */ viewportWidth?: number; /** Viewport height (default: 1080) */ viewportHeight?: number; /** Page load timeout in ms (default: 120000) */ timeout?: number; /** Extra wait after load for JS to settle (default: 3000) */ settleTime?: number; /** Maximum screenshot files including the full-page plate (default: 21) */ maxScreenshots?: number; /** Skip asset downloads */ skipAssets?: boolean; /** Skip optional vision captioning */ skipVision?: boolean; /** Cooperative post-navigation budget in ms (default: 120000). */ postNavigationBudgetMs?: number; /** Optional hard wall-clock deadline for the complete capture run. */ captureDeadlineMs?: number; /** Stable, non-sensitive progress records for watchdog diagnostics. */ onPhase?: (event: CapturePhaseProgress) => void; /** Output JSON for programmatic use */ json?: boolean; } export interface CaptureResult { /** Whether capture completed successfully */ ok: boolean; /** Project output directory */ projectDir: string; /** Source URL */ url: string; /** * What the server answered for `url`, after redirects; null when navigation produced no * response. Also persisted to `extracted/response.json` for out-of-process consumers. */ httpStatus: number | null; /** Page title */ title: string; /** Extracted HTML data */ extracted: ExtractedHtml; /** Screenshot file paths (relative to projectDir) */ screenshots: string[]; /** Design tokens extracted from the page */ tokens: DesignTokens; /** Downloaded asset paths (relative to projectDir) */ assets: DownloadedAsset[]; /** * How many referenced assets are NOT here, by reason. * * Without this, a capture of a page with three images and a capture truncated to three images * are the same object. All zeroes means the capture kept everything it was offered. */ dropped: import("./assetDownloader.js").AssetDropCounts; /** Animation catalog (captured during full-JS page load) */ animationCatalog?: import("./animationCataloger.js").AnimationCatalog; /** Errors/warnings encountered during capture */ warnings: string[]; /** Final structured phase record emitted by a successful capture. */ lastPhase: CapturePhaseProgress; } export interface ExtractedHtml { /** All