/** * What a `@target()` field's rule needs from the `Target` that owns it. A `Target` passes itself, so its fields share * one host rather than each holding closures of its own. */ export interface SingleTargetHost { /** Whether `element` claims the field `key` as the DOM stands, whatever has been delivered. */ claims: (key: string, element: T) => boolean; /** Every element claiming the field `key` as the DOM stands, in document order. */ claimants: (key: string) => T[]; /** Invokes `[key]Connected` with `element`. */ connected: (key: string, element: T) => void; /** Invokes `[key]Disconnected` with `element`. */ disconnected: (key: string, element: T) => void; /** Reports that the field `key` was left with a second Claimant: a mistake that `@targets()` is for. */ reportMultiple: (key: string) => void; /** Whether the Owner is subscribed. It is not while it is torn down, when nothing waiting is to be connected. */ active: () => boolean; /** The number of the delivery running, or `0` when none is. Two calls agree only within one delivery. */ clock: () => number; /** Runs `task` once the run of deliveries now in progress is over: a microtask queued from inside it. */ afterRun: (task: () => void) => void; /** Runs `task` as a delivery of its own, as the changes it hands to callbacks are. */ deliver: (task: () => void) => void; } /** * The rule that decides which Claimant is a `@target()` field's Target, kept for one field. * * `Target` reports each element that starts claiming the field (`claim`) and each that stops (`release`) as the * changes are delivered, and the rule decides who is connected and disconnected. It also answers what the field reads * while changes wait to be delivered (`now`), the same rule asked of the DOM as it stands (docs/adr/0006). */ export interface SingleTarget { /** The Target as delivered: the element the field holds, from its `[key]Connected` until its `[key]Disconnected`. */ readonly target: T | null; /** Reports that `element` has started claiming the field. */ claim: (element: T) => void; /** Reports that `element` no longer claims the field. */ release: (element: T) => void; /** The Target the field will have once the changes waiting are delivered, worked out from the DOM. */ now: () => T | null; /** Forgets the field's history once the Owner is torn down, so removed elements are not kept alive. */ reset: () => void; } /** * Creates the rule for the `@target()` field `key` of the Owner `host` stands for. `Target` creates one per `@target()` * field, passing itself as the host. */ export declare function createSingleTarget(host: SingleTargetHost, key: string): SingleTarget; //# sourceMappingURL=single_target.d.ts.map