import { JSXElementType, JSXElement, Props } from '../elements.js'; import '../jsx-globals.js'; /** A gating condition for lifecycle primitives like {@link timer}; `true` means active. */ type ActivityPredicate = () => boolean; /** Options for {@link timer}. */ interface TimerOptions { when?: ActivityPredicate | readonly ActivityPredicate[]; } /** {@link ActivityPredicate} that is true while the current route matches `pathOrPaths`. */ declare function routeActive( pathOrPaths: string | readonly string[] ): ActivityPredicate; /** {@link ActivityPredicate} that is true while the document is visible. */ declare function documentVisible(): ActivityPredicate; /** {@link ActivityPredicate} that is true while the window has focus. */ declare function windowFocused(): ActivityPredicate; /** An event target, or a function resolving one, accepted by {@link on}. */ type ListenerTarget = EventTarget | (() => EventTarget | null | undefined); type ListenerOptions = boolean | AddEventListenerOptions | undefined; /** Attach an owned event listener to `target` for the current component's lifetime. */ declare function on( target: ListenerTarget, event: string, handler: EventListener, options?: ListenerOptions ): void; /** Run `fn` on an owned interval for the current component's lifetime, optionally gated by `options.when`. */ declare function timer( intervalMs: number, fn: () => void, options?: TimerOptions ): void; /** Runs an owned task after commit. */ declare function task( fn: () => void | (() => void) | PromiseLike void)> ): void; /** A callable reactive source accepted by {@link watch}. */ type WatchSource = () => T; /** Values inferred from an ordered tuple of {@link WatchSource} accessors. */ type WatchValues[]> = { -readonly [TIndex in keyof TSources]: ReturnType; }; /** Post-commit generation details supplied to a {@link watch} callback. */ interface WatchContext { readonly initial: boolean; readonly previous: TValue | undefined; readonly signal: AbortSignal; } /** Owned side-effect callback invoked by {@link watch}. */ type WatchCallback = ( value: TValue, context: WatchContext ) => void | (() => void) | PromiseLike; /** Observe one readable source after commit and whenever its value changes. */ declare function watch( source: WatchSource, callback: WatchCallback ): void; /** Observe an ordered tuple of readable sources after commit and whenever an entry changes. */ declare function watch[]>( sources: TSources extends WatchSource ? never : TSources, callback: WatchCallback> ): void; /** * Capture the result of a synchronous expression at call time and return a * thunk that returns the captured value later. This is a low-level helper for * cases where async continuations need to observe a snapshot of values at the * moment scheduling occurred. * * Usage (public API): * const snapshot = capture(() => someState()); * Promise.resolve().then(() => { use(snapshot()); }); */ declare function capture(fn: () => T): () => T; export { ActivityPredicate, TimerOptions, routeActive, documentVisible, windowFocused, ListenerTarget, ListenerOptions, on, timer, task, WatchSource, WatchValues, WatchContext, WatchCallback, watch, capture, };