import { Effect, Exit, Scope } from "effect";
import type { Fiber } from "effect";
/**
* A component-owned Effect scope.
*
* A `ComponentScope` wraps a `Scope.Closeable` forked from the dispatcher's
* root scope. Work is forked into the scope with `Effect.forkIn`, so closing
* the scope interrupts that work and runs its finalizers. The generated
* component teardown disposes the scope on destroy. Disposal is idempotent.
*
* @since 4.1.0
*/
export declare class ComponentScope {
#private;
private constructor();
/** Forks a child scope from the given root and returns it wrapped. */
static fork(root: Scope.Closeable, on_dispose: (scope: ComponentScope) => void): ComponentScope;
/** The underlying closeable scope used to bind Effect work. */
get underlying(): Scope.Closeable;
/** Whether this scope has already been disposed. */
get disposed(): boolean;
/**
* Forks an effect into this scope. The fiber becomes a child of the scope,
* so disposing the scope interrupts it and runs its finalizers. The scope
* is provided ambiently so `Effect.forkIn` registers the fiber as a child.
*/
fork_in(effect: Effect.Effect): Effect.Effect, never, R>;
/**
* Forks an effect into a child scope owned by one reactive run. The child
* remains open after setup completes so nested scoped work survives until
* that run is invalidated, while component disposal remains its backstop.
*/
fork_run_in(effect: Effect.Effect): {
readonly fork_effect: Effect.Effect, never, R>;
readonly close_effect: (exit: Exit.Exit) => Effect.Effect;
};
/** Effect that closes the scope. Must be run by the owning dispatcher. */
get close_effect(): Effect.Effect;
/**
* Marks the scope disposed and detaches it from the dispatcher. The caller
* is responsible for running {@link close_effect} to run finalizers.
* Idempotent.
*/
dispose(): void;
}