import type { BlockRegistry } from "./registry.js"; import type { BlockSpec, BlockAttrReader } from "./types.js"; /** * Registry-driven MDX serialize/parse, plus the shared encoder primitives that * are the round-trip contract. This module is React-free so the server MDX * adapter (`plan-mdx.ts`) and the agent schema export can import it. The encoder * + estree literal walker are kept BYTE-FOR-BYTE identical to the originals in * `plan-mdx.ts` — `plan-mdx.ts` re-imports them so nothing else there changes * and stored `.mdx` files round-trip the same. */ export declare function jsonExpression(value: unknown): string; export declare function escapeAttr(value: string): string; /** * Encode a single attribute. Returns "" (the attribute is dropped) for * undefined/null; a bare/`={false}` flag for booleans; `={n}` for numbers; a * quoted string when it matches the safe charset and is short, else a JSON * expression. Objects/arrays always serialize as a JSON expression. */ export declare function prop(name: string, value: unknown): string; /** Minimal MDX AST node shape (subset of the remark-mdx jsx element). */ export type MdxAttrNode = { type: string; name?: string; value?: string | null | MdxAttrExpression; }; type MdxAttrExpression = { type: string; value: string; data?: unknown; }; export type MdxJsxNode = { type: string; name?: string; attributes?: MdxAttrNode[]; children?: unknown[]; [key: string]: unknown; }; export declare function attributeValue(attr: MdxAttrNode | undefined): unknown; /** Build a {@link BlockAttrReader} bound to one parsed JSX node. */ export declare function createAttrReader(node: MdxJsxNode): BlockAttrReader; /** * Convert named MDX child code fences into block data fields. This keeps source * authoring normal Markdown/MDX while letting block specs opt into conventions * such as "```html" -> data.html and "```css" -> data.css. */ export declare function childCodeFenceFields(childNodes: unknown[], fieldsByLang: Record): Partial; /** * Serialize selected string data fields as named child code fences. Uses a fence * length that cannot be closed by the field body. */ export declare function serializeChildCodeFenceFields(data: TData, fieldsByLang: Record): string; /** The base-attribute + body shape every block carries. */ export interface SerializableBlock { id: string; title?: string; summary?: string; editable?: boolean; data: unknown; } /** Base block attributes parsed from a node, before the type-specific data. */ export interface ParsedBlockBase { id: string; title?: string; summary?: string; editable?: boolean; } /** * Serialize a block to its MDX element using its spec. Byte output MUST match * the legacy `serializeBlock` for every converted block: base attrs * (`id,title,summary,editable`) first, then the spec's `toAttrs` in insertion * order, then either nested children, prose children, or self-closing. */ export declare function serializeSpecBlock(spec: BlockSpec, block: SerializableBlock): string; /** * Parse one MDX JSX node into a block via the registry, if its tag is * registered. Returns `null` for unregistered tags so the caller can fall back * to its legacy parser. `base` is the already-extracted id/title/summary/ * editable; `children` is the stringified prose children. */ export declare function parseSpecBlock(registry: BlockRegistry, node: MdxJsxNode, base: ParsedBlockBase, children: string, idContext: string): { type: string; data: unknown; } | null; export {}; //# sourceMappingURL=mdx.d.ts.map