export { InkSchema, InkSpec, schema } from './schema.js'; export { ActionDefinition, ComponentDefinition, standardActionDefinitions, standardComponentDefinitions } from './catalog.js'; import { Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, StateModel } from '@json-render/core'; export { Spec, StateModel } from '@json-render/core'; import { ReactNode } from 'react'; import 'zod'; /** * State setter function for updating application state */ type SetState = (path: string, value: unknown) => void; /** * Context passed to component render functions * @example * const StatusBadge: ComponentFn = (ctx) => { * return {ctx.props.label} * } */ interface ComponentContext> { props: InferComponentProps; children?: ReactNode; /** Emit a named event. The renderer resolves the event to an action binding from the element's `on` field. */ emit: (event: string) => void; /** * Two-way binding paths resolved from `$bindState` / `$bindItem` expressions. * Maps prop name → absolute state path for write-back. */ bindings?: Record; loading?: boolean; } /** * Component render function type for Ink * @example * const Badge: ComponentFn = ({ props }) => ( * {props.label} * ); */ type ComponentFn> = (ctx: ComponentContext) => ReactNode; /** * Registry of all component render functions for a catalog * @example * const components: Components = { * Badge: ({ props }) => {props.label}, * Card: ({ props, children }) => {children}, * }; */ type Components = { [K in keyof InferCatalogComponents]: ComponentFn; }; /** * Action handler function type * @example * const exit: ActionFn = async (params, setState) => { * process.exit(0); * }; */ type ActionFn> = (params: InferActionParams | undefined, setState: SetState, state: StateModel) => Promise; /** * Registry of all action handlers for a catalog * @example * const actions: Actions = { * exit: async (params, setState) => { process.exit(0); }, * }; */ type Actions = { [K in keyof InferCatalogActions]: ActionFn; }; export type { ActionFn, Actions, ComponentContext, ComponentFn, Components, SetState };