/** * vapor-chamber - the command binding: a control that dispatches a command, * with no Vue in it. * * One interaction, two ways to attach it. The Vue and Vapor directives * (`v-vc-command`, src/directives.ts) mount it per element; `bindCommands` * mounts it on every `[data-vc-command]` of plain HTML, the bus passed in. * The rules are the directive's (busy, error, announce, optimistic, the * keyboard, the in-flight guard), written once here. This module imports * nothing of chamber.ts, so a page's bundle carries no Vue probe. */ import { type Delay } from './bounds'; import type { BaseBus, Command, CommandResult } from './command-bus'; import { type Paced } from './pace'; /** * @internal The failure of a dispatch that did not settle within the * directive's timeout: `directive:timeout:dispatch`, a transient condition. * A function of its own so a test can read the code (the element's state is * private); tests/errors-match-catalogue.test.ts. */ export declare function _timedOut(action: string, timeout: number): CommandResult; type DirectiveState = { action: string; /** The bus, read at press time: the shared one for the Vue directives, the given one for `bindCommands`. */ busOf: () => BaseBus; /** What the element listens to: `click`, or `input` / `change` on a form control (`v-model`'s choice). */ event: 'click' | 'input' | 'change'; /** The sender's pace from `data-vc-debounce` / `data-vc-throttle`, or null. */ pace: Paced | null; /** The latest send: only its settle clears `vc-loading` on a form control, whose sends overlap. */ seq: number; /** Inside an IME composition (`v-model`'s rule): a text control sends at its end, not before. */ composing: boolean; /** The composition listeners on a text control, kept for teardown. */ ime?: { start: () => void; end: (event: Event) => void; }; /** Vapor only: the binding's getter, read at dispatch time - see vcCommandVapor. */ actionOf?: () => unknown; payload?: any; optimisticFn?: (cmd: Command) => (() => void) | null; /** Vapor only: the `v-vc-payload` binding's getter, read at dispatch time. * Vapor has no `updated` hook, so the same rule `actionOf` follows applies - * read the getter when the click happens and a changed binding re-targets * the next dispatch without the directive re-running. */ payloadOf?: () => unknown; /** Vapor only: the `v-vc-optimistic` binding's getter, read at dispatch. */ optimisticOf?: () => unknown; loading: boolean; error: Error | null; handler: (event: Event) => void; /** Keyboard activation added to a non-native `role="button"` element; see wireKeyboard. */ keys?: { down: (event: KeyboardEvent) => void; up: (event: KeyboardEvent) => void; }; /** The directive made the element focusable, so teardown takes it back. */ addedTabindex?: boolean; /** Timeout in ms for async dispatch. Default: 30_000 */ timeout: Delay; /** `.stop` - call event.stopPropagation() before dispatch. */ stop?: boolean; /** `.prevent` - call event.preventDefault() before dispatch. */ prevent?: boolean; /** `.self` - only dispatch when event.target is the bound element. */ self?: boolean; /** Allowed mouse buttons from `.left`/`.middle`/`.right` (0/1/2). Empty = any. */ buttons?: number[]; /** The exact options object `addEventListener` was called with, kept so * `removeEventListener` is handed THE SAME ONE: two shapes built apart * drift the moment one side gains an option, and removal then silently * stops matching and the listener stays attached. */ listenerOpts?: AddEventListenerOptions; /** `.delegate` - dispatched via the shared document-level listener instead of * a direct one on this element. See "Opt-in delegation" below. */ delegate?: boolean; /** The document this element's delegated listener was counted against. * Recorded at mount so teardown decrements the RIGHT document - an element * can be moved between documents, and `ownerDocument` at unmount time is * not necessarily the one it registered with. */ delegatedDoc?: Document; }; /** The element's command state; directives.ts reads it for the Vapor slots. */ export declare const _stateMap: WeakMap; /** * Payload / optimistic bindings that ran BEFORE `v-vc-command` on the same * element, held until the command mounts and claims them. BOTH RENDERERS. * * WHY IT EXISTS, and it is not defensive programming. A compiled template * applies an element's directives in SOURCE ORDER, and `mountCommand()` opens * by calling `unmountCommand()`, which DELETES whatever state the element * carries. So without this slot, * * * * */ export declare function bindCommands(root: Element | Document, options: { bus: BaseBus; }): () => void; export {}; //# sourceMappingURL=command-binding.d.ts.map