import { type MaybeCleanup, type MaybePromise, type Memo, type Signal, type SingleMatchHandlers, type SlotDescriptor } from '@zeix/cause-effect'; import type { ComponentProps, EffectDescriptor, FactoryResult, Falsy } from '../types'; /** * A reactive value that drives a DOM update or a slot injection. * * Three forms are accepted: * - `keyof P` — a string property name on the host; reads `host[name]` and * registers it as a signal dependency automatically. * - `Signal` — any signal; `.get()` is called inside the reactive effect. * - `() => T | Promise | null | undefined` — a thunk wrapped in `createComputed`; * all signals read inside are tracked in the pure phase. Returning `null` or * `undefined` drives the `nil` path; an async thunk becomes a `Task` signal. */ type Reactive = keyof P | Signal | (() => T | Promise | null | undefined); /** * A map of child component property names to the reactive values to inject into them. * Passed as the second argument to `pass()`. Keys must be property names of the target component `Q`. */ type PassedProps

= { [K in keyof Q & string]?: Reactive | SlotDescriptor; }; /** * The `watch` helper type in `FactoryContext`. * * Drives a reactive effect from a signal source (property name, Signal, thunk, * or array). Only the declared sources trigger re-runs — incidental reads inside * the handler are not tracked. Returns an `EffectDescriptor`. * * Thunk form `() => T` is wrapped in `createComputed`, so all signals read inside * it are tracked in the pure phase — useful for deriving or transforming values * before the side-effectful handler runs. */ type WatchHelper

= { (source: K, handler: (value: P[K]) => MaybePromise): EffectDescriptor; (source: K, handlers: SingleMatchHandlers): EffectDescriptor; (source: Signal, handler: (value: T) => MaybePromise): EffectDescriptor; (source: Signal, handlers: SingleMatchHandlers): EffectDescriptor; (source: () => T | Promise | null | undefined, handler: (value: T) => MaybePromise): EffectDescriptor; (source: () => T | Promise | null | undefined, handlers: SingleMatchHandlers): EffectDescriptor; (source: Array, P>>, handler: (values: any[]) => MaybePromise): EffectDescriptor; }; /** * The `pass` helper type in `FactoryContext`. * * Passes reactive values to a descendant Le Truc component's Slot-backed signals. * Supports single-element and Memo targets (per-element lifecycle for Memo). */ type PassHelper

= { (target: (HTMLElement & Q) | Falsy, props: PassedProps): EffectDescriptor; (target: Memo<(HTMLElement & Q)[]> | Falsy, props: PassedProps): EffectDescriptor; }; /** * Recursively activate a `FactoryResult` array of effect descriptors. * * Nested arrays are flattened; falsy values are skipped. Each truthy descriptor * is called immediately so its reactive effects register in the current scope. * * @since 2.0 * @param {FactoryResult} result - Flat or nested array of effect descriptors to activate */ declare const activateResult: (result: FactoryResult) => void; /** * Create a `watch` helper bound to a specific component host. * * `watch` wraps `match` to create a reactive effect driven by explicitly declared * signal sources. Only the declared source signals trigger re-runs — other reads * inside the handler are not tracked. Returns an `EffectDescriptor`. * * @since 2.0 * @param {HTMLElement & P} host - The component host element * @returns {WatchHelper

} Bound `watch` function for the given host */ declare const makeWatch:

(host: HTMLElement & P) => WatchHelper

; /** * Create a `pass` helper bound to a specific component host. * * `pass` passes reactive values to a descendant Le Truc component by swapping * its Slot-backed signals. The original signals are restored when the component * disconnects. Supports both single-element and `Memo` targets. * * For Memo targets, uses per-element lifecycle: signals are swapped when elements * enter the collection and restored when they leave. * * @since 2.0 * @param {HTMLElement & P} host - The component host element * @returns {PassHelper

} Bound `pass` function for the given host */ declare const makePass:

(host: HTMLElement & P) => PassHelper

; /** * Create per-element reactive effects from a `Memo`. * * When elements enter the collection, their effects are created in a per-element * scope; when they leave, their effects are disposed with that scope. * * The callback receives a single element and returns a `FactoryResult` (array of * `EffectDescriptor`s) or a single `EffectDescriptor` (single-descriptor shortcut). * Falsy values can also be returned to skip conditionally. * * @since 2.0 */ declare function each(memo: Memo, callback: (element: E) => FactoryResult | EffectDescriptor | Falsy): EffectDescriptor; export { activateResult, type EffectDescriptor, each, type FactoryResult, type Falsy, makePass, makeWatch, type PassedProps, type PassHelper, type Reactive, type WatchHelper, };