import type * as otel from '@opentelemetry/api'; import { BoundArray } from '@livestore/common'; import type { Types } from '@livestore/utils/effect'; export declare const NOT_REFRESHED_YET: unique symbol; export type NOT_REFRESHED_YET = typeof NOT_REFRESHED_YET; export type GetAtom = (atom: Atom, otelContext?: otel.Context, debugRefreshReason?: TODO) => T; export type Ref = { _tag: 'ref'; id: string; isDirty: false; isDestroyed: boolean; previousResult: T; computeResult: () => T; sub: Set>; super: Set | Effect>; label?: string | undefined; /** Container for meta information (e.g. the LiveStore Store) */ meta?: unknown; equal: (a: T, b: T) => boolean; refreshes: number; }; export type Thunk = { _tag: 'thunk'; id: string; isDirty: boolean; isDestroyed: boolean; computeResult: (otelContext?: otel.Context, debugRefreshReason?: TDebugRefreshReason) => TResult; previousResult: TResult | NOT_REFRESHED_YET; sub: Set>; super: Set | Effect>; label?: string | undefined; /** Container for meta information (e.g. the LiveStore Store) */ meta?: unknown; equal: (a: TResult, b: TResult) => boolean; recomputations: number; __getResult: any; }; export type Atom = Ref | Thunk; export type Effect = { _tag: 'effect'; id: string; isDestroyed: boolean; doEffect: (otelContext?: otel.Context, debugRefreshReason?: TDebugRefreshReason) => void; sub: Set>; label?: string | undefined; invocations: number; }; export type Node = Atom | Effect; export declare const isThunk: (obj: unknown) => obj is Thunk; export type DebugThunkInfo = { _tag: T; durationMs: number; }; export type DebugRefreshReasonBase = /** Usually in response to some `commit` calls with `skipRefresh: true` */ { _tag: 'runDeferredEffects'; originalRefreshReasons?: ReadonlyArray | undefined; manualRefreshReason?: DebugRefreshReasonBase | undefined; } | { _tag: 'makeThunk'; label?: string | undefined; } | { _tag: 'unknown'; }; export type DebugRefreshReason = DebugRefreshReasonBase | { _tag: T; }; export type AtomDebugInfo = { atom: SerializedAtom; resultChanged: boolean; debugInfo: TDebugThunkInfo; }; export type RefreshDebugInfo = { /** Currently only used for easier handling in React (e.g. as key) */ id: string; reason: TDebugRefreshReason; refreshedAtoms: AtomDebugInfo[]; skippedRefresh: boolean; durationMs: number; /** Note we're using a regular `Date.now()` timestamp here as it's faster to produce and we don't need the fine accuracy */ completedTimestamp: number; graphSnapshot: ReactiveGraphSnapshot; }; export type EncodedOption = { _tag: 'Some'; value?: A | undefined; } | { _tag: 'None'; }; export type SerializedAtom = SerializedRef | SerializedThunk; export type SerializedRef = Readonly, '_tag' | 'id' | 'label' | 'meta' | 'isDirty' | 'isDestroyed' | 'refreshes'> & { /** Is `None` if `getSnapshot` was called with `includeResults: false` which is the default */ previousResult: EncodedOption; sub: ReadonlyArray; super: ReadonlyArray; }>>; export type SerializedThunk = Readonly, '_tag' | 'id' | 'label' | 'meta' | 'isDirty' | 'isDestroyed' | 'recomputations'> & { /** Is `None` if `getSnapshot` was called with `includeResults: false` which is the default */ previousResult: EncodedOption; sub: ReadonlyArray; super: ReadonlyArray; }>>; export type SerializedEffect = Readonly, '_tag' | 'id' | 'label' | 'invocations' | 'isDestroyed'> & { sub: ReadonlyArray; }>>; export type ReactiveGraphSnapshot = { readonly atoms: ReadonlyArray; readonly effects: ReadonlyArray; /** IDs of deferred effects */ readonly deferredEffects: ReadonlyArray; }; /** Used for testing */ export declare const __resetIds: () => void; export declare class ReactiveGraph void) => void) | undefined; } = {}> { id: string; readonly atoms: Set>; readonly effects: Set>; context: TContext | undefined; debugRefreshInfos: BoundArray>; private currentDebugRefresh; private deferredEffects; private refreshCallbacks; private nodeIdCounter; private uniqueNodeId; private refreshInfoIdCounter; private uniqueRefreshInfoId; makeRef(val: T, options?: { label?: string; meta?: unknown; equal?: (a: T, b: T) => boolean; }): Ref; makeThunk(getResult: (get: GetAtom, setDebugInfo: (debugInfo: TDebugThunkInfo) => void, ctx: TContext, otelContext: otel.Context | undefined, debugRefreshReason: TDebugRefreshReason | undefined) => T, options?: { label?: string; meta?: any; equal?: (a: T, b: T) => boolean; }): Thunk; destroyNode(node: Node): void; destroy(): void; makeEffect(doEffect: (get: GetAtom, otelContext: otel.Context | undefined, debugRefreshReason: DebugRefreshReason | undefined) => void, options?: { label?: string; }): Effect; setRef(ref: Ref, val: T, options?: { skipRefresh?: boolean; debugRefreshReason?: TDebugRefreshReason; otelContext?: otel.Context; }): void; setRefs(refs: [Ref, T][], options?: { skipRefresh?: boolean; debugRefreshReason?: TDebugRefreshReason; otelContext?: otel.Context; }): void; private runEffects; runDeferredEffects: (options?: { debugRefreshReason?: TDebugRefreshReason; otelContext?: otel.Context; }) => void; runRefreshCallbacks: () => void; addEdge(superComp: Thunk | Effect, subComp: Atom): void; removeEdge(superComp: Thunk | Effect, subComp: Atom): void; getSnapshot: (opts?: { includeResults: boolean; }) => ReactiveGraphSnapshot; subscribeToRefresh: (cb: () => void) => () => void; } export declare const throwContextNotSetError: (graph: ReactiveGraph) => never; //# sourceMappingURL=reactive.d.ts.map