import { Observable } from "rxjs"; import type { KeyedSignal } from "./types.js"; /** * Backing implementation for {@link unstable_KeyedSignal}. Exposed for internal * tests (node lifecycle); consumers use the `.state()` factory. */ export declare class KeyedStore { /** Source of truth for present entries — non-reactive reads and iteration. */ private readonly _present; /** Reactive nodes, materialized lazily; a superset of observed keys only. */ private readonly _nodes; /** Bumped on add/remove — structural reactivity (values$). */ private readonly _structVersion$; /** Bumped on every change (incl. value replacement) — whole-snapshot reactivity. */ private readonly _anyVersion$; /** Memoized whole-collection snapshot, invalidated on any write. */ private _snapshot; readonly obs: Observable>>; constructor(initial?: Record | Iterable); get size(): number; /** Reactive whole-collection read: tracks any change, returns the snapshot. */ readAll(): Readonly>; get(key: string): V | undefined; get$(key: string): V | undefined; has(key: string): boolean; set(key: string, value: V): void; delete(key: string): boolean; clear(): void; values(): IterableIterator; /** Reactive whole-collection read: tracks structure only (add/remove). */ values$(): V[]; snapshot(): Readonly>; dispose(): void; private _ensureNode; /** * Deferred reap: scheduled when a node's last observer leaves AND when a * node is created (a tracker may record the dependency without ever * subscribing — see {@link _ensureNode}). A (re-)subscribe within the same * tick (e.g. a Computed swapping its dependencies, or an Effect that * subscribes synchronously during its tracked run) lands before this * fires; and a node whose key is still present is kept. Only a * gone-and-unobserved node is dropped. The defer also prevents a * flickering selector from thrashing. */ private _reap; } /** * @experimental A reactive keyed collection: `Map`-speed reads and O(1) writes, * with fine-grained per-key reactivity. Created via the signal-style factory: * * ```ts * // seed with initial data — a plain object, or pairs / a Map * const cart = unstable_KeyedSignal.state({ a: { qty: 1 } }); * cart.set("b", { qty: 2 }); * cart(); // reactive whole snapshot (wakes on ANY change) * cart.get$("a"); // reactive single key (wakes only when "a" changes) * cart.values$(); // reactive structure (wakes only on add/remove) * ``` * * Three orthogonal reactive surfaces — the callable (whole snapshot), {@link * KeyedSignal.get$ | get$} (one key) and {@link KeyedSignal.values$ | values$} * (structure). Per-key nodes are materialized lazily and reaped once their key * is gone and nobody observes them, so memory tracks the live/observed set * rather than every key ever touched; non-reactive reads allocate no node. */ export declare class unstable_KeyedSignal { static state(initial?: Record | Iterable): KeyedSignal; }