/** * @typedef {Object} CompressNode * @property {string} text the symbol's source text (a chunk body) * @property {string} [format] "py" | "js" | "ts" | … — needed for `signature`/`drop` extraction * @property {string|null} [symbol] the chunk's symbol name, used for the `drop` marker when present */ /** * Render a node at the given fidelity. `signature` and `drop` need a parseable `format`; when a node * can't be parsed (markdown, a preamble chunk, a parse failure) `signature` falls back to verbatim * text — never throws, never returns less than the body asked for losslessly. * @param {CompressNode} node * @param {{ level?: "verbatim" | "signature" | "drop" }} [opts] * @returns {Promise} * @category CE * @when Render a code/doc unit at a chosen fidelity (verbatim / signature-only / dropped) to fit a budget. * @fails Never throws; an unparseable node (markdown, preamble, parse failure) falls back to verbatim rather than losing content. * @signature compress(node: CompressNode, opts?: { level? }) => Promise * @example * import { compress } from 'litectx' * const sig = await compress({ text: fnSource, format: 'js', symbol: 'parseConfig' }, { level: 'signature' }) */ export function compress(node: CompressNode, opts?: { level?: "verbatim" | "signature" | "drop"; }): Promise; /** The render fidelities, most → least detail. @type {readonly string[]} */ export const COMPRESS_LEVELS: readonly string[]; export type CompressNode = { /** * the symbol's source text (a chunk body) */ text: string; /** * "py" | "js" | "ts" | … — needed for `signature`/`drop` extraction */ format?: string | undefined; /** * the chunk's symbol name, used for the `drop` marker when present */ symbol?: string | null | undefined; };