import type { StandardSchemaV1 } from '@standard-schema/spec';
import { type Catalog, type CatalogOptions, type ComponentDefinition } from './catalog.js';
import { type JsonSchema } from './schema.js';
/** Plain, durable data. Renderer functions and binary attachments never enter a UI frame. */
export interface ComponentPresentation
> {
component: string;
props: P;
version: number;
fallbackText: string;
}
export interface ComponentFactory {
(props: Input): Promise>;
readonly definition: ComponentDefinition;
}
/** Reject values JSON would silently discard/coerce, and detach from caller-owned objects. */
export declare function snapshotComponentPresentation(value: T): T;
export declare function createComponent(definition: Omit>, 'props'> & {
props: S;
}, options?: CatalogOptions): ComponentFactory, StandardSchemaV1.InferOutput>;
export declare function createComponent >(definition: ComponentDefinition
, options?: CatalogOptions): ComponentFactory
;
export type ComponentRenderer
, Context = unknown> = (props: P, context?: Context) => unknown | Promise;
export interface ComponentManifest {
name: string;
title: string;
description: string;
version: number;
props?: JsonSchema;
}
export interface ComponentRegistry {
readonly catalog: Catalog;
readonly manifest: readonly ComponentManifest[];
register(definition: ComponentDefinition
, renderers: Record>): this;
/** Revalidate against the app's authoritative definition and regenerate trusted fallback text. */
prepare(presentation: ComponentPresentation): Promise;
render(presentation: ComponentPresentation, channel: string, context?: Context): Promise;
}
/** A registry is owned by one app/tenant; registering never mutates a shared singleton. */
export declare function createComponentRegistry(options?: CatalogOptions): ComponentRegistry;
export type TableCell = string | number | boolean | null;
export interface TableProps {
title?: string;
columns: {
key: string;
label: string;
align?: 'left' | 'right' | 'center';
format?: 'text' | 'number' | 'currency' | 'percent' | 'date' | 'link';
}[];
rows: Record[];
}
export interface ChartProps {
type: 'bar' | 'line';
title?: string;
xKey: string;
series: {
key: string;
label?: string;
}[];
data: Record[];
unit?: string;
}
export declare const table: ComponentFactory;
export declare const chart: ComponentFactory;
/** Prepare all JSON emissions before any sink receives a partial batch. Factories validate schemas. */
export declare function validatePresentationBatch(presentations: ComponentPresentation | readonly ComponentPresentation[]): ComponentPresentation[];
//# sourceMappingURL=registry.d.ts.map