/** * effract — write React components as Effect programs. * * This is the **client-graph** entry (the `default` export condition). Whether a * component runs in a SPA, during SSR + hydration, or as a client island inside * an RSC page, it renders here through the in-render interpreter. A React Server * Component graph resolves the sibling `index.server` * entry instead (via the package's `react-server` condition) — so you import * `mount` from `@tmonier/effract` everywhere and the bundler picks where it runs. * * @packageDocumentation */ // --- the yield protocol --- export { hook, isHook, HookTypeId, isPlacement, placement, PlacementTypeId, suspend, query, scoped, isSuspensable, SuspensableTypeId, isAtom, AtomTypeId, } from '#domain/protocol.ts'; export type { AnyEffect, Hook, Suspensable, QueryOptions, CatchApi, Suspends, Volatile, Atom, ReadableAtom, Yieldable, RecBody, RecGenerator, RecHandle, RecPlacement, RequirementsOf, ErrorsOf, SuspendsOf, } from '#domain/protocol.ts'; // --- components --- // `rec` comes from the server-safe descriptor module directly — NOT via the // `'use client'` `react/rec.tsx` — so a server module importing `rec` is not // tagged as a client function by an RSC bundler. `mount` here is the client one. export { rec, RecTypeId } from '#infrastructure/rec-core.tsx'; export type { REC, CatchHandlers, MissingServices, LoadingNotHandled, VolatileNotHandled, MemoRequiresComparableProps, RendersOn, Effective, } from '#infrastructure/rec-core.tsx'; export { mount } from '#infrastructure/react/rec.tsx'; export type { MountOptions } from '#infrastructure/react/rec.tsx'; // Hydration has no client API: `mount` seeds the state the server embedded (via // `renderToStream` from `@tmonier/effract/ssr`) automatically. The only opt-in // is `atom.serializable(...)` — marking the state that may cross the wire. // --- the query cache as a service: invalidation + manual refetch (ADR 0008) --- export { QueryCache } from '#infrastructure/query-cache.ts'; // --- mutations in services: optimistic apply + typed-error rollback --- export { mutation } from '#infrastructure/mutation-core.ts'; export type { Mutation, MutationOptions, MutationState } from '#infrastructure/mutation-core.ts'; // --- devtools (dev-only, opt-in; tree-shakes away when unused) --- export { connectReduxDevtools, Inspector } from '#infrastructure/react/devtools.tsx'; export type { InspectorProps } from '#infrastructure/react/devtools.tsx'; // The dev render ledger (ADR 0007, decision 5): the last 200 renders with their // attributed cause, readable without mounting the Inspector. Empty in production. export { readRenderLedger } from '#infrastructure/devtools-core.ts'; export type { RenderEvent, RenderTrigger, TraceEntry } from '#infrastructure/devtools-core.ts'; // --- the runtime boundary (mount is canonical; Runtime is the low-level provider) --- export { Runtime, useEffractRuntime } from '#infrastructure/react/runtime.tsx'; export type { RuntimeProps } from '#infrastructure/react/runtime.tsx'; // --- reactivity --- // `atom` / `derive` / `atomFamily` / `batch` / `defer` are server-safe (a // service can hold and drive them; a deferred read is a plain read on the // server); the hooks that read them in a component are client-only, like // `hook` itself. export { atom, derive, atomFamily, batch, defer } from '#infrastructure/reactivity-core.ts'; export type { Read, AtomFamily, AtomFamilyOptions, AtomFamilyGc, AsyncDerived, SerializableAtom, } from '#infrastructure/reactivity-core.ts'; export { observe, Observe, useAtom, useAtomValue, useAtomSet, } from '#infrastructure/react/reactivity.tsx'; export type { ObserveProps } from '#infrastructure/react/reactivity.tsx';