import { default as EventEmitter } from 'eventemitter3'; import { Filter } from '../../../types/index.js'; import * as React from "react"; /** * Cache entry stored per `(event, channelHash)`. The original channel * object is preserved so mount replay can re-emit with the exact * channel the producer used — otherwise late-mounting subscribers * could not satisfy filtered-channel matching. */ type Entry = { readonly channel: Filter | undefined; readonly value: unknown; }; /** * EventEmitter subclass that caches the latest payload per `(event, * channel)` pair. When a broadcast or multicast action is dispatched, * the payload is stored so that late-mounting components can replay it * via {@link useLifecycles} and handlers can read it via * `context.actions.final()`. Cache entries are keyed by both the * action and the channel object — multi-channel actions retain * one entry per channel rather than overwriting on every dispatch. */ export declare class BroadcastEmitter extends EventEmitter { private cache; private latest; emit(event: string | symbol, ...args: unknown[]): boolean; /** * Cache a value for a given event/channel pair without emitting to * listeners. Used by {@link emitAsync} to preserve caching when * bypassing `emit()`. */ setCache(event: string | symbol, value: unknown, channel: Filter | undefined): void; /** * Retrieve the most recently cached payload across every channel for * a given event. Returns `undefined` if no value has ever been * dispatched. Use {@link getCachedAll} when channel-specific replay * is required — this overload exists for `context.actions * .final()`, which resolves to the most recent broadcast regardless * of channel. */ getCached(event: string | symbol): unknown; /** * Iterate every cached `(channel, value)` pair for a given event. * Mount replay walks this to re-emit per-channel values so that * late-mounting subscribers see the same broadcasts they would have * received had they been mounted at dispatch time. */ getCachedAll(event: string | symbol): Iterable; /** * Emit without caching the payload. Used by the framework to publish * fire-and-forget events (such as `Lifecycle.Fault`) where late-mounting * subscribers must not replay a stale value. */ fire(event: string | symbol, ...args: unknown[]): boolean; } /** * React context for broadcasting distributed actions across components. */ export declare const Context: React.Context; /** * Hook to access the broadcast EventEmitter for emitting and listening to distributed actions. * * @returns The BroadcastEmitter instance for distributed actions. */ export declare function useBroadcast(): BroadcastEmitter; export {};