/** * vapor-chamber - Directive plugin (opt-in, 0KB when not imported) * * The rules this file keeps (the history is in CHANGELOG.md and the * whitepaper's Vue 3.6 alignment log, appendix B): * - THE NAME CARRIES THE SELECTOR: `vc-command`, `vc-payload`, * `vc-optimistic`. Vue's directive argument is a parameter slot (a getter * in compiled Vapor, #15490), so nothing here reads it - see * {@link vcCommandVapor}. * - `vcCommandVapor` is the function shape `withVaporDirectives` calls, over * the same `buildHandler` as the vDOM hooks. * - Direct listeners, one per element, per Document; `.delegate` opts in to * delegation, as Vue's compiled `@click` does (#15127). * - Event modifiers are honoured (.stop/.prevent/.self/.left/.middle/.right/ * .capture/.once/.passive). * - `buildHandler()` skips dispatch on a disabled, aria-disabled or * in-flight element. Vue skips only a `disabled` node, and only in its * delegated handler (#14948). The other two are this directive's rule. * - TEARDOWN IS KEYED TO WHAT WAS MOUNTED, never to the current binding. See * the `beforeUnmount` note in the plugin below. * * Provides a Vue plugin that installs three directives for declarative command * dispatch directly in templates, combining dispatch + loading + error * handling without any * * * // or app-wide, on the typed app from 'vapor-chamber/vapor': * // createVaporChamberApp(App).directive('vc-command', vcCommandVapor) */ export declare function vcCommandVapor(el: Element, value?: () => unknown, _argument?: () => unknown, modifiers?: Record): (() => void) | undefined; /** * vcPayloadVapor - `v-vc-payload` for Vapor components. * * The Vapor port of the vDOM `vc-payload` registration, in the function shape * `withVaporDirectives` calls. Sets the payload for the `v-vc-command` on the * SAME element, and like the vDOM half it is inert on an element that has no * command. * * The binding is read at DISPATCH time rather than stored at mount, because * Vapor has no `updated` hook - so a changed payload reaches the next click * without the directive re-running, which is the same rule `vcCommandVapor` * follows for the action. A binding beats `data-vc-payload` on both renderers. * * WHY THIS EXISTS AT ALL, since `data-vc-payload` already worked on both * renderers: JSON is lossy and the binding is not. MEASURED on one payload * through both paths - a `Date` arrives as a string, a `Map` as `{}`, a class * instance as a plain object, a function is dropped and an `undefined` key * disappears. A handler that calls `cmd.payload.when.getTime()` works through * the binding and throws through the attribute. * * THE BINDING NAME IS `vVcPayload`, because Vue camelCases the whole directive * name. An import aliased to anything shorter compiles, type-checks and mounts * nothing - see the note on {@link vcCommandVapor}. * * @example * * */ export declare function vcPayloadVapor(el: Element, value?: () => unknown): () => void; /** * vcOptimisticVapor - `v-vc-optimistic` for Vapor components. * * The Vapor port of the vDOM `vc-optimistic` registration. The bound function * receives the `Command` and returns a rollback function (or null); the * rollback runs if the dispatch fails. A dispatch still running when the * timeout modifier gives up is reported as `directive:timeout:dispatch` and * the button released, and its late result decides: a failure rolls back, a * success keeps. * * Without it a Vapor template has no optimistic update with rollback: the * alternative is to abandon `v-vc-command` for that button and hand-roll the * dispatch, which forfeits `vc-loading` / `vc-error`, disable-while-busy, the * re-entrancy guard, the timeout and the modifiers - and an `@click` beside * the directive cannot do it, because since Vue 3.6.0-rc.9 `80b3a046` that * handler registers FIRST and `buildHandler`'s guards let it veto the dispatch. * * Read at dispatch time, for the same reason as the payload. * * THE BINDING NAME IS `vVcOptimistic`. * * @example * * */ export declare function vcOptimisticVapor(el: Element, value?: () => unknown): () => void; /** * createDirectivePlugin - installs v-vc-command, v-vc-payload and * v-vc-optimistic. * * Opt-in: import and use this plugin only when you need template directives. * Zero cost when not imported. In Vapor components use {@link vcCommandVapor}. * * INSTALLED ON A VAPOR APP IT DOES NOTHING, and says so in DEV. The three * registrations below are vDOM OBJECT directives; from Vue 3.6.0-rc.9 a Vapor * template skips a non-function directive with a warning of its own (#15489), * and before that it called the object and threw. Vue names the symptom * ("Received a VDOM object directive"); this names the fix. The check is one * own-property read - a Vapor app carries `vapor`, a vDOM app does not - and * the whole branch folds out of a production build. */ export declare function createDirectivePlugin(): { install(app: any): void; }; //# sourceMappingURL=directives.d.ts.map