/** * vapor-chamber - Transition integration * * `VaporTransition` merges its declared `on*` props across sources, so * `` runs both hooks * (tests/transition-bind-merge-fixture.test.ts). The hooks are idempotent by * construction (see `buildHooks`); onMove's behaviour notes are on its JSDoc. * The history is in CHANGELOG.md and the whitepaper's appendix B. * * Two entry points: * createTransitionBridge - framework-agnostic factory (accepts BaseBus) * useTransitionCommand - Vue composable (uses shared bus + auto-cleanup) * * @example * // Factory (any JS context): * const t = createTransitionBridge({ bus, namespace: 'modal' }); * // t.onEnter dispatches 'modalEnter', t.onLeave dispatches 'modalLeave', etc. * * @example * // Vue composable: * const t = useTransitionCommand({ namespace: 'drawer' }); * // - the eight enter and leave hooks wired automatically */ import type { BaseBus } from './command-bus'; import type { Signal } from './chamber'; export type TransitionPhase = 'idle' | 'entering' | 'leaving'; export type TransitionBridgeOptions = { /** Namespace prefix for dispatched actions (e.g. 'modal' -> 'modalEnter'). */ namespace?: string; /** Bus to dispatch on. Required for createTransitionBridge. */ bus?: BaseBus; /** * Milliseconds to wait for an async `*Enter` / `*Leave` handler before * calling `done()` anyway. Default: 30_000, the same cap `directives.ts` * applies to its own dispatches. * * Vue waits for `done()` indefinitely, so a handler that never settles * leaves the element stuck mid-transition for the life of the page - see the * note in `dispatchWithDone`. Clamped to between 1ms and `MAX_TIMEOUT_MS`. */ timeout?: number; }; export type TransitionHooks = { onBeforeEnter: (el: Element) => void; onEnter: (el: Element, done: () => void) => void; onAfterEnter: (el: Element) => void; onEnterCancelled: (el: Element) => void; onBeforeLeave: (el: Element) => void; /** * Dispatches `Leave` and awaits an async handler before `done()`. * * Fires when a **non-v-show root is structurally removed after a v-show * branch was shown** too (Vue gates its `persisted` carry-forward on an * actual v-show marker, beta.16). */ onLeave: (el: Element, done: () => void) => void; onAfterLeave: (el: Element) => void; onLeaveCancelled: (el: Element) => void; /** * Dispatches `Move` with `el` as the target. Vue never calls it: * no Vue component has a move hook, on either renderer * (tests/vue-no-move-hook.test.ts). Call it yourself, for example from your * own FLIP code after a reorder. No `done()` callback. * * It is kept out of a spread (see `assembleBridge`): Vue declares no * `onMove` prop, so `v-bind="t"` would pass it on to the child as a `move` * DOM listener that nothing fires, and Vue warns on a fragment child. */ onMove: (el: Element) => void; }; export type TransitionBridge = TransitionHooks & { /** Reactive signal: current transition phase. */ phase: Signal; /** Cleanup function (no-op for bridge, meaningful for composable). */ dispose: () => void; }; /** * createTransitionBridge - wire Vue transition hooks to bus commands. * * Framework-agnostic: accepts any BaseBus (sync or async). Use this in * non-Vue contexts or when you need explicit lifecycle control. * * @example * const bus = createCommandBus(); * bus.register('modalEnter', (cmd) => { * cmd.target.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 300 }); * }); * * const t = createTransitionBridge({ bus, namespace: 'modal' }); * // Pass t.onEnter, t.onLeave, etc. to or call them manually * * On a vDOM app, `` with this bridge needs an ASYNC * bus. On a sync bus the bridge calls `done()` at once, so the leave finishes * synchronously, and Vue's vDOM `out-in` then throws and renders nothing * (tests/transition-done-timing-fixture.test.ts). That is Vue's defect, * reported as vuejs/core#15727, a fix proposed in vuejs/core#11824. Vapor's * `` and the default mode are not affected (same test). */ export declare function createTransitionBridge(options: TransitionBridgeOptions & { bus: BaseBus; }): TransitionBridge; /** * useTransitionCommand - Vue composable that wires transition hooks to the * shared command bus with reactive phase signal and auto-cleanup. * * Bind directly to `` via `v-bind`: * * @example * * * * * Your own hooks compose with the spread: `` runs both, in Vapor from Vue 3.6.0-rc.8 and in vDOM always. * Vue still waits for `done` when any merged handler takes two arguments, and * the bridge's `onEnter` / `onLeave` do. */ export declare function useTransitionCommand(options?: TransitionBridgeOptions): TransitionBridge; //# sourceMappingURL=transitions.d.ts.map