import type { WatchSource, WatchCallback, WatchOptions, WatchHandle } from './types'; /** * Deeply subscribe the active effect to every object reachable from `value`. * * The whole traversal runs over RAW objects and touches the proxy exactly once * per object, to subscribe. Two measurements shaped it: * * - `Object.keys()` on a reactive proxy costs ~165x what it costs on the raw * object (2036ns vs 12.3ns for a three-key object). V8 validates the * `ownKeys` trap's result against the target's own property descriptors on * every call — that is the proxy protocol, not the trap body, and on a * 200-row fixture it was ~68% of a deep-watch turn (#641). * - Reading each value back through the `get` trap to reach its per-key dep * cost ~50ns a key, ~1200 keys, and produced ~1600 subscriptions where 402 * would do (#644). * * So neither happens now. `trackAnyWrite` subscribes to one dep covering every * write to an object — any key, new keys, deletions, Map/Set mutations — and * the recursion descends through the raw values, resolving each child's proxy * directly rather than by reading it out of its parent. * * The child proxy must still be MATERIALISED (not merely looked up): a write * always goes through a proxy, so an object we never proxied is an object whose * writes we would never see. * * Exported from `@sigx/reactivity/internals` as `deepTrack` (#651). `watch` is * not the only caller that needs a deep dirty signal, and the other one — * `@sigx/actors`, which parks the effect's re-run and folds it at a turn * boundary rather than re-walking per mutation — needs a `scheduler`, which * `WatchOptions` does not offer. Without a seam it carried a copy of this * function instead, and that copy sat on the pre-#642 algorithm while this one * moved twice: it enumerated the proxy AND read every key back. Exporting the * traversal rather than the `trackAnyWrite` leaf is deliberate — a caller given * only the leaf must re-derive `descend`, `shouldNotProxy` and the `signal()` * materialisation, all load-bearing and none of them exported, and would be * free to disagree with `watch(deep)` about what counts as a change all over * again. * * @param value The value to traverse. Subscribing needs a reactive proxy — a * plain object has no deps to subscribe to, so passing one walks the shape * and tracks nothing. That is what enumerating it used to do too. * @param depth Maximum depth (Infinity for unlimited, number for limited) * @param seen Raw objects already visited, to terminate on cycles * @internal */ export declare function traverse(value: unknown, depth?: number, seen?: Set): unknown; /** * Watch a reactive source and run a callback when it changes. * Supports deep watching, immediate invocation, and pause/resume. * * @example * ```ts * const count = signal(0); * const handle = watch(() => count.value, (newVal, oldVal) => { * console.log(`${oldVal} → ${newVal}`); * }); * handle.stop(); // stop watching * ``` */ export declare function watch(source: WatchSource, cb: WatchCallback, options?: WatchOptions): WatchHandle; //# sourceMappingURL=watch.d.ts.map