/** * Fine-grained reactivity system using Proxies. * * @remarks * Each directive becomes its own effect, tracking only the state it accesses. * Changes trigger only the affected effects - no component re-renders, no diffing. * * @packageDocumentation */ type Effect = () => void; /** * A scope that groups effects for collective disposal. * * @remarks * Used for cleanup when elements are removed or re-rendered. * All effects created within a scope can be stopped at once. */ export interface EffectScope { /** * Run a function within this scope. * Any effects created will be tracked by this scope. */ run(fn: () => T): T; /** * Stop all effects in this scope. */ stop(): void; /** * Whether the scope has been stopped. */ active: boolean; } export declare function createEffectScope(): EffectScope; /** * Make an object deeply reactive. * * @remarks * Property access is tracked when inside an effect. Mutations trigger * all effects that depend on the changed property. * * @typeParam T - Object type * @param target - The object to make reactive * @returns A reactive proxy of the object * * @example * ```ts * const state = reactive({ count: 0 }); * effect(() => console.log(state.count)); * state.count = 1; // logs: 1 * ``` */ export declare function reactive(target: T): T; /** * Create a reactive effect. * * @remarks * The function runs immediately, tracking dependencies. * It re-runs automatically whenever those dependencies change. * * @param fn - The effect function to run * @returns A cleanup function to stop the effect * * @example * ```ts * const state = reactive({ count: 0 }); * const stop = effect(() => { * console.log('Count:', state.count); * }); * state.count = 1; // logs: Count: 1 * stop(); // effect no longer runs * ``` */ export declare function effect(fn: Effect): () => void; /** * Create a child reactive scope. * * @remarks * Used by structural directives like g-for to create per-item contexts. * The child scope inherits from the parent, with additions taking precedence. * * @typeParam T - Parent object type * @param parent - The parent reactive object * @param additions - Additional properties for this scope * @returns A new reactive scope that inherits from parent * * @example * ```ts * const parent = reactive({ items: [1, 2, 3] }); * const child = createScope(parent, { item: 1, index: 0 }); * child.item; // 1 * child.items; // [1, 2, 3] (from parent) * ``` */ export declare function createScope(parent: T, additions: Record): T & Record; export {};