import type { Key } from "../functional/key"; import type { Maybe } from "../functional/maybe"; import type { Use } from "./state"; import type { $primitive } from "./primitive"; export type RefCallback = (value: T | null) => void; export type RefObject = { current: T | null; }; export type Ref = RefCallback | RefObject; /** Apply a value (or null) to either ref shape. Engine + renderer share this. */ export declare function applyRef(ref: Maybe>, value: T | null): void; export type ViewBody = { render: () => void; onMount?: () => void; shouldUpdate?: (nextProps: Props) => boolean; onUpdateBefore?: () => void; onUpdateAfter?: () => void; dispose?: () => void; }; /** Slot callback — passed by the caller at the call site. */ export type Slot = () => void; /** What callers may pass as a slot: a callback or a plain string (rendered as text). */ export type SlotContent = Slot | string; /** * Setter handed to the viewFn for publishing an api into the consumer's `ref`. * Typically called once during the body. Subsequent calls overwrite. */ export type RefSetter = (value: Api) => void; export type ViewFn = { (ctx: { props: () => Props; use: Use; slot: Slot; ref: RefSetter; }): ViewBody; [$primitive]?: string; }; /** * Caller-facing props type. Allows `void` when Props is void or all-optional. * `ref` is added alongside `key`; its element type is whatever the view * publishes via `ctx.ref(...)`. */ type ViewProps = Props extends void ? { key?: Key; ref?: Ref; } | void : {} extends Props ? (Props & { key?: Key; ref?: Ref; }) | void : Props & { key?: Key; ref?: Ref; }; export declare function view(body: ViewFn): (props: ViewProps, slot?: SlotContent) => void; export type PublicView = ReturnType>; export {};