import type { GateInterface, SubscriberInterface, BaseTransferInterface, PushableTransferInterface, PullableTransferInterface, SubscribableTransferInterface, TriggerableTransferInterface, PollingProxyTransferInterface, PollingSourceTransferInterface, GateTransferInterface, UniversalDuplexInterface, AsyncTriggerableInterface, AsyncPushableTransferInterface, AsyncPullableTransferInterface, AsyncPollingProxyTransferInterface } from "./interfaces"; import type { DataHandler, DataFetcher, AsyncDataFetcher, ErrorHandler, Transfer, AsyncPushable, Subscribable } from "./types"; import type { PollingSourceTransferConfig, BaseStateTransferConfig, DelayedPushChannelTransferConfig, DebounceTransferConfig, ThrottleTransferConfig, GateTransferConfig, MergeTransferConfig, SplitTransferConfig, SinkTransferConfig, ChannelTransferConfig, WriteTransferConfig, ReadTransferConfig, ConvertTransferConfig, StoredChannelTransferConfig, PollingProxyTransferConfig, ConditionTransferConfig, PollingFlowTransferConfig, IdlePollingTransferConfig, DisplaceTransferConfig, CompositeTransferConfig, AsyncSinkTransferConfig, AsyncWriteTransferConfig, AsyncReadTransferConfig, AsyncPollingSourceTransferConfig, AsyncPollingProxyTransferConfig, AsyncPollingFlowTransferConfig, AsyncIdlePollingTransferConfig, AsyncConvertTransferConfig, AsyncConditionTransferConfig, AsyncStoredChannelTransferConfig } from "./configs"; import { ProxyReference } from "./helpers"; /** * Base abstract class for all transfers. * Implements CommunicationContractInterface via boolean capability flags. * * Flags determine which methods and interfaces a specific transfer implements: * - isInput / isOutput — flow direction (input/output/duplex) * - isPushable / isPullable / isSubscribable — data delivery mechanics * - isTriggerable — presence of a manual trigger * - isGate — presence of state management (activate/deactivate) * - isPollingSource — presence of an external poller (polling) * - isPollingProxy — ability to poll another transfer (polling) * - isDuplex (computed) — true if isInput && isOutput * * All flags default to false. Subclasses override the needed ones to true. * * Each subclass must implement destroy(), which can lead to errors * if the developer forgets to call super.destroy() to clean up _state. * * @category Transfers */ export declare abstract class BaseTransfer implements BaseTransferInterface { readonly isInput: boolean; readonly isOutput: boolean; readonly isDuplex: boolean; readonly isPushable: boolean; readonly isPullable: boolean; readonly isPollingSource: boolean; readonly isPollingProxy: boolean; readonly isSubscribable: boolean; readonly isTriggerable: boolean; readonly isGate: boolean; readonly isAsyncPushable: boolean; readonly isAsyncPullable: boolean; readonly isAsyncTriggerable: boolean; readonly isAsyncPollingProxy: boolean; abstract destroy(): void; } /** * Base class for transfers that store a value in ProxyReference. * * Provides: * - _state: ProxyReference — reference to the current value (initialValue from config or undefined) * - destroy(): clears _state * * Subclasses use _state.value for writing, _state.pop() for extracting * with cleanup, _state.clear() for resetting without extraction. * * @category Transfers */ export declare abstract class BaseStateTransfer extends BaseTransfer { protected readonly _state: ProxyReference; protected constructor(config?: BaseStateTransferConfig); destroy(): void; } /** * Output channel with external management via setup/destroy callbacks. * * Capabilities: isOutput, isSubscribable * * Mechanics: * 1. The constructor accepts config with callbacks: * - setup(emit) — called immediately, receives the emit(data) function * - destroy() — cleanup function (called on transfer destroy) * 2. setup() should call emit(data) to send data to subscribers * 3. subscribe(handler) — subscribes to notifications * 4. destroy() — calls config.destroy(), unsubscribes subscribers * * Error handling: * - onError — for errors in emit() (when sending data to subscribers) * - onDestroyError — for errors in destroy() * - With the corresponding handler provided, the exception is suppressed. * - Without a handler, the exception is rethrown. * - setup() errors are always rethrown (no onSetupError — a failed setup * means the transfer is unusable, suppressing would create a zombie object). * * Configuration (ChannelTransferConfig): * - setup: (emit: DataHandler) => void — channel initialization * - destroy: () => void — channel cleanup * - onError?: ErrorHandler — emit() error handler * - onDestroyError?: ErrorHandler — destroy() error handler * * Difference from StoredChannelTransfer: * - No pull() — only reactive subscription * - No trigger() — emission only via external emit() * - _state does not store a value for reading (cleared after sendState) * * Use cases: * - Integration with external event sources (WebSocket, DOM events) * - Adapting legacy API to pipeline * - Custom data sources with their own logic * * @category Transfers */ export declare class ChannelTransfer extends BaseStateTransfer implements SubscribableTransferInterface { readonly isOutput = true; readonly isSubscribable = true; protected readonly _emit: DataHandler; protected readonly _destroy: () => void; protected readonly _onError?: ErrorHandler>; protected readonly _onDestroyError?: ErrorHandler>; private readonly _subscription; constructor(config: ChannelTransferConfig); subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; } /** * Output channel with last-value retention and external management. * * Capabilities: isOutput, isPullable, isTriggerable, isSubscribable * * Mechanics: * 1. The constructor accepts config with setup/destroy callbacks (like ChannelTransfer) * 2. setup() calls emit(data), which writes the value to _state and calls trigger() * 3. trigger() — notifies subscribers with the current value (without clearing _state) * 4. pull() — reads the current value without clearing * 5. subscribe(handler) — subscribes to notifications * 6. destroy() — calls config.destroy(), unsubscribes subscribers * * Error handling: * - onError — for errors in emit() (when sending data to subscribers) * - onDestroyError — for errors in destroy() * - With the corresponding handler provided, the exception is suppressed. * - Without a handler, the exception is rethrown. * - setup() errors are always rethrown (no onSetupError). * * Configuration (StoredChannelTransferConfig): * - setup: (emit: DataHandler) => void — channel initialization * - destroy: () => void — channel cleanup * - initialValue?: T — initial value in _state * - onError?: ErrorHandler — emit() error handler * - onDestroyError?: ErrorHandler — destroy() error handler * * Difference from ChannelTransfer: * - Retains the last value (pull() is available) * - Has trigger() for re-emitting the current value * - emit() calls trigger() instead of sendState() + clear() * * Use cases: * - Integration with external sources with caching * - Channel with the ability to re-read the last value * - Storing state from an external source * * @category Transfers */ export declare class StoredChannelTransfer extends BaseStateTransfer implements SubscribableTransferInterface, PullableTransferInterface, TriggerableTransferInterface { readonly isOutput = true; readonly isPullable = true; readonly isTriggerable = true; readonly isSubscribable = true; protected readonly _emit: DataHandler; protected readonly _destroy: () => void; protected readonly _onError?: ErrorHandler>; protected readonly _onDestroyError?: ErrorHandler>; private readonly _subscription; constructor(config: StoredChannelTransferConfig); pull(): T | undefined; subscribe(handler: DataHandler): SubscriberInterface; trigger(): void; destroy(): void; } /** * Reactive channel with automatic emission to subscribers on push(). * * Capabilities: isInput, isOutput, isPushable, isSubscribable * * Mechanics: * 1. push(data) — writes the value to _state, notifies subscribers, clears _state * 2. subscribe(handler) — subscribes to notifications * 3. destroy() — unsubscribes all subscribers, clears state * * Use cases: * - Fire-and-forget messaging between components * - Reactive events without state retention * - Analog of Observable with single emission per push() * * @category Transfers */ export declare class PushChannelTransfer extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; private readonly _subscription; constructor(); push(data: T): void; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; } /** * Reactive channel with last-value retention. * Combines push/pull/subscribe/trigger. * * Capabilities: isInput, isOutput, isPushable, isPullable, isSubscribable, isTriggerable * * Mechanics: * 1. push(data) — writes the value, notifies subscribers (does NOT clear _state) * 2. pull() — reads the current value without clearing * 3. subscribe(handler) — subscribes to notifications * 4. trigger() — manually sends the current value to subscribers * 5. destroy() — unsubscribes subscribers, clears state * * Difference from PushChannelTransfer: * - Does not clear _state after push() — the value is available for pull() * - Has trigger() for manual emission without changing data * * Use cases: * - Caching the last value with reactive updates * - Component state with manual synchronization capability * - Buffer with subscription to changes * * @category Transfers */ export declare class PushStoredChannelTransfer extends BaseStateTransfer implements PushableTransferInterface, PullableTransferInterface, SubscribableTransferInterface, TriggerableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isPullable = true; readonly isSubscribable = true; readonly isTriggerable = true; private readonly _subscription; constructor(config?: BaseStateTransferConfig); push(data: T): void; pull(): T | undefined; subscribe(handler: DataHandler): SubscriberInterface; trigger(): void; destroy(): void; } /** * Reactive channel with delayed emission to subscribers on push(). * * Capabilities: isInput, isOutput, isPushable, isSubscribable * * Mechanics: * 1. push(data) — schedules a timer for delay ms; on expiry, * writes the value to _state, notifies subscribers, clears _state * 2. subscribe(handler) — subscribes to notifications * 3. destroy() — clears all pending timers, unsubscribes subscribers, clears state * * Each push() gets its own timer — multiple push() calls * result in multiple delayed notifications. * * Configuration (DelayedPushChannelTransferConfig): * - delay: number — delay before emitting data to subscribers (ms) * * Difference from PushChannelTransfer: * - push() does NOT notify subscribers immediately — only after delay ms * - The value is captured in the timer closure, so multiple * push() calls do not overwrite each other's data * * Use cases: * - Delayed events (e.g., debounce-like delay without suppression) * - Asynchronous emission with a guaranteed delay * - Testing reactive chains with a time shift * * @category Transfers */ export declare class DelayedPushChannelTransfer extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; private readonly _subscription; private readonly _delay; private _timers; constructor(config: DelayedPushChannelTransferConfig); push(data: T): void; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; } /** * Reactive channel with debounced emission to subscribers on push(). * * Capabilities: isInput, isOutput, isPushable, isSubscribable * * Mechanics: * 1. push(data) — resets the previous timer, starts a new one for delay ms * 2. On timer expiry — writes the last value to _state, * notifies subscribers, clears _state * 3. subscribe(handler) — subscribes to notifications * 4. destroy() — clears the timer, unsubscribes subscribers, clears state * * Each new push() resets the timer — subscribers are notified only * after delay ms of silence following the last push(). * * Configuration (DebounceTransferConfig): * - delay: number — silence period before emitting data (ms) * * Difference from DelayedPushChannelTransfer: * - Each push() resets the timer (rather than creating an independent one) * - Subscribers receive only the last value after a silence period * * Use cases: * - Debouncing user input (search, autosave) * - Reducing event frequency to the "last" one after a pause * - Replacing manual clearTimeout/setTimeout pattern * * @category Transfers */ export declare class DebounceTransfer extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; private readonly _subscription; private readonly _delay; private _timer; constructor(config: DebounceTransferConfig); push(data: T): void; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; private _clearTimer; } /** * Reactive channel with throttled emission to subscribers on push(). * * Capabilities: isInput, isOutput, isPushable, isSubscribable * * Mechanics: * 1. push(data) — if the throttle window is closed (active timer exists): * the value is saved as pending but not emitted * 2. If the window is open (no active timer) — the value is emitted * immediately (leading edge), a timer for interval ms is started * 3. On interval expiry — if there is a pending value, it is emitted * (trailing edge) and a new window is started * 4. subscribe(handler) — subscribes to notifications * 5. destroy() — clears the timer, unsubscribes subscribers, clears state * * Leading + trailing: the first push passes immediately, the last one in the window — * after the interval ends. This guarantees that no value is lost * and the emission rate is limited to interval. * * Configuration (ThrottleTransferConfig): * - interval: number — minimum interval between emissions (ms) * * Use cases: * - Rate-limiting high-frequency events (mouse move, resize) * - Throttling sensor/tracking data to a fixed FPS * - Replacing setInterval pattern for periodic updates * * @category Transfers */ export declare class ThrottleTransfer extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; private readonly _subscription; private readonly _interval; private _timer; private _pendingValue; private _hasPending; constructor(config: ThrottleTransferConfig); push(data: T): void; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; private _emit; private _startTimer; private _clearTimer; } /** * Passive buffer with push/pull mechanics (no notifications). * * Capabilities: isInput, isOutput, isPushable, isPullable * * Mechanics: * 1. push(data) — writes the value (overwrites the previous one) * 2. pull() — extracts the value WITH CLEANUP (uses _state.pop()) * * Differences from PushStoredChannelTransfer: * - No subscription (subscribe) — only active pull() * - No trigger — data is not sent automatically * - pull() clears the buffer (pop) rather than just reading * * Use cases: * - One-time data transfer between processes * - Buffer for producer-consumer pattern without reactivity * - Synchronous data exchange on demand * * @category Transfers */ export declare class BufferTransfer extends BaseStateTransfer implements PushableTransferInterface, PullableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isPullable = true; constructor(); push(data: T): void; pull(): T | undefined; } /** * Buffer with manual read control via trigger(). * * Capabilities: isInput, isOutput, isPushable, isPullable, isTriggerable * * Mechanics: * 1. push(data) — writes the value (overwrites the previous one) * 2. trigger() — sets the _triggered flag to true * 3. pull() — returns the value only if trigger() was called, * otherwise returns undefined; extracts with cleanup (pop) * * Difference from BufferTransfer: * - pull() returns data only after trigger() * - Implements a "lazy" read pattern: data is ready but not yielded * until explicit permission * * Use cases: * - Synchronizing reads with an external event * - Buffer with a data-readiness condition * - Step-by-step data processing in a pipeline * * @category Transfers */ export declare class ManualBufferTransfer extends BaseStateTransfer implements PushableTransferInterface, PullableTransferInterface, TriggerableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isPullable = true; readonly isTriggerable = true; private _triggered; constructor(); push(data: T): void; pull(): T | undefined; trigger(): void; } /** * Reactive stream with manual emission control via trigger(). * * Capabilities: isInput, isOutput, isPushable, isSubscribable, isTriggerable * * Mechanics: * 1. push(data) — writes the value (without notifying subscribers) * 2. trigger() — notifies subscribers with the current value, clears _state * 3. subscribe(handler) — subscribes to notifications * 4. destroy() — unsubscribes subscribers, clears state * * Difference from PushChannelTransfer: * - push() does NOT notify subscribers automatically * - To send data to subscribers, trigger() must be called * - Separates data writing from emission * * Difference from ManualBufferTransfer: * - Uses subscribe() instead of pull() * - Notifies all subscribers on trigger(), not just one reader * * Use cases: * - Synchronizing emission with an external event (e.g., requestAnimationFrame) * - Manual control of the data emission moment * * @category Transfers */ export declare class ManualFlowTransfer extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface, TriggerableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; readonly isTriggerable = true; private readonly _subscription; constructor(config?: BaseStateTransferConfig); push(data: T): void; trigger(): void; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; } /** * Transfer with state management (gate) for controlling data flow. * * Capabilities: isInput, isOutput, isPushable, isSubscribable, isGate * * Mechanics: * 1. push(data) — writes and notifies subscribers only if active === true * If the gate is closed (active === false), data is ignored * 2. subscribe(handler) — subscribes to notifications * 3. activate()/deactivate()/toggle() — control the gate state * 4. destroy() — deactivates the gate, unsubscribes subscribers, clears state * * Configuration (GateTransferConfig): * - activated: boolean — initial gate state * - initialValue?: T — initial value in _state * * Use cases: * - Blocking data flow by condition (e.g., until the user is authenticated) * - Enabling/disabling event processing * - Implementing PassBridge and other bridges * * @category Transfers */ export declare class GateTransfer extends BaseStateTransfer implements GateTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; readonly isGate = true; private readonly _subscriptions; private readonly _gateState; private _active; constructor(config: GateTransferConfig); subscribe(handler: DataHandler): SubscriberInterface; onStateChange(handler: DataHandler): SubscriberInterface; push(data: T): void; get active(): boolean; activate(): void; deactivate(): void; toggle(): boolean; destroy(): void; } /** * Aggregator of multiple sources into a single stream (merge). * * Capabilities: isInput, isOutput, isSubscribable * * Mechanics: * 1. The constructor accepts config.sources: an array of SubscribableTransferInterface * 2. Automatically subscribes to all sources * 3. On receiving data from any source — notifies its subscribers * 4. subscribe(handler) — subscribes to the merged stream * 5. destroy() — unsubscribes from all sources, unsubscribes its subscribers * * Configuration (MergeTransferConfig): * - sources: SubscribableTransferInterface[] — data sources * * Difference from AggregatorTransfer (old version): * - The new version uses SubscriptionManager and DisposableSubscriberAdapter * - Implements push/pull flags, but push() is only called internally * * Use cases: * - Merging events from multiple sources (e.g., clicks + touch + keyboard) * - Multicast: one subscriber to multiple transfers * - Implementing BridgeAggregator * * @category Transfers */ export declare class MergeTransfer extends BaseStateTransfer implements SubscribableTransferInterface { readonly isOutput = true; readonly isSubscribable = true; private readonly _subscription; private _inputConnections; constructor(config: MergeTransferConfig); subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; private _push; } /** * Stream splitter to multiple targets (broadcast). * * Capabilities: isInput, isOutput, isPushable * * Mechanics: * 1. The constructor accepts config.targets: an array of PushableTransferInterface * 2. push(data) — sends data to all targets sequentially * 3. destroy() — clears the targets array (does not call destroy() on targets) * * Configuration (SplitTransferConfig): * - targets: PushableTransferInterface[] — data receivers * * Use cases: * - Broadcasting: one event → multiple receivers * - Logging + processing: same data into two different streams * - Implementing publish-subscribe pattern at the transfer level * * @category Transfers */ export declare class SplitTransfer extends BaseTransfer implements PushableTransferInterface { readonly isInput = true; readonly isPushable = true; private _targets; constructor(config: SplitTransferConfig); push(data: T): void; destroy(): void; } /** * Output transfer with internal polling of a data source. * * Capabilities: isOutput, isPollingSource, isPullable, isSubscribable, isTriggerable, isGate * * Mechanics: * 1. The constructor accepts config.fetcher: DataFetcher — a function to retrieve data * 2. An internal Ticker (RAFTicker by default) calls trigger() at the specified interval * 3. trigger() — calls fetcher(), writes the result, notifies subscribers * 4. pull() — calls fetcher() directly (without writing to state) * 5. subscribe(handler) — subscribes to periodic updates * 6. activate()/deactivate()/toggle() — control polling * 7. destroy() — stops the ticker, unsubscribes subscribers * * Error handling: * - If fetcher() throws an exception in trigger() or pull(), onError is called. * - With onError provided, the exception is suppressed (polling continues). * - Without onError, the exception is rethrown. * * Configuration (PollingSourceTransferConfig): * - fetcher: DataFetcher — data retrieval function * - interval: number — polling interval (ms) * - activated: boolean — initial polling state * - tickerFactory?: TickerFactory — custom ticker factory (default: RAFTicker.factory) * - onError?: ErrorHandler — fetcher error handler * * Use cases: * - Periodic polling of an API or external source * - Timer emitting the current time * - Animation at a fixed FPS * * @category Transfers */ export declare class PollingSourceTransfer extends BaseStateTransfer implements PollingSourceTransferInterface, SubscribableTransferInterface, PullableTransferInterface, TriggerableTransferInterface, GateInterface { readonly isOutput = true; readonly isPollingSource = true; readonly isPullable = true; readonly isSubscribable = true; readonly isTriggerable = true; readonly isGate = true; private readonly _subscription; private readonly _gateState; private readonly _ticker; private readonly _fetcher; private readonly _onError?; constructor(config: PollingSourceTransferConfig); pull(): T | undefined; subscribe(handler: DataHandler): SubscriberInterface; onStateChange(handler: DataHandler): SubscriberInterface; trigger(): void; get active(): boolean; activate(): void; deactivate(): void; toggle(): boolean; destroy(): void; } /** * Duplex transfer with polling that receives its fetcher from the previous node in the chain. * * Capabilities: isInput, isOutput, isPollingSource, isPollingProxy, isPullable, isSubscribable, isTriggerable, isGate * * Mechanics: * 1. The constructor accepts config (interval, activated), but NOT a fetcher * 2. setFetcher(fetcher) — sets the fetcher from the previous transfer, * creates a Ticker via tickerFactory, starts polling if active * 3. clearFetcher() — stops the Ticker, clears the fetcher * 4. trigger() — calls fetcher(), notifies subscribers (if active) * 5. pull() — calls fetcher() directly (if active and fetcher is set) * 6. activate()/deactivate()/toggle() — control polling and state * 7. destroy() — stops polling, clears the fetcher, unsubscribes subscribers * * Error handling: * - If fetcher() throws an exception in trigger() or pull(), onError is called. * - With onError provided, the exception is suppressed (polling continues). * - Without onError, the exception is rethrown. * - The 'Fetcher is not defined' error is always rethrown (this is not a fetcher runtime error). * * Difference from PollingSourceTransfer: * - Fetcher is NOT set in the constructor, but via setFetcher() * - Has isInput = true (duplex, can be an intermediate link) * - pull()/trigger() without a fetcher throws an Error * - pull()/trigger() without active — returns undefined / is ignored * * Configuration (PollingProxyTransferConfig): * - interval: number — polling interval (ms) * - activated: boolean — initial polling state * - tickerFactory?: TickerFactory — custom ticker factory (default: RAFTicker.factory) * - onError?: ErrorHandler — fetcher error handler * * Use cases: * - Intermediate polling node in a transfer chain * - Adapter between a pull-source and a subscribe-consumer * - Periodic reading from a buffer with emission into a stream * * @category Transfers */ export declare class PollingProxyTransfer extends BaseStateTransfer implements PollingProxyTransferInterface, PollingSourceTransferInterface, SubscribableTransferInterface, PullableTransferInterface, TriggerableTransferInterface, GateInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPollingProxy = true; readonly isPollingSource = true; readonly isPullable = true; readonly isSubscribable = true; readonly isTriggerable = true; readonly isGate = true; private readonly _subscription; private readonly _gateState; private readonly _interval; private readonly _tickerFactory; private readonly _onError?; private _active; private _ticker; private _fetcher; constructor(config: PollingProxyTransferConfig); pull(): T | undefined; subscribe(handler: DataHandler): SubscriberInterface; onStateChange(handler: DataHandler): SubscriberInterface; trigger(): void; setFetcher(fetcher: DataFetcher): void; clearFetcher(): void; get active(): boolean; activate(): void; deactivate(): void; toggle(): boolean; destroy(): void; } /** * Output transfer with polling from OutputFlowInterface (e.g., Storage). * * Capabilities: isOutput, isPollingSource, isPullable, isSubscribable, isTriggerable, isGate * * Mechanics: * 1. The constructor accepts config.flow: OutputFlowInterface and config.interval * 2. An internal Ticker (RAFTicker by default) calls trigger() at the specified interval * 3. trigger() — calls flow.read(), writes the result, notifies subscribers * 4. pull() — calls flow.read() directly (without writing to state) * 5. subscribe(handler) — subscribes to periodic updates * 6. activate()/deactivate()/toggle() — control polling * 7. destroy() — stops the ticker, unsubscribes subscribers * * Error handling: * - If flow.read() throws an exception in trigger() or pull(), onError is called. * - With onError provided, the exception is suppressed. * * Configuration (PollingFlowTransferConfig): * - flow: OutputFlowInterface — data source with a read() method * - interval: number — polling interval (ms) * - activated: boolean — initial polling state * - tickerFactory?: TickerFactory — custom ticker factory (default: RAFTicker.factory) * - onError?: ErrorHandler — error handler * * Difference from PollingSourceTransfer: * - Uses FlowInterface instead of DataFetcher * - Convenient for working with Storage (LatestStorage, QueueStorage, StackStorage) * * Use cases: * - Periodic reading from storage * - Polling state from shared storage * - Integration with external sources via FlowInterface * * @category Transfers */ export declare class PollingFlowTransfer extends BaseStateTransfer implements PollingSourceTransferInterface, SubscribableTransferInterface, PullableTransferInterface, TriggerableTransferInterface, GateInterface { readonly isOutput = true; readonly isPollingSource = true; readonly isPullable = true; readonly isSubscribable = true; readonly isTriggerable = true; readonly isGate = true; private readonly _subscription; private readonly _gateState; private readonly _flow; private readonly _ticker; private readonly _onError?; constructor(config: PollingFlowTransferConfig); pull(): T | undefined; subscribe(handler: DataHandler): SubscriberInterface; onStateChange(handler: DataHandler): SubscriberInterface; trigger(): void; get active(): boolean; activate(): void; deactivate(): void; toggle(): boolean; destroy(): void; } /** * Reactive channel with fallback polling on idle incoming data. * * Capabilities: isInput, isOutput, isDuplex, isPushable, isPullable, isSubscribable, isPollingSource, isTriggerable, isGate * * Mechanics: * 1. push(data) — writes the value, notifies subscribers, clears _state, * resets the idle timer and stops polling if it was active * 2. If no data arrived via push() for longer than timeout ms — an internal * Ticker (via tickerFactory) starts, periodically polling the fetcher at interval * 3. trigger() — manually calls the fetcher and notifies subscribers, restarts the idle timer * 4. pull() — calls the fetcher directly (without writing to state or notifying subscribers) * 5. subscribe(handler) — subscribes to notifications * 6. activate()/deactivate()/toggle() — control idle monitoring * 7. destroy() — stops timers, unsubscribes subscribers, clears state * * Error handling: * - If fetcher() throws an exception in trigger() or during polling, onError is called. * - With onError provided, the exception is suppressed (polling continues). * - Without onError, the exception is rethrown. * * Configuration (IdlePollingTransferConfig): * - fetcher: DataFetcher — data retrieval function for idle polling * - timeout: number — idle time (ms) before polling starts * - interval: number — fetcher polling interval (ms) * - activated: boolean — initial idle monitoring state * - initialValue?: T — initial value in _state * - tickerFactory?: TickerFactory — custom ticker factory (default: RAFTicker.factory) * - onError?: ErrorHandler — fetcher error handler * * Use cases: * - Refreshing data from an API when the external source stops sending events * - Heartbeat / keep-alive mechanism: polling on absence of incoming data * - Fallback data source when the main stream is idle * * @category Transfers */ export declare class IdlePollingTransfer extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface, PullableTransferInterface, TriggerableTransferInterface, PollingSourceTransferInterface, GateInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isPullable = true; readonly isSubscribable = true; readonly isPollingSource = true; readonly isTriggerable = true; readonly isGate = true; private readonly _subscription; private readonly _gateState; private readonly _timeout; private readonly _interval; private readonly _fetcher; private readonly _onError?; private readonly _tickerFactory; private _active; private _idleTimer; private _ticker; constructor(config: IdlePollingTransferConfig); push(data: T): void; subscribe(handler: DataHandler): SubscriberInterface; pull(): T | undefined; onStateChange(handler: DataHandler): SubscriberInterface; trigger(): void; get active(): boolean; activate(): void; deactivate(): void; toggle(): boolean; destroy(): void; private _startIdleTimer; private _clearIdleTimer; private _startPolling; private _stopPolling; private _poll; } /** * Terminal destination (sink) — calls a callback on receiving data. * * Capabilities: isInput, isPushable * * Mechanics: * 1. The constructor accepts config.callback: DataHandler * 2. push(data) — calls callback(data) * 3. destroy() — inherited from BaseStateTransfer, clears _state * * Error handling: * - If callback() throws an exception, onError is called. * - With onError provided, the exception is suppressed. Without onError — rethrown. * * Configuration (SinkTransferConfig): * - callback: DataHandler — incoming data handler * - onError?: ErrorHandler — error handler * - initialValue?: T — initial value (unused) * * Difference from CallbackTransfer (old version): * - The new version inherits from BaseStateTransfer (has _state) * - But _state is not used in push() — data goes directly to callback * - Does not implement isOutput (input only) * * Use cases: * - Logging: writing data to console/file * - Side effects: sending metrics, analytics * - Finalization: saving the result to storage * * @category Transfers */ export declare class SinkTransfer extends BaseStateTransfer implements PushableTransferInterface { readonly isInput = true; readonly isPushable = true; private readonly _callback; private readonly _onError?; constructor(config: SinkTransferConfig); push(data: T): void; } /** * Write adapter for an arbitrary InputFlowInterface (e.g., Storage). * * Capabilities: isInput, isPushable * * Mechanics: * 1. The constructor accepts config.flow: InputFlowInterface * 2. push(data) — calls flow.write(data) * 3. destroy() — does nothing (does not own the flow) * * Error handling: * - If flow.write() throws an exception, onError is called. * - With onError provided, the exception is suppressed. Without onError — rethrown. * * Configuration (WriteTransferConfig): * - flow: InputFlowInterface — target flow with a write() method * - onError?: ErrorHandler — error handler * * Use cases: * - Writing data to Storage (LatestStorage, QueueStorage, StackStorage) * - Adapting an arbitrary object with write() to pipeline * - Finalization: saving the result to external storage * * @category Transfers */ export declare class WriteTransfer extends BaseTransfer implements PushableTransferInterface { readonly isInput = true; readonly isPushable = true; private readonly _flow; private readonly _onError?; constructor(config: WriteTransferConfig); push(data: T): void; destroy(): void; } /** * Read adapter for an arbitrary OutputFlowInterface (e.g., Storage). * * Capabilities: isOutput, isPullable * * Mechanics: * 1. The constructor accepts config.flow: OutputFlowInterface * 2. pull() — returns flow.read() * 3. destroy() — does nothing (does not own the flow) * * Error handling: * - If flow.read() throws an exception, onError is called. * - With onError provided, the exception is suppressed, pull() returns undefined. * - Without onError, the exception is rethrown. * * Configuration (ReadTransferConfig): * - flow: OutputFlowInterface — target flow with a read() method * - onError?: ErrorHandler — error handler * * Use cases: * - Reading data from Storage (LatestStorage, QueueStorage, StackStorage) * - Adapting an arbitrary object with read() to pipeline * - Data source for polling transfers * * @category Transfers */ export declare class ReadTransfer extends BaseTransfer implements PullableTransferInterface { readonly isOutput = true; readonly isPullable = true; private readonly _flow; private readonly _onError?; constructor(config: ReadTransferConfig); pull(): T | undefined; destroy(): void; } /** * Converter transfer: transforms input data via an Operator and * sends the result to subscribers. * * Capabilities: isInput, isOutput, isPushable, isSubscribable * * Mechanics: * 1. The constructor accepts config.operator: OperatorInterface * 2. push(data: TInput) — applies operator.apply(data), notifies subscribers, * clears _state * 3. subscribe(handler) — subscribes to transformed data * 4. destroy() — unsubscribes subscribers, clears _state * 5. If the operator returns undefined, subscribers are not notified * * Error handling: * - If operator.apply() throws an exception, onError is called. * - With onError provided, the exception is suppressed, subscribers are not notified. * - Without onError, the exception is rethrown. * * Configuration (ConvertTransferConfig): * - operator: OperatorInterface — data transformer * - onError?: ErrorHandler — error handler * * Difference from OperatorTransfer (old version): * - The new version's push() automatically notifies subscribers * - Has no trigger() — emission happens immediately on push() * - Has no pull() — the result is not stored after emission * * Use cases: * - Type transformation in a stream (e.g., string → number) * - Filtering via GuardOperator (undefined blocks emission) * - Real-time data mapping * - Implementing TransformBridge * * @category Transfers */ export declare class ConvertTransfer extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; private readonly _subscription; private readonly _operator; private readonly _onError?; constructor(config: ConvertTransferConfig); push(data: TInput): void; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; } /** * Transfer with conditional filtering on input and output. * * Capabilities: isInput, isOutput, isPushable, isSubscribable * * Mechanics: * 1. The constructor accepts config with two predicates: * - shouldAccept(data) — input filter (if false, data is ignored) * - shouldEmit(data) — output filter (if false, data is ignored) * 2. push(data) — checks shouldAccept, if true — checks shouldEmit, * if true — notifies subscribers and clears state * 3. subscribe(handler) — subscribes to notifications * 4. destroy() — unsubscribes subscribers, clears state * * Error handling: * - If shouldAccept throws an exception, onAcceptError is called. * - If shouldEmit throws an exception, onEmitError is called. * - With the corresponding handler provided, the exception is suppressed. * * Configuration (ConditionTransferConfig): * - shouldAccept?: (data: T) => boolean — input filter (default: always true) * - shouldEmit?: (data: T) => boolean — output filter (default: always true) * - onAcceptError?: ErrorHandler — shouldAccept error handler * - onEmitError?: ErrorHandler — shouldEmit error handler * * Use cases: * - Filtering data by value (e.g., only even numbers) * - Blocking duplicates (shouldEmit checks the previous value) * - Throttling/debouncing via time-based conditions * - Validating data before forwarding * * @category Transfers */ export declare class ConditionTransfer extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; private readonly _subscription; private readonly _shouldAccept; private readonly _shouldEmit; private readonly _onAcceptError?; private readonly _onEmitError?; constructor(config: ConditionTransferConfig); push(data: T): void; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; } /** * Displace transfer: for each input value, creates a new inner * async-pushable + subscribable transfer via a factory function, * subscribes to it, pushes the value into it via asyncPush(), and * forwards the inner's emissions to outer subscribers. * * On each new push(), the previous inner subscription is unsubscribed * and the previous inner transfer is destroyed — the new inner * displaces the previous one. Only the latest inner transfer's * emissions reach the outer subscribers. * * The factory receives no arguments — the input value is delivered to * the inner transfer via asyncPush(data), not passed to the factory. * This keeps the factory purely declarative: it creates a transfer, * DisplaceTransfer handles data delivery. * * The outer push() is synchronous: it creates the inner, disposes the * previous one, subscribes, and calls inner.asyncPush(data) fire-and- * forget. The async work happens inside the inner transfer — its * results arrive via subscription callbacks. * * Capabilities: isInput, isOutput, isPushable, isSubscribable * * Mechanics: * 1. push(data) — calls factory() to create a new inner transfer, * then disposes the previous inner (unsubscribe + destroy), * then subscribes to the new inner (forwarding emissions to outer subscribers), * then calls inner.asyncPush(data) to deliver the value (fire-and-forget) * 2. subscribe(handler) — subscribes to the outer output * 3. destroy() — disposes the current inner transfer, unsubscribes outer subscribers * * Error handling: * - If factory() throws an exception, onError is called. * - With onError provided, the exception is suppressed (previous inner remains active). * - Without onError, the exception is rethrown. * - If inner.asyncPush(data) rejects, the rejection is unhandled (fire-and-forget). * Provide onError on the inner transfer to suppress internal errors. * * Configuration (DisplaceTransferConfig): * - factory: () => Transfer * — creates inner transfer per input (no arguments; data is pushed via asyncPush) * - onError?: ErrorHandler — factory error handler * - onDisplace?: (displaced: Transfer) => void * — called with the previous inner transfer before it is unsubscribed and destroyed. * Use for cleanup that must happen before destruction (e.g., aborting an in-flight request, * closing a WebSocket, cancelling a timer). If the callback throws, the exception is * rethrown (the inner is still destroyed). Not called on destroy() — only on displacement * by a new push(). Not called for the first push() (no previous inner exists). * * Use cases: * - switchMap semantics: displace previous inner stream on new input * - Search-as-you-type: debounce → displace(factory) → latest result wins * - Per-value async operations (fetch, readFile) where only the latest result matters * - Per-value WebSocket/stream subscriptions with automatic cleanup * - Custom cancellation logic via onDisplace (abort, close, cancel) before inner is destroyed * * @category Transfers */ export declare class DisplaceTransfer = Transfer> extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; private readonly _subscription; private readonly _factory; private readonly _onError?; private readonly _onDisplace?; private _innerSubscription; private _innerTransfer; constructor(config: DisplaceTransferConfig); push(data: TInput): void; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; private _disposeInner; } /** * Output channel with value retention, external management, and async interface. * * Capabilities: isOutput, isSubscribable, isAsyncPullable, isAsyncTriggerable * * Mechanics: * 1. setup(emit) / destroy() — sync, like in StoredChannelTransfer * 2. emit(data) — sync, writes the value, calls asyncTrigger (fire-and-forget) * 3. asyncPull() — returns the current value (trivially async) * 4. asyncTrigger() — notifies subscribers (trivially async) * 5. subscribe(handler) — sync subscription * * Note: setup/emit/subscribe are synchronous (subscription remains sync), * but pull/trigger are async for integration with async pipelines. * * Configuration (AsyncStoredChannelTransferConfig): * - setup: (emit: DataHandler) => void * - destroy: () => void * - initialValue?: T * - onError?, onDestroyError?: ErrorHandler * * @category Async Transfers */ export declare class AsyncStoredChannelTransfer extends BaseStateTransfer implements SubscribableTransferInterface, AsyncPullableTransferInterface, AsyncTriggerableInterface { readonly isOutput = true; readonly isSubscribable = true; readonly isAsyncPullable = true; readonly isAsyncTriggerable = true; protected readonly _emit: DataHandler; protected readonly _destroy: () => void; protected readonly _onError?: ErrorHandler>; protected readonly _onDestroyError?: ErrorHandler>; private readonly _subscription; constructor(config: AsyncStoredChannelTransferConfig); asyncPull(): Promise; subscribe(handler: DataHandler): SubscriberInterface; asyncTrigger(): Promise; destroy(): void; } /** * Asynchronous terminal sink — calls a callback on receiving data. * * Capabilities: isInput, isAsyncPushable * * Mechanics: * 1. The constructor accepts config.callback: AsyncDataHandler * 2. asyncPush(data) — calls await callback(data) * 3. destroy() — inherited from BaseStateTransfer, clears _state * * Ordered execution (config.ordered: true): * - When enabled, callback invocations are executed sequentially in * data-arrival order, regardless of their async duration. * - Uses an internal OrderedExecutor (promise chain). * - Default: false (unordered, backward-compatible). * * Error handling: * - If callback() throws an exception, onError is called. * - With onError provided, the exception is suppressed. Without onError — rethrown. * - When ordered: true, the executor chain catches errors so that a throwing * callback does not block subsequent callbacks. The error is still propagated * to the asyncPush caller via the awaited executor promise. * * Configuration (AsyncSinkTransferConfig): * - callback: AsyncDataHandler — incoming data handler (sync or async) * - onError?: ErrorHandler — error handler * - ordered?: boolean — ordered callback execution (default: false) * - maxConcurrency?, bufferSize?, onBufferOverflow? (BackpressureConfig) * * Use cases: * - Asynchronous logging to file/database * - Side effects with async API (fetch, IndexedDB) * * @category Async Transfers */ export declare class AsyncSinkTransfer extends BaseStateTransfer implements AsyncPushableTransferInterface { readonly isInput = true; readonly isAsyncPushable = true; private readonly _callback; private readonly _onError?; private readonly _maxConcurrency; private readonly _bufferSize; private readonly _onBufferOverflow?; private readonly _ordered; private readonly _executor; private _activeCount; private _buffer; constructor(config: AsyncSinkTransferConfig); asyncPush(data: T): Promise; private _process; private _dequeue; destroy(): void; } /** * Asynchronous write adapter for AsyncInputFlowInterface. * * Capabilities: isInput, isAsyncPushable * * Mechanics: * 1. The constructor accepts config.flow: AsyncInputFlowInterface * 2. asyncPush(data) — calls await flow.write(data) * 3. destroy() — does nothing (does not own the flow) * * Ordered execution (config.ordered: true): * - When enabled, flow.write() invocations are executed sequentially in * data-arrival order, regardless of their async duration. * - Uses an internal OrderedExecutor (promise chain). * - Default: false (unordered, backward-compatible). * * Error handling: * - If flow.write() throws an exception, onError is called. * - With onError provided, the exception is suppressed. Without onError — rethrown. * - When ordered: true, the executor chain catches errors so that a throwing * write does not block subsequent writes. The error is still propagated * to the asyncPush caller via the awaited executor promise. * * Configuration (AsyncWriteTransferConfig): * - flow: AsyncInputFlowInterface — target flow with async write() * - onError?: ErrorHandler — error handler * - ordered?: boolean — ordered write execution (default: false) * - maxConcurrency?, bufferSize?, onBufferOverflow? (BackpressureConfig) * * Use cases: * - Writing data to async storage (IndexedDB, API) * - Adapting an arbitrary object with async write() to pipeline * * @category Async Transfers */ export declare class AsyncWriteTransfer extends BaseTransfer implements AsyncPushableTransferInterface { readonly isInput = true; readonly isAsyncPushable = true; private readonly _flow; private readonly _onError?; private readonly _maxConcurrency; private readonly _bufferSize; private readonly _onBufferOverflow?; private readonly _ordered; private readonly _executor; private _activeCount; private _buffer; constructor(config: AsyncWriteTransferConfig); asyncPush(data: T): Promise; destroy(): void; private _process; private _dequeue; } /** * Asynchronous read adapter for AsyncOutputFlowInterface. * * Capabilities: isOutput, isAsyncPullable * * Mechanics: * 1. The constructor accepts config.flow: AsyncOutputFlowInterface * 2. asyncPull() — returns await flow.read() * 3. destroy() — does nothing (does not own the flow) * * Error handling: * - If flow.read() throws an exception, onError is called. * - With onError provided, the exception is suppressed, asyncPull() returns undefined. * - Without onError, the exception is rethrown. * * Configuration (AsyncReadTransferConfig): * - flow: AsyncOutputFlowInterface — target flow with async read() * - onError?: ErrorHandler — error handler * * Use cases: * - Reading data from async storage (IndexedDB, API) * - Data source for async-polling transfers * * @category Async Transfers */ export declare class AsyncReadTransfer extends BaseTransfer implements AsyncPullableTransferInterface { readonly isOutput = true; readonly isAsyncPullable = true; private readonly _flow; private readonly _onError?; constructor(config: AsyncReadTransferConfig); asyncPull(): Promise; destroy(): void; } /** * Output transfer with asynchronous internal polling of a data source. * * Capabilities: isOutput, isPollingSource, isAsyncPullable, isSubscribable, isAsyncTriggerable, isGate * * Mechanics: * 1. The constructor accepts config.fetcher: AsyncDataFetcher * 2. An internal Ticker calls asyncTrigger() (fire-and-forget) * 3. asyncTrigger() — calls await fetcher(), writes the result, notifies subscribers * 4. asyncPull() — calls await fetcher() directly (without writing to state) * 5. The _polling flag prevents overlapping calls with a slow fetcher * 6. activate()/deactivate()/toggle() — control polling via the ticker * * Error handling: * - If fetcher() throws an exception in asyncTrigger() or asyncPull(), onError is called. * - With onError provided, the exception is suppressed (polling continues). * - Without onError, the exception is rethrown from asyncPull()/asyncTrigger(). * - When the ticker fires asyncTrigger() without onError, the rejection is unhandled * (visible in logs as unhandled promise rejection). To suppress — provide onError. * * Configuration (AsyncPollingSourceTransferConfig): * - fetcher: AsyncDataFetcher — async data retrieval function * - interval: number — polling interval (ms) * - activated: boolean — initial polling state * - tickerFactory?: TickerFactory — custom ticker factory * - onError?: ErrorHandler — fetcher error handler * * @category Async Transfers */ export declare class AsyncPollingSourceTransfer extends BaseStateTransfer implements PollingSourceTransferInterface, SubscribableTransferInterface, AsyncPullableTransferInterface, AsyncTriggerableInterface, GateInterface { readonly isOutput = true; readonly isPollingSource = true; readonly isSubscribable = true; readonly isAsyncPullable = true; readonly isAsyncTriggerable = true; readonly isGate = true; private readonly _subscription; private readonly _gateState; private readonly _ticker; private readonly _fetcher; private readonly _onError?; private _polling; constructor(config: AsyncPollingSourceTransferConfig); asyncPull(): Promise; subscribe(handler: DataHandler): SubscriberInterface; onStateChange(handler: DataHandler): SubscriberInterface; asyncTrigger(): Promise; get active(): boolean; activate(): void; deactivate(): void; toggle(): boolean; destroy(): void; } /** * Output transfer with asynchronous polling from AsyncOutputFlowInterface. * * Capabilities: isOutput, isPollingSource, isAsyncPullable, isSubscribable, isAsyncTriggerable, isGate * * Mechanics are analogous to AsyncPollingSourceTransfer, but the source is * AsyncOutputFlowInterface (async read()) instead of AsyncDataFetcher. * * Configuration (AsyncPollingFlowTransferConfig): * - flow: AsyncOutputFlowInterface — data source with async read() * - interval, activated, tickerFactory, onError — same as in AsyncPollingSourceTransfer * * @category Async Transfers */ export declare class AsyncPollingFlowTransfer extends BaseStateTransfer implements PollingSourceTransferInterface, SubscribableTransferInterface, AsyncPullableTransferInterface, AsyncTriggerableInterface, GateInterface { readonly isOutput = true; readonly isPollingSource = true; readonly isSubscribable = true; readonly isAsyncPullable = true; readonly isAsyncTriggerable = true; readonly isGate = true; private readonly _subscription; private readonly _gateState; private readonly _flow; private readonly _ticker; private readonly _onError?; private _polling; constructor(config: AsyncPollingFlowTransferConfig); asyncPull(): Promise; subscribe(handler: DataHandler): SubscriberInterface; onStateChange(handler: DataHandler): SubscriberInterface; asyncTrigger(): Promise; get active(): boolean; activate(): void; deactivate(): void; toggle(): boolean; destroy(): void; } /** * Duplex transfer with asynchronous polling that receives its fetcher from the previous node. * * Capabilities: isInput, isOutput, isDuplex, isAsyncPollingProxy, isPollingSource, * isAsyncPullable, isSubscribable, isAsyncTriggerable, isGate * * Mechanics: * 1. The constructor accepts config (interval, activated), but NOT a fetcher * 2. setAsyncFetcher(fetcher) — sets the async fetcher, creates a Ticker, starts if active * 3. clearAsyncFetcher() — stops the Ticker, clears the fetcher * 4. asyncTrigger() — calls await fetcher(), notifies subscribers (if active) * 5. asyncPull() — calls await fetcher() directly (if active and fetcher is set) * 6. The _polling flag prevents overlapping * 7. activate()/deactivate()/toggle() — control polling * * Error handling: * - If fetcher() throws an exception, onError is called. * - With onError provided, the exception is suppressed. Without onError — rethrown. * - The 'Async fetcher is not defined' error is always rethrown. * - When the ticker fires asyncTrigger() without onError, the rejection is unhandled * (visible in logs as unhandled promise rejection). To suppress — provide onError. * * Configuration (AsyncPollingProxyTransferConfig): * - interval: number — polling interval (ms) * - activated: boolean — initial polling state * - tickerFactory?: TickerFactory * - onError?: ErrorHandler * * @category Async Transfers */ export declare class AsyncPollingProxyTransfer extends BaseStateTransfer implements AsyncPollingProxyTransferInterface, PollingSourceTransferInterface, SubscribableTransferInterface, AsyncPullableTransferInterface, AsyncTriggerableInterface, GateInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPollingSource = true; readonly isSubscribable = true; readonly isGate = true; readonly isAsyncPollingProxy = true; readonly isAsyncPullable = true; readonly isAsyncTriggerable = true; private readonly _subscription; private readonly _gateState; private readonly _interval; private readonly _tickerFactory; private readonly _onError?; private _active; private _ticker; private _fetcher; private _polling; constructor(config: AsyncPollingProxyTransferConfig); asyncPull(): Promise; subscribe(handler: DataHandler): SubscriberInterface; onStateChange(handler: DataHandler): SubscriberInterface; asyncTrigger(): Promise; setAsyncFetcher(fetcher: AsyncDataFetcher): void; clearAsyncFetcher(): void; get active(): boolean; activate(): void; deactivate(): void; toggle(): boolean; destroy(): void; } /** * Reactive channel with asynchronous fallback polling on idle. * * Capabilities: isInput, isOutput, isDuplex, isPushable, isSubscribable, * isPollingSource, isAsyncPullable, isAsyncTriggerable, isGate * * Mechanics: * 1. push(data) — synchronously writes, notifies, clears, resets the idle timer * 2. asyncTrigger() — awaits _doPoll() (fetch + notify), then restarts the idle timer * 3. asyncPull() — calls await fetcher() directly (without writing to state) * 4. If no data arrived for longer than timeout ms — polling starts via Ticker * 5. The ticker calls _doPoll() (fire-and-forget) * 6. On push — polling stops, the idle timer resets * 7. The _polling flag prevents overlapping * * Note: push is synchronous (like in the sync version), but the fetcher is asynchronous. * Results arrive via sync subscription. asyncTrigger and asyncPull are async methods. * * Error handling: * - If fetcher() throws an exception, onError is called. * - With onError provided, the exception is suppressed. Without onError — rethrown from _doPoll. * - asyncTrigger() awaits _doPoll() — caller can catch rethrown errors via await. * - When the ticker fires _doPoll() without onError, the rejection is unhandled * (visible in logs as unhandled promise rejection). To suppress — provide onError. * * Configuration (AsyncIdlePollingTransferConfig): * - fetcher: AsyncDataFetcher — async data retrieval function for idle polling * - timeout: number — idle time (ms) before polling starts * - interval: number — fetcher polling interval (ms) * - activated: boolean — initial idle monitoring state * - initialValue?: T * - tickerFactory?: TickerFactory * - onError?: ErrorHandler * * @category Async Transfers */ export declare class AsyncIdlePollingTransfer extends BaseStateTransfer implements PushableTransferInterface, SubscribableTransferInterface, AsyncPullableTransferInterface, AsyncTriggerableInterface, PollingSourceTransferInterface, GateInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isPushable = true; readonly isSubscribable = true; readonly isPollingSource = true; readonly isAsyncPullable = true; readonly isAsyncTriggerable = true; readonly isGate = true; private readonly _subscription; private readonly _gateState; private readonly _timeout; private readonly _interval; private readonly _fetcher; private readonly _onError?; private readonly _tickerFactory; private _active; private _idleTimer; private _ticker; private _polling; constructor(config: AsyncIdlePollingTransferConfig); push(data: T): void; subscribe(handler: DataHandler): SubscriberInterface; onStateChange(handler: DataHandler): SubscriberInterface; asyncPull(): Promise; asyncTrigger(): Promise; get active(): boolean; activate(): void; deactivate(): void; toggle(): boolean; destroy(): void; private _startIdleTimer; private _clearIdleTimer; private _startPolling; private _stopPolling; private _doPoll; } /** * Async converter transfer: transforms input data via an AsyncOperator * and sends the result to subscribers. * * Capabilities: isInput, isOutput, isDuplex, isAsyncPushable, isSubscribable * * Mechanics: * 1. The constructor accepts config.operator: AsyncOperatorInterface * 2. asyncPush(data) — applies await operator.apply(data), notifies subscribers, clears _state * 3. subscribe(handler) — subscribes to transformed data (sync) * 4. If the operator returns undefined — subscribers are not notified * * Sequence Guard (active when maxConcurrency > 1): * - Multiple operator.apply() calls run in parallel (up to maxConcurrency). * - Results are emitted to subscribers strictly in data-arrival order. * - A faster operation that completes before an older one waits in an * internal pending queue until its predecessor is emitted. * - This prevents a stale result from overwriting a fresh one in _state.value. * - When maxConcurrency <= 1, the guard is inactive (no overhead). * * Error handling: * - If operator.apply() throws an exception, onError is called. * - With onError provided, the exception is suppressed. Without onError — rethrown. * - When the guard is active, a failed operation submits undefined to the * queue so that subsequent results are not blocked. * * Configuration (AsyncConvertTransferConfig): * - operator: AsyncOperatorInterface * - onError?: ErrorHandler * - maxConcurrency?, bufferSize?, onBufferOverflow? (BackpressureConfig) * * @category Async Transfers */ export declare class AsyncConvertTransfer extends BaseStateTransfer implements AsyncPushableTransferInterface, SubscribableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isSubscribable = true; readonly isAsyncPushable = true; private readonly _subscription; private readonly _operator; private readonly _onError?; private readonly _maxConcurrency; private readonly _bufferSize; private readonly _onBufferOverflow?; private readonly _guardActive; private readonly _queue; private _activeCount; private _buffer; constructor(config: AsyncConvertTransferConfig); asyncPush(data: TInput): Promise; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; private _process; private _drain; private _dequeue; } /** * Transfer with asynchronous conditional filtering on input and output. * * Capabilities: isInput, isOutput, isDuplex, isAsyncPushable, isSubscribable * * Mechanics: * 1. shouldAccept(data) — async input filter (if false, data is ignored) * 2. shouldEmit(data) — async output filter (if false, data is not emitted) * 3. asyncPush(data) — await shouldAccept → await shouldEmit → sendState + clear * 4. Predicates can be sync or async (return Promise | boolean) * * Sequence Guard (active when maxConcurrency > 1): * - Multiple shouldAccept/shouldEmit checks run in parallel (up to maxConcurrency). * - Emissions to subscribers happen strictly in data-arrival order. * - shouldEmit receives the operation's local data, not a shared _state.value, * so it cannot accidentally inspect another operation's data. * - When maxConcurrency <= 1, the guard is inactive (no overhead). * * Error handling: * - If shouldAccept throws an exception, onAcceptError is called. * - If shouldEmit throws an exception, onEmitError is called. * - With the corresponding handler provided, the exception is suppressed. * - When the guard is active, a failed/skipped operation submits a no-emit * marker to the queue so that subsequent results are not blocked. * * Configuration (AsyncConditionTransferConfig): * - shouldAccept?: (data: T) => Promise | boolean * - shouldEmit?: (data: T) => Promise | boolean * - onAcceptError?: ErrorHandler * - onEmitError?: ErrorHandler * - maxConcurrency?, bufferSize?, onBufferOverflow? (BackpressureConfig) * * @category Async Transfers */ export declare class AsyncConditionTransfer extends BaseStateTransfer implements AsyncPushableTransferInterface, SubscribableTransferInterface { readonly isInput = true; readonly isOutput = true; readonly isDuplex = true; readonly isSubscribable = true; readonly isAsyncPushable = true; private readonly _subscription; private readonly _shouldAccept; private readonly _shouldEmit; private readonly _onAcceptError?; private readonly _onEmitError?; private readonly _maxConcurrency; private readonly _bufferSize; private readonly _onBufferOverflow?; private readonly _guardActive; private readonly _queue; private _activeCount; private _buffer; constructor(config: AsyncConditionTransferConfig); asyncPush(data: T): Promise; subscribe(handler: DataHandler): SubscriberInterface; destroy(): void; private _process; private _drain; private _dequeue; } /** * Universal composite transfer — combines input and output transfers * into a single duplex interface with automatic extraction of additional capabilities. * * Capabilities: depend on the provided input/output (determined dynamically via flags) * * Mechanics: * 1. The constructor accepts config with required input/output and optional: * - triggerable?: TriggerableInterface — explicit object for trigger() * - gate?: GateInterface — explicit object for active control * - owned?: DisposableInterface[] — resources to clean up on destroy() * 2. Automatically extracts triggerable and gate by priority: * - Priority 1: config.triggerable / config.gate (explicit) * - Priority 2: config.input (if it has the corresponding flag) * - Priority 3: config.output (if it has the corresponding flag) * 3. Delegates input/output methods: * - push(data) → _input.push(data) * - pull() → _output.pull() * - subscribe(handler) → _output.subscribe(handler) * - trigger() → _triggerable.trigger() * - setFetcher/clearFetcher() → _input.setFetcher/clearFetcher() * - activate/deactivate/toggle/active → _gate.* * 4. All methods check capabilities via flags before calling * 5. destroy() — cleans up all owned resources * * Triggerable/gate extraction priorities: * - If config.triggerable is specified — it is used * - Otherwise if config.input.isTriggerable — input is used * - Otherwise if config.output.isTriggerable — output is used * - Otherwise undefined (trigger() will throw an error) * * Configuration (CompositeTransferConfig): * - input: InputTransfer — input transfer * - output: OutputTransfer — output transfer * - triggerable?: TriggerableInterface — explicit triggerable (optional) * - gate?: GateInterface — explicit gate (optional) * - owned?: DisposableInterface[] — managed resources (optional) * * Use cases: * - Composing separate input and output transfers into a single interface * - Adapting legacy transfers to the new flag-based architecture * - Building complex pipelines with automatic capability management * - Encapsulating multiple resources into a single managed object * * @example * // Basic usage with automatic extraction * const transfer = new PushStoredChannelTransfer(); * const composite = new UniversalCompositeTransfer({ * input: transfer, * output: transfer, * owned: [transfer], * }); * * composite.push(42); * // Delegates input.push() * * composite.subscribe(console.log); * // Delegates output.subscribe() * * composite.trigger(); * // Delegates triggerable.trigger() * * composite.destroy(); * // Cleans up owned resources * * @example * // Explicit triggerable and gate * const input = new PushChannelTransfer(); * const output = new PushChannelTransfer(); * const gate = new GateTransfer({ activated: true, initialValue: 0 }); * const composite = new UniversalCompositeTransfer({ * input, * output, * gate, // Explicitly specify gate * owned: [gate], * }); * * @category Transfers */ export declare class UniversalCompositeTransfer implements UniversalDuplexInterface { private readonly _input; private readonly _output; private readonly _triggerable?; private readonly _asyncTriggerable?; private readonly _gate?; private _owned; constructor(config: CompositeTransferConfig); /** * Sends data to the input transfer. * @param data Data to send * @throws Error if isPushable === false */ push(data: TInput): void; /** * Extracts data from the output transfer. * @returns Data or undefined if no data * @throws Error if isPullable === false */ pull(): TOutput | undefined; /** * Subscribes to output transfer notifications. * @param handler Notification handler * @returns SubscriberInterface for subscription management * @throws Error if isSubscribable === false */ subscribe(handler: DataHandler): SubscriberInterface; onStateChange(handler: DataHandler): SubscriberInterface; /** * Manual trigger to send data to subscribers. * @throws Error if _triggerable === undefined (isTriggerable === false) */ trigger(): void; /** * Sets the fetcher for polling. * @param fetcher Data retrieval function * @throws Error if isPollingProxy === false */ setFetcher(fetcher: DataFetcher): void; /** * Clears the fetcher for polling. * @throws Error if isPollingProxy === false */ clearFetcher(): void; /** * Asynchronously sends data to the input transfer. * @throws Error if isAsyncPushable === false */ asyncPush(data: TInput): Promise; /** * Asynchronously extracts data from the output transfer. * @throws Error if isAsyncPullable === false */ asyncPull(): Promise; /** * Asynchronous manual trigger. * @throws Error if _asyncTriggerable === undefined (isAsyncTriggerable === false) */ asyncTrigger(): Promise; /** * Sets the async fetcher for polling. * @throws Error if isAsyncPollingProxy === false */ setAsyncFetcher(fetcher: AsyncDataFetcher): void; /** * Clears the async fetcher. * @throws Error if isAsyncPollingProxy === false */ clearAsyncFetcher(): void; /** * Checks the gate state (active/inactive). * @returns true if the gate is active * @throws Error if _gate === undefined (isGate === false) */ get active(): boolean; /** * Activates the gate (enables data flow). * @throws Error if _gate === undefined (isGate === false) */ activate(): void; /** * Deactivates the gate (blocks data flow). * @throws Error if _gate === undefined (isGate === false) */ deactivate(): void; /** * Toggles the gate state. * @returns The new gate state * @throws Error if _gate === undefined (isGate === false) */ toggle(): boolean; /** * Cleans up all owned resources. * Calls destroy() on each resource in the owned array. */ destroy(): void; /** * Flag: whether the transfer is an input. * Delegated from _input.isInput. */ get isInput(): boolean; /** * Flag: whether the transfer is an output. * Delegated from _output.isOutput. */ get isOutput(): boolean; /** * Flag: whether the transfer is duplex (both input and output). * Computed as isInput && isOutput. */ get isDuplex(): boolean; /** * Flag: whether the transfer is a polling data source. * Delegated from _output.isPollingSource. */ get isPollingSource(): boolean; /** * Flag: whether the transfer can poll other transfers. * Delegated from _input.isPollingProxy. */ get isPollingProxy(): boolean; /** * Flag: whether the transfer supports sending data via push(). * Delegated from _input.isPushable. */ get isPushable(): boolean; /** * Flag: whether the transfer supports extracting data via pull(). * Delegated from _output.isPullable. */ get isPullable(): boolean; /** * Flag: whether the transfer supports subscription via subscribe(). * Delegated from _output.isSubscribable. */ get isSubscribable(): boolean; /** * Flag: whether the transfer supports a manual trigger via trigger(). * true if _triggerable !== undefined. */ get isTriggerable(): boolean; /** * Flag: whether the transfer supports flow control via gate. * true if _gate !== undefined. */ get isGate(): boolean; /** * Flag: whether the transfer supports async data push via asyncPush(). * Delegated from _input.isAsyncPushable. */ get isAsyncPushable(): boolean; /** * Flag: whether the transfer supports async data extraction via asyncPull(). * Delegated from _output.isAsyncPullable. */ get isAsyncPullable(): boolean; /** * Flag: whether the transfer supports async manual trigger via asyncTrigger(). * true if _asyncTriggerable !== undefined. */ get isAsyncTriggerable(): boolean; /** * Flag: whether the transfer can asynchronously poll another transfer. * Delegated from _input.isAsyncPollingProxy. */ get isAsyncPollingProxy(): boolean; /** * Extracts TriggerableInterface from the configuration. * Priorities: * 1. config.triggerable (explicit) * 2. config.input (if input.isTriggerable === true) * 3. config.output (if output.isTriggerable === true) * 4. undefined (if nothing found) */ private _extractTriggerable; /** * Extracts GateInterface from the configuration. * Priorities: * 1. config.gate (explicit) * 2. config.input (if input.isGate === true) * 3. config.output (if output.isGate === true) * 4. undefined (if nothing found) */ private _extractGate; /** * Extracts AsyncTriggerableInterface from the configuration. * Priorities: * 1. config.asyncTriggerable (explicit) * 2. config.input (if input.isAsyncTriggerable === true) * 3. config.output (if output.isAsyncTriggerable === true) * 4. undefined (if nothing found) */ private _extractAsyncTriggerable; } //# sourceMappingURL=transfers.d.ts.map