import type { DispatcherEvent, Dispose, MarkupPromiseEvent, MarkupRunEvent, MarkupValueEvent, PromiseOptions, ValueOptions } from "./types.js"; import type { ManagedRuntime as ManagedRuntimeType } from "effect/ManagedRuntime"; import { Effect, Layer } from "effect"; import { ComponentScope } from "./scope.js"; export { Code } from "./types.js"; export type { Dispose, PromiseOptions, ValueOptions } from "./types.js"; export declare class Dispatcher { #private; static make(layer?: Layer.Layer): Dispatcher; constructor(runtime?: ManagedRuntimeType); /** * Begin a component-owned Effect scope. Pass the returned scope to * {@link run_scoped} so the work is interrupted and finalized when the * component is destroyed. Disposal is idempotent. */ begin_scope(): ComponentScope; /** * Runs `fn` with `scope` as the current component scope. While active, * every effect path ({@link promise}, {@link run}, {@link value}) forks * its work into `scope` so disposing the scope interrupts it and runs its * finalizers. A disposed scope falls back to unscoped execution. */ with_scope(scope: ComponentScope, fn: () => T): T; /** * Forks an effect into a reactive-run scope and starts it. The run scope is * a child of the component scope, so rerun cleanup closes only that run * while component disposal remains a backstop. Returns an idempotent handle * that closes the run scope and all work forked into it. * * Throws {@link ScopeDisposedError} when the scope was already disposed * and {@link DispatcherDisposedError} when the dispatcher was shut down. */ run_scoped(scope: ComponentScope, effect: Effect.Effect): Dispose; /** * Disposes a component scope owned by this dispatcher, interrupting its * bound work and running its finalizers. Idempotent. Rejects scopes owned * by another dispatcher with {@link ScopeDisposedError}. */ dispose_scope(scope: ComponentScope): void; emit(event: MarkupValueEvent): A | F; emit(event: MarkupPromiseEvent): Promise; emit(event: MarkupRunEvent): Promise; emit(event: DispatcherEvent): A | F | Promise; fork(effect: Effect.Effect): Dispose; value(options: ValueOptions): A; promise(options: PromiseOptions): Promise; run(effect: Effect.Effect): Promise; dispose(): void; /** * Read-only snapshot of the value/promise cache keys. Diagnostic surface * for leak regression tests; not part of the runtime contract. */ inspect_cache(): { value_cells: readonly string[]; promise_values: readonly string[]; }; } export declare function get_dispatcher(): Dispatcher; export declare function reset_dispatcher(): void; /** * Lazily-created component scope used by generated component code. * * The holder is created synchronously during component init (before any * top-level `await`, where `onDestroy` is not yet available), and the scope * itself is materialized on first use. Disposal is registered separately * through `onDestroy` during component initialisation, so the scope is * reliably closed on unmount. * * @since 4.1.0 */ export declare class ComponentScopeRef { #private; constructor(get_dispatcher_fn: () => Dispatcher); /** The component scope, creating it on first access. */ get scope(): ComponentScope; /** Disposes the scope if it was created. Idempotent. */ dispose(): void; }