/** Callback for modifying value before setting watcher */ export type BeforeSetSignalWatcher = (options: SignalWatcherArguments) => { value: T; settable?: boolean } | undefined; /** Callback for actions after setting watcher */ export type AfterSetSignalWatcher = (options: SignalWatcherArguments) => void; export type OnGetSignalWatcher = (options: SignalWatcherArguments) => void; /** Available execution options for the watcher */ export type SignalWatcherExecutionOption = 'beforeSet' | 'afterSet' | 'onGet'; /** Options for configuring a signal watcher */ export interface SignalWatcherOptions { /** If true, watcher is executed immediately */ immediate?: boolean; /** Execution mode. */ execution?: SignalWatcherExecutionOption; } /** Arguments passed to signal watcher function */ export interface SignalWatcherArguments { /** New value */ newValue?: T; // New value being set /** Previously setted value */ oldValue?: T; } /** Function to stop watching a signal */ export type SignalUnwatch = () => void; /** Collection of categorized signal watcher functions */ export interface SignalWatchers { beforeSet: Set; afterSet: Set; onGet: Set; } export type SetSignalWatcher = (listener: BeforeSetSignalWatcher | AfterSetSignalWatcher | OnGetSignalWatcher, options?: SignalWatcherOptions) => SignalUnwatch; /** Represents a signal with a specific value and associated watchers. */ export declare class Signal { constructor(value: T); value: T; watchers: SignalWatchers; /** Adds a watcher function to the signal. */ watch: SetSignalWatcher; toString: () => string; valueOf: () => T; toJSON: () => T; } /** Creates a new Signal instance with the provided default value. */ export type signal = (defaultValue: T) => Signal; export interface SignalModule { signal: signal, Signal: Signal }