/** * vapor-chamber - Vue Vapor integration * * v1.3.0 — Vue 3.6.0-beta.12 alignment: error recovery (component context, * fallthrough props, render effects restored after setup errors); * VDOM slots interop normalization; no code changes needed here. * v1.1.0 — Vue 3.6.0-beta.10 alignment: defineVaporCustomElement, defineVaporComponent, * defineVaporAsyncComponent detection; improved hydration interop. * v0.4.1 — Added: useCommandGroup (namespace isolation), useCommandError (error boundary). * v0.4.0 — Vue 3.6 Vapor alignment: onScopeDispose, Vapor detection, * defineVaporCommand, createVaporChamberApp. * v0.3.0 — Fixed: signal shim, resetCommandBus, auto-cleanup on Vue unmount. */ import { type CommandBus, type AsyncCommandBus, type Command, type CommandResult, type CommandMap, type TargetOf, type PayloadOf, type ResultOf, type Handler, type Plugin, type RegisterOptions, type Listener } from './command-bus'; import { configureSignal, signal } from './signal'; import type { Signal } from './signal'; export type { Signal, CreateSignal } from './signal'; export { configureSignal }; export { signal }; /** * Wait for Vue detection to complete. Call this in app setup if you need * to guarantee Vue APIs are available before the first signal() call. * * @example * import { waitForVueDetection, signal } from 'vapor-chamber'; * await waitForVueDetection(); * const count = signal(0); // guaranteed to use Vue ref() if available */ export declare function waitForVueDetection(): Promise; /** * Returns true if Vue 3.6+ with Vapor mode support is detected. */ export declare function isVaporAvailable(): boolean; /** @internal — for chamber-vapor.ts use only */ export declare function getVaporAppFn(): any; /** @internal — for chamber-vapor.ts use only */ export declare function getVaporInteropRef(): any; /** @internal — for chamber-vapor.ts use only */ export declare function getDefineVaporCustomElementFn(): any; /** @internal — for chamber-vapor.ts use only */ export declare function getDefineVaporComponentFn(): any; /** @internal — for chamber-vapor.ts use only */ export declare function getDefineVaporAsyncComponentFn(): any; /** @internal — Vue's DEEP ref(), for the vapor-chamber/reactive companion only. * Returns null until Vue detection completes (or if Vue is absent). */ export declare function getVueDeepRefFn(): ((v: T) => { value: T; }) | null; /** * GlobalCommands — module-augmentation hook that types the SHARED bus * (pinia-style). Augment it once in your app and every `useCommand()` / * `getCommandBus()` call site gets typed dispatch/register with autocomplete * and compile errors: * * @example * declare module 'vapor-chamber' { * interface GlobalCommands { * cartAdd: { target: Product; payload: { qty: number }; result: Cart }; * cartClear: { target: null; result: Cart }; * } * } * * Unaugmented, everything stays exactly as loose as before (string actions, * `any` targets). Schema users: derive the entries with `CommandsOf` from * './schema' instead of writing them by hand. */ export interface GlobalCommands { } /** * The CommandMap the shared bus is typed with: `GlobalCommands` when augmented, * the loose default `CommandMap` otherwise. Wrapped in a mapped type because * interfaces have no implicit index signature and would fail the CommandMap * constraint. */ export type SharedCommandMap = [keyof GlobalCommands] extends [never] ? CommandMap : { [K in keyof GlobalCommands]: GlobalCommands[K]; }; /** * Get the shared bus. Typed with {@link SharedCommandMap} — augment * {@link GlobalCommands} to make every call site typed. Pass an explicit map * to override per call site (`getCommandBus()` opts back out). */ export declare function getCommandBus(): CommandBus; /** * Replace the shared bus instance. * * SSR WARNING: the shared bus is a module global — one per Node process, not * per request. The set-render-reset pattern (see ssr.ts) is only safe when * requests render strictly one at a time. Under CONCURRENT SSR renders, * interleaved requests stomp each other's bus: handlers and state leak across * requests. For concurrent servers, don't use the shared bus on the server — * create a bus per request and pass it explicitly (every composable and plugin * accepts a `bus` option / argument). * * Accepts either bus flavor — the composables' dispatch path already handles * thenable results (`runDispatch` awaits them), so an AsyncCommandBus works at * runtime; previously callers had to cast. `getCommandBus()`'s static type * stays `CommandBus` for compatibility. */ export declare function setCommandBus(bus: CommandBus | AsyncCommandBus): void; /** * Reset the shared bus to null. Useful in test teardown to prevent * handler/hook leaks between test files. */ export declare function resetCommandBus(): void; /** * Try to register a cleanup function on the nearest Vue scope/component. * * Uses `getCurrentScope()` (Vue 3.2+) to check whether a reactive scope is * active before calling `onScopeDispose`. This replaces the earlier try/catch * pattern — no exception-as-control-flow, no `onUnmounted` fallback needed. * * In Vue 3.5+ (the minimum peer dep), every component `setup()` — including * Vapor components — is wrapped in an effect scope, so `getCurrentScope()` * inside setup always returns something. The `onUnmounted` fallback is * unreachable under Vue 3.5+ and has been removed. * * Vue 3.6.0-beta.13 (runtime-vapor: only create lifecycle update jobs when * needed): lifecycle update jobs are now created lazily — only when a component * actually has reactive state that can trigger updates. Registering * `onScopeDispose` via this function no longer causes a lifecycle update job * to be allocated for every vapor-chamber composable call. Components that use * vapor-chamber composables solely for dispatch (no reactive signals consumed * in the template) incur zero update-job overhead. * * No-ops entirely when called outside any Vue scope (e.g. module init time, * plain async callbacks). Caller is responsible for calling `dispose()` in * those cases. */ export declare function tryAutoCleanup(disposeFn: () => void): void; /** * Register KeepAlive lifecycle hooks to pause/resume bus subscriptions. * * When a component is deactivated by KeepAlive, `onPause` is called. * When reactivated, `onResume` is called. No-ops if not inside a * KeepAlive-wrapped component or if Vue is not available. * * `getCurrentInstance()` is the correct guard: `onActivated`/`onDeactivated` * throw when called outside a component setup context, so the upfront check * replaces the earlier two try/catch blocks. * * @internal — used by composables that manage bus subscriptions. */ export declare function tryKeepAliveHooks(onPause: () => void, onResume: () => void): void; /** @internal */ export declare function runDispatch(busCall: () => any, loading: Signal, lastError: Signal, onSuccess?: (value: any) => void): CommandResult | Promise; /** * useCommand — reactive command dispatch with optional bus subscriptions. * * Returns `dispatch` + reactive `loading` / `lastError`, plus `register` / `on` / * `emit` for managing handlers and listeners with auto-cleanup on scope disposal * (`onScopeDispose`). Vapor-safe — works in `