/**
* Reactive TUI renderer.
* Components run once, and only the parts that depend on changed signals re-render.
*/
import { Renderer, type RendererOptions } from "./renderer.js";
import type { VNode } from "./vnode.js";
export interface ReactiveAppOptions extends RendererOptions {
/** Called before each render */
onRender?: () => void;
/** Called on error */
onError?: (error: Error) => void;
}
export interface ReactiveApp {
/** Force a full re-render */
rerender(): void;
/** Dispose the app and cleanup all reactive subscriptions */
dispose(): void;
/** Get the underlying renderer */
renderer: Renderer;
/** Resize the terminal */
resize(width: number, height: number): void;
}
/**
* Create a reactive TUI application.
*
* @example
* ```tsx
* import { createSignal, render } from 'treeli';
*
* function App() {
* const [count, setCount] = createSignal(0);
*
* return (
*
* Count: {count()}
*
* );
* }
*
* const app = render(App, { width: 80, height: 24 });
* ```
*/
export declare function render(App: () => VNode, options: ReactiveAppOptions): ReactiveApp;
/**
* Run a TUI app with terminal handling.
*
* @example
* ```tsx
* import { createSignal, run } from 'treeli';
*
* function App() {
* const [count, setCount] = createSignal(0);
*
* // Expose setter for keyboard handling
* (globalThis as any).setCount = setCount;
*
* return Count: {count()};
* }
*
* run(App, {
* onKeypress(key) {
* if (key === '+') (globalThis as any).setCount((c: number) => c + 1);
* if (key === 'q') return true; // Exit
* }
* });
* ```
*/
export interface RunOptions extends Omit {
/** Terminal width (defaults to stdout.columns or 80) */
width?: number;
/** Terminal height (defaults to stdout.rows or 24) */
height?: number;
/** Called when app starts */
onMount?: (app: ReactiveApp) => void;
/** Called when app exits */
onUnmount?: () => void;
/** Capture console output (default: true). Press Ctrl+L to toggle log viewer. */
captureConsole?: boolean;
/** Maximum number of console messages to keep in memory (default: 1000) */
maxConsoleMessages?: number;
}
export declare function run(App: () => VNode, options?: RunOptions): void;
//# sourceMappingURL=app.d.ts.map