/** * One Step of an element's initialization. `start` runs as the element initializes, in the order the Steps are listed; * one that returns a promise holds the init until the promise settles. `stop`, when there is one, undoes `start`: the * Steps that started are stopped in reverse order when the element is torn down or its init is abandoned. A Step whose * `start` throws, or whose promise rejects, is stopped too, so `stop` must undo a `start` that only got part of the way. */ export interface Step { start: (host: H) => void | Promise; stop?: (host: H) => void; } export interface LifecycleOptions { /** The Steps an init starts, in order, before the element is Initialized. */ steps: ReadonlyArray>; /** Called once the element is Initialized. */ connected: (host: H) => void; /** Called as a teardown begins, once the element is no longer Initialized and before any Step is stopped. */ disconnected: (host: H) => void; /** * Whether the elements a custom element class defines run this lifecycle, so `whenInitialized` waits for one to * initialize rather than only for its class to be defined. */ isHost: (ctor: CustomElementConstructor) => boolean; } export interface Lifecycle { /** Reports that `host` was connected, as `connectedCallback` does. */ connect: (host: H) => void; /** Reports that `host` was disconnected, as `disconnectedCallback` does. */ disconnect: (host: H) => void; /** * Whether an attribute change on `host` is reported: from the moment it is Initialized until its teardown has * returned, so a `disconnected()` that sets a property is still told about it. */ reportsChanges: (host: H) => boolean; /** Whether `element` is a host that is Initialized right now. */ isInitialized: (element: Element) => boolean; /** * Resolves with `element` once it is ready: a host once it is Initialized, any other custom element once its class is * defined, and a standard element at once. Rejects after `timeout` milliseconds, if given. */ whenInitialized: (element: T, options?: { timeout?: number; }) => Promise; } /** * Builds the lifecycle that hosts run: an init that starts `steps` in order and then calls `connected`, and a teardown * that calls `disconnected` and then stops the Steps in reverse. * * Each host's Phase is kept here rather than on the host. The `data-impulse-element` attribute marks an Initialized * host for stylesheets, tests and anything else reading the DOM, but it is a consequence of initializing rather than the * record of it: an attribute can be copied by `cloneNode` or written into server-rendered HTML, neither of which starts * an element. */ export declare function createLifecycle({ steps, connected, disconnected, isHost, }: LifecycleOptions): Lifecycle; //# sourceMappingURL=lifecycle.d.ts.map