import { type MemoCallback, type Signal, type TaskCallback } from '@zeix/cause-effect'; import { type ProvideContextsHelper, type RequestContextHelper } from './helpers/context'; import { type ElementQueries } from './helpers/dom'; import { type OnHelper } from './helpers/events'; import { type FactoryResult, type Falsy, type PassHelper, type WatchHelper } from './helpers/reactive'; import { type ComponentProps, type MethodProducer, type Parser } from './types'; /** * Any value that `#setAccessor` can turn into a signal: * - `T` — wrapped in `createState()` * - `Signal` — used directly * - `MemoCallback` — wrapped in `createComputed()` * - `TaskCallback` — wrapped in `createTask()` */ type MaybeSignal = T | Signal | MemoCallback | TaskCallback; /** * The `props` argument of `defineComponent` — a map from property names to their initializers. * * Each value may be: * - A **static value** or **`Signal`** — used directly as the initial signal value. * - A **`Parser`** (branded with `asParser()`) — called with the attribute value string * at connect time. * - A **`MethodProducer`** (branded with `defineMethod()`) — assigned directly as the property * value; the function IS the method. Per-instance state lives in factory scope. */ type Initializers

= { [K in keyof P]?: P[K] | Signal | Parser | MethodProducer; }; /** * The context object passed to the v1.1 factory function. * * Components destructure only what they need. */ type FactoryContext

= ElementQueries & { host: HTMLElement & P; expose: (props: Initializers

) => void; watch: WatchHelper

; on: OnHelper

; pass: PassHelper

; provideContexts: ProvideContextsHelper

; requestContext: RequestContextHelper; }; /** * Define and register a reactive custom element using the v1.1 factory form. * * The factory receives a `FactoryContext` at connect time: query helpers (`first`, `all`), * the `host` element, and `expose()` for declaring reactive properties. It returns a flat * array of effect descriptors created by helpers like `watch()`, `on()`, `pass()`, * `provideContexts()`, and `requestContext()`. * * Effects activate after dependency resolution — child custom elements are guaranteed to * be defined before any descriptor runs. * * @since 2.0 * @param {string} name - Custom element name (must contain a hyphen and start with a lowercase letter) * @param {function} factory - Factory function that queries elements, calls expose(), and returns effect descriptors * @throws {InvalidComponentNameError} If the component name is not a valid custom element name */ declare function defineComponent

(name: string, factory: (context: FactoryContext

) => FactoryResult | Falsy | void): CustomElementConstructor | undefined; export { defineComponent, type FactoryContext, type Initializers, type MaybeSignal, };