import { A as Suspensable, B as query, C as RecBody, D as RequirementsOf, E as RecPlacement, F as isAtom, H as suspend, I as isHook, L as isPlacement, M as Volatile, N as Yieldable, O as Suspends, P as hook, R as isSuspensable, S as ReadableAtom, T as RecHandle, V as scoped, _ as ErrorsOf, a as MemoRequiresComparableProps, b as PlacementTypeId, c as RecTypeId, d as rec, f as AnyEffect, h as CatchApi, i as LoadingNotHandled, j as SuspensableTypeId, k as SuspendsOf, l as RendersOn, m as AtomTypeId, n as CatchHandlers, o as MissingServices, p as Atom, r as Effective, s as REC, t as QueryCache, u as VolatileNotHandled, v as Hook, w as RecGenerator, x as QueryOptions, y as HookTypeId, z as placement } from "./query-cache-sfUY26Qc.mjs";
import { a as Read, c as atomFamily, d as derive, f as Mutation, h as mutation, i as AtomFamilyOptions, l as batch, m as MutationState, n as AtomFamily, o as SerializableAtom, p as MutationOptions, r as AtomFamilyGc, s as atom, t as AsyncDerived, u as defer } from "./reactivity-core-Jf4T2qpz.mjs";
import { ReactNode } from "react";
import * as ManagedRuntime from "effect/ManagedRuntime";
import * as Layer from "effect/Layer";
//#region src/infrastructure/react/rec.d.ts
/** Options for the client `mount`. `loading` discharges the tree's loading obligation. */
interface MountOptions {
readonly loading?: ReactNode;
}
/**
* Mount a root REC under an Effect runtime — the **client** implementation of
* `mount`, selected everywhere except a React Server Component graph (where the
* sibling `../server/mount.ts` is chosen by the `react-server` condition). It is
* the boundary between effract and React: returns an ordinary React node and, at
* compile time, verifies that `layer` provides every service the REC's tree
* requires *and* that the tree's loading obligation is discharged — either by a
* `.suspense(...)` somewhere in it, or by passing `{ loading }` here — *and*
* that its volatility obligation is discharged (`defer(atom)` at the read, or
* `.hot()` on the component; there is deliberately no mount-level discharge for
* it). All checks live on the arguments, so there is no cast on the result.
*
* ```tsx
* createRoot(el).render(mount(AppLive, Dashboard.suspense()));
* // or
* createRoot(el).render(mount(AppLive, Dashboard, { loading: }));
* ```
*
* You import `mount` from `@tmonier/effract` in every file; where the module
* runs decides whether it renders interactively (here) or on the server.
*/
declare function mount(source: Layer.Layer | ManagedRuntime.ManagedRuntime, rec: REC, RE, R, S, V, L> & ([Effective] extends [ROut | QueryCache] ? unknown : MissingServices, ROut | QueryCache>>) & ([S] extends [never] ? unknown : LoadingNotHandled) & ([V] extends [never] ? unknown : VolatileNotHandled), options?: MountOptions): ReactNode;
declare function mount(source: Layer.Layer | ManagedRuntime.ManagedRuntime, rec: REC, RE, R, S, V, L> & ([Effective] extends [ROut | QueryCache] ? unknown : MissingServices, ROut | QueryCache>>) & ([V] extends [never] ? unknown : VolatileNotHandled), options: MountOptions & {
readonly loading: ReactNode;
}): ReactNode;
//#endregion
//#region src/infrastructure/react/devtools.d.ts
/**
* Bridge atom writes to the Redux DevTools extension. Returns a disconnect
* function. A no-op (returning a no-op disconnect) when the extension is absent —
* so it is safe to call unconditionally in development.
*/
declare const connectReduxDevtools: (options?: {
readonly name?: string;
}) => (() => void);
interface InspectorProps {
/** Poll interval (ms) for the query-store view. Default 500. */
readonly interval?: number;
}
declare const Inspector: ({
interval
}: InspectorProps) => ReactNode;
//#endregion
//#region src/infrastructure/devtools-core.d.ts
/** One yield a REC render processed, in order — the unit of the render trace (#55). */
interface TraceEntry {
readonly kind: 'effect' | 'atom' | 'query' | 'suspend' | 'hook' | 'child';
readonly label: string;
}
/**
* Why a REC rendered — the render ledger's attribution (ADR 0007, decision 5).
* One cause per render; when several changed at once a fixed priority picks the
* winner — **atom > query > props > hook > parent** — and within a kind the
* first changed yield (body order) wins, so attribution is deterministic.
*
* - `atom` — an atom the body reads changed value (label: the atom's name)
* - `query` — a `query`/`suspend` entry settled, refetched or was
* invalidated (label: the stringified key; `suspend` if keyless)
* - `props` — the placement's props changed (label: the changed key names)
* - `hook` — a lifted hook's value changed (label: the hook ordinal, `#n`)
* - `parent` — a re-render none of the above explains: the parent rendered
* (label: empty)
*/
interface RenderTrigger {
readonly kind: 'atom' | 'query' | 'props' | 'hook' | 'parent';
readonly label: string;
}
/**
* A REC render: what it yielded, and (if known) what triggered it — the render
* trace that makes "why did this re-render, and what does it depend on"
* visible, so React render behaviour is debuggable (#55).
*/
interface RenderEvent {
readonly kind: 'render';
/** The REC's display name. */
readonly rec: string;
/** A stable per-instance id, so repeated renders of one instance group together. */
readonly instanceId: string;
readonly yields: ReadonlyArray;
/** The attributed cause of this render, if it could be determined. */
readonly trigger?: RenderTrigger;
}
/**
* Read the dev render ledger: the last 200 renders (oldest first), each with
* its yields and — when attributable — the {@link RenderTrigger} that caused
* it. Populated in development builds whether or not an inspector is
* connected, so a test or a REPL can ask "why did this render?" without
* mounting ``. Always empty in production.
*/
declare const readRenderLedger: () => ReadonlyArray;
//#endregion
//#region src/infrastructure/react/runtime.d.ts
type AnyManagedRuntime = ManagedRuntime.ManagedRuntime;
interface RuntimeProps {
/**
* A self-contained layer providing the subtree's services. Its one permitted
* open requirement is {@link QueryCache}, which the boundary itself provides —
* so a service may `yield* QueryCache` in its `make`.
*/
readonly layer?: Layer.Layer;
/**
* A pre-built `ManagedRuntime` to use instead of building one from a `layer`
* (share one runtime across mounts / with non-React code). effract does **not**
* dispose an injected runtime — you own its lifecycle. Built outside effract,
* it does not get a `QueryCache` merged in: build with the `layer` form if
* your services use the cache.
*/
readonly runtime?: ManagedRuntime.ManagedRuntime;
readonly children?: ReactNode;
}
/**
* Provide an Effect runtime to a React subtree. Prefer `mount(layer, Root)`,
* which wraps the root REC in this provider and checks the tree's services at
* compile time. Reach for `Runtime` directly only to wrap non-REC React trees.
*/
declare function Runtime({
layer,
runtime: injected,
children
}: RuntimeProps): ReactNode;
/** Escape hatch: the underlying `ManagedRuntime`, for imperative `runPromise`/`runFork`. */
declare const useEffractRuntime: () => AnyManagedRuntime;
//#endregion
//#region src/infrastructure/react/reactivity.d.ts
/**
* Subscribe a component to an inline derived view over one or more atoms. Re-renders
* precisely when a read atom changes. This is the escape hatch for an ad-hoc reactive
* expression in a component; prefer reading a single atom with {@link useAtomValue}
* (or `yield*` in a REC), and deriving shared values with `atom.derive` / `derive` in
* a service. `` is the same thing, inline in JSX.
*
* ```tsx
* const doubled = observe(($) => $(count) * 2);
* ```
*/
declare const observe: (selector: (read: Read) => A) => A;
/**
* Read a single atom's value, subscribing the component to it. A `defer(a)`
* wrapper is read through `useDeferredValue`, so the deferred semantics hold in
* the hooks world too — the value lags urgent work instead of storming it.
*/
declare const useAtomValue: (atomRead: ReadableAtom) => A;
/** A stable setter for a writable atom, supporting both values and updater functions. */
declare const useAtomSet: (atomWrite: Atom) => ((value: A | ((prev: A) => A)) => void);
/** Read and write a single atom — the `useState` shape, backed by Effect. */
declare const useAtom: (atomWrite: Atom) => readonly [A, (value: A | ((prev: A) => A)) => void];
interface ObserveProps {
readonly children: (read: Read) => A;
}
/** The render-prop form of {@link observe}, for inline reactive values in JSX. */
declare const Observe: ({
children
}: ObserveProps) => ReactNode;
//#endregion
export { type AnyEffect, type AsyncDerived, type Atom, type AtomFamily, type AtomFamilyGc, type AtomFamilyOptions, AtomTypeId, type CatchApi, type CatchHandlers, type Effective, type ErrorsOf, type Hook, HookTypeId, Inspector, type InspectorProps, type LoadingNotHandled, type MemoRequiresComparableProps, type MissingServices, type MountOptions, type Mutation, type MutationOptions, type MutationState, Observe, type ObserveProps, PlacementTypeId, QueryCache, type QueryOptions, type REC, type Read, type ReadableAtom, type RecBody, type RecGenerator, type RecHandle, type RecPlacement, RecTypeId, type RenderEvent, type RenderTrigger, type RendersOn, type RequirementsOf, Runtime, type RuntimeProps, type SerializableAtom, type Suspends, type SuspendsOf, type Suspensable, SuspensableTypeId, type TraceEntry, type Volatile, type VolatileNotHandled, type Yieldable, atom, atomFamily, batch, connectReduxDevtools, defer, derive, hook, isAtom, isHook, isPlacement, isSuspensable, mount, mutation, observe, placement, query, readRenderLedger, rec, scoped, suspend, useAtom, useAtomSet, useAtomValue, useEffractRuntime };