import type { TerminalFrameContext, TerminalFrameTaskPriority, TerminalScheduler } from "../context.js"; import type { FramePerfReason } from "../../observability/frame-perf.js"; export type FrameMailboxApply = (value: T, ctx: TerminalFrameContext, meta: { queued: number; dropped: number; }) => void; export type FrameMailboxOptions = Readonly<{ scheduler: TerminalScheduler; id: string | (() => string); reason?: FramePerfReason; priority?: TerminalFrameTaskPriority; sync?: boolean; merge?: (prev: T, next: T) => T; apply: FrameMailboxApply; }>; /** * Coalesces many producer updates into a single scheduler frame task. * * This helper is currently internal to vue-tui. It is used by library * components and internal tests, but it is not exported from the package root. * * Default behavior keeps only the latest queued value. If `merge` is provided, * the pending value is updated with `merge(prev, next)`. * * Only the first queue() call in a pending cycle schedules a frame task. * Later queue() calls update the pending payload and are reported as dropped * producer updates when the frame task runs. * * droppedUpdates are reported after apply() succeeds. They only appear in * framePerf when apply() also invalidates and produces a rendered frame sample. * If apply() throws, scheduler error stats include mailbox queued/dropped * metadata for the failed delivery attempt. The pending payload has already * been cleared; mailbox delivery is fail-fast and does not retry stale payloads * on later frames. * * cancel() is best-effort at scheduler level. The run callback still guards * `disposed || !hasPending`, because a scheduler may already have taken a * snapshot of tasks for the current frame. * * queue() returns false only when the scheduler explicitly rejects the task. * Legacy void-returning schedulers are treated as accepted for compatibility. * Owners should call dispose() before the component/scope that owns the * mailbox is destroyed. * * id is scheduler-global. Components should include instance id and producer * name, for example `TList:${uid}:wheel`. */ export declare function createFrameMailbox(options: FrameMailboxOptions): { readonly queue: (value: T) => boolean; readonly replacePending: (value: T) => boolean; readonly cancel: () => void; readonly dispose: () => void; readonly hasPending: () => boolean; readonly peek: () => T | undefined; };