/** * @file `bake` — write a derived value back into the source text. * * A directive carries a value a machine derives and a human reads * (directives.js). Baking materializes the current value INTO the * committed file, which is the whole point: the document needs no * runtime, GitHub renders it correctly, and the next re-derivation shows * up as a diff a reviewer can look at instead of a number that quietly * stopped being true. * * Two properties make it usable on documents people wrote by hand: * * - **byte-local.** Only the spans between markers change. `toMarkdown` * is a canonicalizing printer, so re-printing a README would reflow * every list and re-wrap every table — correct markdown, and a diff * nobody can review. So `bake` splices the SOURCE, and a document * with no directives comes back the same bytes it went in as. * - **idempotent.** Baking an already-baked document changes nothing, * which is what lets a `--check` mode be "bake and compare". * * The trust level is different from mdx's, and the difference is the * point: an mdx interpolation lands in a TEXT node and is never re-read * as markdown, because it may carry untrusted data. A baked body is * spliced into the source and WILL be re-parsed as markdown — a fact * that is a whole table is exactly the use case. `bake` is therefore a * build-time tool for input you control, and it says so here rather than * leaving the two to be confused. */ export type BakeResult = { text: string; changed: boolean; diagnostics: string[]; applied: { key: string; from: string; to: string; }[]; }; /** * @typedef {{ text: string, changed: boolean, diagnostics: string[], * applied: { key: string, from: string, to: string }[] }} BakeResult */ /** * Replace every directive body in `source` with a freshly resolved * value. * * `resolve(key, directive)` returns the text to place between the * markers, or `undefined` to leave that directive untouched. Throwing is * allowed and is reported as a diagnostic — one bad derivation must not * cost the rest of the document. * * @param {string} source the document text * @param {{ ns: string, resolve: (key: string, directive: any) => (string|undefined), * parseOptions?: any }} options * @returns {BakeResult} */ export declare function bake(source: string, options: { ns: string; resolve: (key: string, directive: any) => (string | undefined); parseOptions?: any; }): BakeResult;