/** * What is running right now that could have scheduled an update: the answer * the lifecycle layer's `requestUpdate` wrapper records as a tick's cause. * * Three kinds of context, and the innermost wins: an event being dispatched * (an input event the browser raised, marked by the mouse and keyboard * layers' capture listeners, or a custom event a component dispatched, marked * by the custom events layer), the element inside `performUpdate`, whose * render set a property on, or created, the requester, and a DevTools * command running ({@link withDevtoolsCause}). * * An event is "in flight" while its `eventPhase` is not `NONE`, which the DOM * flips for exactly the duration of its dispatch. That is what makes marked * events usable without a matching "dispatch ended" hook. `window.event` is * not an option: the DOM leaves it unset for listeners inside a shadow tree, * which is where every Lit component's handlers live. * * Only consulted while recording; nothing here may throw into the app. */ import type { TimelineCause } from '../../../types/timeline.js'; /** A recorded event row: the layer it is on and its `time`. */ export interface EventCause { layerId: string; time: number; /** The row's title, so same-`time` rows (mouseup and click) stay apart. */ title?: string; } /** A context that may be the cause, with when it began. */ export interface SequencedCause { cause: TimelineCause; /** From {@link nextCauseSeq}; the higher sequence is the inner context. */ seq: number; } /** A fresh sequence number; contexts compare these to find the innermost. */ export declare const nextCauseSeq: () => number; /** * Remember that `event` was recorded as `cause`, for the handlers it is about * to run. Call before the dispatch (or from a capture listener that runs * ahead of the app's). */ export declare const markEventCause: (event: Event, cause: EventCause) => void; /** Point `currentCause` at the lifecycle layer's notion of "updating now". */ export declare const setUpdateCauseSource: (source: () => SequencedCause | undefined) => void; /** * Run `fn`, the DevTools command `command`, so the updates it schedules * carry a `devtools` cause naming it. */ export declare const withDevtoolsCause: (command: string, fn: () => T) => T; /** The cause an update scheduled at this moment should carry, if any. */ export declare const currentCause: () => TimelineCause | undefined; //# sourceMappingURL=cause-context.d.ts.map