import { type BuildCtx, type SignalDoc } from './build-context.js'; import type { SignalScope } from './runtime.js'; import type { Renderable } from './element.js'; import type { TransitionOptions } from '../types.js'; /** Placement + teardown policy for an {@link ArmController}. The controller reads * `parent()`/`insertBefore()` fresh on every mount (anchors move as siblings come * and go) and calls `clear()` to remove a swapped-out arm's region. */ export interface ArmPlacement { doc: SignalDoc; /** The enclosing build's ctx — arms build as nested builds inheriting it. */ buildCtx: BuildCtx; /** The context map SNAPSHOTTED at this primitive's placement/build time. Arms * build lazily (on every switch), long after `provide`'s synchronous `render()` * restored the parent map, so the live `buildCtx.contexts` no longer carries a * value provided above this primitive. Threading the snapshot keeps `useContext` * inside an arm resolving to the provided value. */ contexts: ReadonlyMap; /** The owner scope: mounted arms are added/removed as its children. */ ownerHost: { scope: SignalScope | null; }; /** Inside an `each` row: rebase arm VALUE specs to read `ctx.state`. */ inRow: boolean; /** The parent element the arm nodes insert into, or null when detached (the * controller then no-ops the swap — the reconcile ran off-DOM). */ parent(): Node | null; /** The node to insert arm nodes before (an end anchor, or `anchor.nextSibling`); * null appends at the end of `parent()`. Read fresh per mount. */ insertBefore(): Node | null; /** Remove the swapped-out arm's DOM region. Receives the arm's own nodes; a * bracketed primitive ignores them and clears between its anchors instead (which * also sweeps nested-structural content). */ clear(nodes: readonly Node[]): void; /** Optional element-level enter/leave hooks (see {@link TransitionOptions}). When * `leave` is provided the controller DEFERS node detachment + scope teardown of a * swapped-out arm until the returned promise resolves; `enter` runs post-mount on * a freshly-inserted arm. Absent (the default) ⇒ synchronous swap, byte-identical * to the pre-transition behavior. Never invoked under {@link ssr}. */ transition?: TransitionOptions; /** True during a server render — transitions never run (no live DOM / no frames). * The controller then always takes the synchronous path. */ ssr?: boolean; /** Snapshot the exact DOM footprint of the arm to detach LATER, when its `leave` * animation resolves. Captured at teardown time — BEFORE any replacement arm is * inserted — so it names only the leaving arm's nodes (its own PLUS any nested * structural content between the anchors), never the incoming arm's. Required * (with {@link detach}) for the deferred-leave path; when absent the controller * falls back to the synchronous {@link clear}. */ collectRegion?(nodes: readonly Node[]): readonly Node[]; /** Detach a set previously captured by {@link collectRegion}. */ detach?(nodes: readonly Node[]): void; } /** * Holds at most one mounted arm keyed by `K`. `switchTo` swaps to the arm for a new * key (or unmounts when `armFn` is undefined / a same-key call short-circuits); * `dispose` tears the current arm down. Behavior matches the former inline * show/branch reconcile + host-dispose teardown exactly. */ export declare class ArmController { private readonly place; private mounted; private pendingLeaves; constructor(place: ArmPlacement); /** Is an arm currently mounted? (Test/introspection aid.) */ get isMounted(): boolean; /** The currently-mounted arm's key, or null when none is mounted. */ get currentKey(): K | null; /** * Reconcile to the arm for `key`. No-op when detached (no parent). A same-key * call short-circuits (the mounted arm's own scope handles its updates). Otherwise * the current arm (if any) is torn down and — when `armFn` is provided — the new * arm is built, inserted, mounted against `mountState`, registered as a child of * the owner scope, and its onMount callbacks run. `armFn` undefined mounts nothing * (the falsy `show` with no `orElse`, or an absent `branch` arm). */ switchTo(key: K, armFn: (() => Renderable) | undefined, mountState: unknown): void; /** Tear down the currently-mounted arm, if any (host dispose). Idempotent. * Finalizes synchronously — a `leave` animation must never hold DOM/scopes past * the owning component's unmount. */ dispose(): void; /** Tear down the currently-mounted arm. With `immediate` false and a `leave` hook * present, DEFERS node detachment + scope teardown until `leave` resolves (the arm * animates out while a replacement may already be mounting); otherwise removes * synchronously — the byte-identical pre-transition path. */ private teardown; /** Detach a pending-leave arm and run its teardowns exactly once. */ private finalizeLeave; /** Finalize every in-flight leave synchronously (interruption / dispose). */ private finalizePendingLeaves; } //# sourceMappingURL=arm-controller.d.ts.map