import { PlainObject, Some } from '@xh/hoist/core'; import type { StringInternSpec } from '../FetchService'; /** * Generational string-interning cache for a logical dataset, identified by an app-provided * key and shared across fetches of that dataset - see {@link FetchOptions.internStrings}. * * Values are deduplicated into an internal pending map spanning a whole response (all chunks * of an NDJSON stream), with lookups falling back to the previously committed values, so values * repeated across successive fetches share a single canonical string. Calling `commit()` * installs the pending values per the spec's `retainMode` - by default replacing the committed * set, bounding cache retention to the strings present in the latest completed response. See * {@link StringInternSpec.retainMode} for the 'always' and 'never' variants. * * The pending map is opened lazily by `intern()`. A response that fails or is abandoned before * commit should be `abort()`ed to discard its pending values - the previously committed * generation remains in place either way. * * @internal */ export declare class StringInterner { /** Latest spec provided for this key - adopted on each call, so settings may vary. */ get spec(): StringInternSpec; set spec(spec: StringInternSpec); private _spec; private excludeFields; private committed; private pending; private processed; private carried; private lastStats; constructor(spec: StringInternSpec); /** * Stats for the most recently committed cycle (i.e. response) - all zero if none committed: * - `processed` - total string values encountered. * - `retained` - distinct values in the committed response, with `retainedPct` of * processed. Lower percentage = more duplication removed. * - `carried` - retained values already present in the previous generation, with * `carriedPct` of retained. Higher percentage = more stability across refreshes. * * Introspect from the console via `XH.fetchService.getInternStats()`. */ get stats(): PlainObject; /** * Intern string values within the given data, mutating it in place. */ intern(data: Some): void; /** * Install pending values for reuse by later responses, per the spec's `retainMode`: * 'nextCall' (default) replaces the committed set, evicting values not re-seen; 'always' * merges into it; 'never' discards, leaving `committed` permanently empty so interning is * per-response only. */ commit(): void; /** Discard pending values without committing. No-op if already committed or aborted. */ abort(): void; private internRow; }