import * as Database from './Database'; /** * `JSON.stringify` replacer signature. * * Defined here (rather than re-imported from a UI package) so other ECHO-aware utilities can * share a stable signature without creating a dependency edge into the UI tree. */ export type JsonReplacer = (key: string, value: any) => any; export type CreateRefReplacerOptions = { db: Database.Database; /** How many ref hops to follow. `0` leaves all refs as-is. Default: `1`. */ depth?: number; }; /** * Returns a {@link JsonReplacer} that inlines ECHO ref objects (`{ "/": "echo:..." }`) up to * `depth` ref hops. Beyond that depth refs are left in their encoded form. * * Implemented as a per-call `JSON.stringify` replacer (not a one-shot tree walk at root) so it * composes with wrappers like `safeStringify` that intercept the root call. JSON.stringify * already drives the recursion; we only need to (a) detect a ref at the current callback, * (b) resolve and return the target if hop budget remains, and (c) tag the returned object * with its hop count so children know how far in they are. * * The hop count is tracked per-object via a `WeakMap`: a ref-resolved target's children inherit * `parentHops + 1`; a regular intermediate object's children inherit `parentHops`. This makes the * budget count *ref hops*, not tree depth — a ref deep in a tree still resolves once when * `depth >= 1`. * * Note: ECHO objects' `toJSON` runs before the replacer is invoked, so by the time we see a * value refs are already encoded as `{ "/": "dxn:..." }`. */ export declare const createRefReplacer: ({ db, depth }: CreateRefReplacerOptions) => JsonReplacer; //# sourceMappingURL=Json.d.ts.map