import { BindingDescriptor } from '../../types'; /** * Function signature for updating a single binding with new state */ type UpdateBindingFn = (binding: BindingDescriptor, state: Record) => void; /** * Wraps an array in a Proxy that intercepts mutation methods. * When any mutation method is called, the onMutate callback is triggered, * which updates all directives (like $for loops). * * Example: * const items = createReactiveArray(['a', 'b'], () => console.log('changed!')); * items.push('c'); // Logs: "changed!" * items[0] = 'x'; // Also triggers reactivity (index assignment) * * @param arr - The array to make reactive * @param onMutate - Callback to trigger when the array is mutated * @returns A reactive proxy of the array */ export declare function createReactiveArray(arr: T[], onMutate: () => void): T[]; /** * Creates a reactive state object that automatically updates the DOM * when properties change. * * How it works: * 1. Wraps the initial state in a Proxy * 2. When a property is set, finds all bindings that depend on it * 3. Re-evaluates those bindings and updates the DOM * * Supports dynamically adding new state keys (e.g., from module scripts). * When a new key is added, it automatically finds bindings that depend on it. * * Example: * const state = createReactiveState({ count: 0 }, bindings, updateFn); * state.count++; // Automatically updates all {count} bindings in the DOM * state.name = "hello"; // New key - finds and updates {name} bindings * * @param initialState - Initial state values extracted from component script * @param bindings - All template bindings that might depend on state * @param updateBinding - Function to re-evaluate and update a single binding * @param onStateChange - Optional callback when any state property changes (for directives) */ export declare function createReactiveState(initialState: Record, bindings: BindingDescriptor[], updateBinding: UpdateBindingFn, onStateChange?: () => void): Record; /** * Creates the update function that re-evaluates a binding and updates the DOM. * This should be called once when setting up reactivity, then passed to * createReactiveState. * * @param evaluateExpression - Function to evaluate {expression} against state */ export declare function createBindingUpdater(evaluateExpression: (expr: string, context: Record) => unknown): UpdateBindingFn; export {};