import { type CodegenFrameOptions, type CodegenNode } from './codegen.js'; import type { EditorDeclarations } from './declarations.js'; import type { BindingNodeContext, DataBindingDocument, DataCatalog } from '../binding/contracts.js'; import { type NodeJSON } from './store.js'; export declare const DESIGN_IR_SCHEMA: "pygmalion.design-ir"; export declare const DESIGN_IR_VERSION: 1; export declare const DESIGN_CODEGEN_PROJECT_SCHEMA: "pygmalion.codegen-project"; export declare const DESIGN_CODEGEN_PROJECT_VERSION: 1; export type DesignCompilePurpose = 'interactive' | 'export'; export type DesignCompileSeverity = 'info' | 'warning' | 'error'; export type DesignCompileStage = 'normalize' | 'analyze' | 'generate' | 'resource'; export type DesignCompileStatus = 'ready' | 'deferred' | 'blocked'; export interface DesignCompileDiagnostic { severity: DesignCompileSeverity; stage: DesignCompileStage; code: string; message: string; nodeId?: string; nodePath?: string; details?: Readonly>; } export interface DesignIRAsset { id: string; kind: 'image' | 'video' | 'background'; source: string; portability: 'embedded' | 'remote' | 'project' | 'ephemeral'; nodeIds: readonly string[]; } export interface DesignIRComponent { name: string; importPath: string; registered: boolean; connectionId?: string; sourcePath?: string; design?: { provider: string; documentId?: string; nodeId: string; url?: string; }; nodeIds: readonly string[]; } export interface DesignIRMetrics { nodeCount: number; maxDepth: number; hiddenNodeCount: number; componentCount: number; assetCount: number; } /** JSON-shaped host data produced from a repository-owned codegen contract. */ export type DesignCodegenData = null | string | number | boolean | readonly DesignCodegenData[] | { readonly [key: string]: DesignCodegenData; }; export interface DesignCodegenPromptReference { /** Repository-relative agent instruction file used to author this manifest. */ sourcePath: string; /** Host-owned revision bumped when the instructions or output contract change. */ revision: string; } export interface DesignCodegenFrameContract { /** Canonical source anchors chosen by the host, in addition to observed files. */ sourcePaths?: readonly string[]; /** Adapter-specific, deterministic metadata. It is never interpreted by core. */ metadata?: Readonly>; } /** * Checked-in output of a repository's codegen instructions. * * The prompt is provenance, not a runtime dependency: adapters consume this * manifest synchronously and never call a model while the editor is open. */ export interface DesignCodegenProjectManifest { schema: typeof DESIGN_CODEGEN_PROJECT_SCHEMA; version: typeof DESIGN_CODEGEN_PROJECT_VERSION; defaultTarget?: string; prompt?: DesignCodegenPromptReference; frames?: Readonly>; } export interface DesignCodegenPageContext { /** Canonical import id when available, otherwise the editor-local page id. */ id: string; name: string; route?: string; previewRoute?: string; sourcePaths: readonly string[]; flow?: string; scenario?: string; state?: string; stateKind?: string; scenarioId?: string; scenarioIds: readonly string[]; desiredState?: Readonly>; /** Current reproducible recipe; direct state stays separate for easy adapters. */ capture: { environment?: DesignCodegenData; preset?: DesignCodegenData; interactions: readonly DesignCodegenData[]; assertions: readonly DesignCodegenData[]; }; interactiveStateId?: string; interactiveOptionId?: string; interactiveOptionIds?: readonly string[]; viewport: { width: number; height: number; }; /** Frame-specific checked-in contract selected by id. */ contract?: DesignCodegenFrameContract; } export interface DesignCodegenRuntimeContext { page?: DesignCodegenPageContext; project?: DesignCodegenProjectManifest; } export interface DesignIntermediateDocumentV1 { schema: typeof DESIGN_IR_SCHEMA; version: typeof DESIGN_IR_VERSION; root: NodeJSON; frame?: CodegenFrameOptions; components: readonly DesignIRComponent[]; assets: readonly DesignIRAsset[]; metrics: DesignIRMetrics; } export interface DesignCompileLimits { /** Interactive code output pauses above this size until explicitly requested. */ previewNodeLimit: number; /** Compilation is blocked instead of silently dropping nodes. */ maxNodes: number; maxDepth: number; maxOutputBytes: number; } export declare const DEFAULT_DESIGN_COMPILE_LIMITS: Readonly; export interface DesignCodegenAdapterContext extends DesignCodegenRuntimeContext { document: DesignIntermediateDocumentV1; /** The editor's declarations the adapter generates against. */ declarations: CompileDeclarations; } export interface DesignCodegenAdapterOutput { code: string; diagnostics?: readonly DesignCompileDiagnostic[]; /** * Host-owned, JSON-only input for an optional asynchronous parity check. * Core never interprets the payload or runs it while a frame is switching. */ validation?: DesignCodegenValidationRequest; } export interface DesignCodegenValidationRequest { /** Selects the host validator that understands payload. */ kind: string; /** Deterministic repository data needed to reproduce this exact output. */ payload?: DesignCodegenData; } export type DesignCodegenValidationStatus = 'matched' | 'different' | 'unavailable'; export interface DesignCodegenValidationArtifacts { baseline?: string; rendered?: string; diff?: string; } export interface DesignCodegenValidationResult { status: DesignCodegenValidationStatus; message: string; diffRatio?: number; changedPixels?: number; totalPixels?: number; artifacts?: DesignCodegenValidationArtifacts; } /** A transport-neutral host hook. It may call local Vite or a hosted service. */ export type DesignCodegenValidator = (request: DesignCodegenValidationRequest, options: { signal: AbortSignal; }) => Promise; export interface DesignCodegenAdapter { id: string; label: string; language: string; extension: string; /** * Repository adapters generate from checked-in source contracts rather than * approximating the captured design tree. They still receive the document * for source-map context, but design-IR warnings and preview size deferral do * not describe their output. */ basis?: 'design-ir' | 'repository'; generate(context: DesignCodegenAdapterContext): string | DesignCodegenAdapterOutput; } export interface DesignCompileOptions { /** Dynamic documents use the structured binding source plan, never literal-prop output. */ bindings?: { catalog: DataCatalog; document: DataBindingDocument; nodes: readonly BindingNodeContext[]; }; target?: string; purpose?: DesignCompilePurpose; force?: boolean; frame?: CodegenFrameOptions; limits?: Partial; /** Current repository frame and checked-in codegen contract for host adapters. */ context?: DesignCodegenRuntimeContext; } export interface DesignCompileResult { target: string; status: DesignCompileStatus; code: string; language?: string; extension?: string; document: DesignIntermediateDocumentV1; diagnostics: readonly DesignCompileDiagnostic[]; metrics: DesignIRMetrics & { outputBytes: number; }; validation?: DesignCodegenValidationRequest; } /** What compilation reads from the editor's declarations. */ export type CompileDeclarations = Pick; export declare function createDesignIntermediateDocument(declarations: CompileDeclarations, root: CodegenNode, frame?: CodegenFrameOptions): DesignIntermediateDocumentV1; export declare function registerDesignCodegenAdapter(adapter: DesignCodegenAdapter): () => void; export declare function getDesignCodegenAdapters(): readonly DesignCodegenAdapter[]; export declare function compileDesignDocument(declarations: CompileDeclarations, root: CodegenNode, options?: DesignCompileOptions): DesignCompileResult;