import { ParseOptions, MDXLDDocument, StringifyOptions, MDXLDAst } from './types.js'; export { ExtractType, LDProperties, MDXLDAstNode, MDXLDAstNodeType, MDXLDData, MDXLDDocumentFull, MDXLDDocumentWithAST, MDXLDDocumentWithCode, TypedData, createTypedDocument, isOneOfTypes, isType } from './types.js'; /** * Parse MDXLD content into a document * * @param content - Raw MDXLD string content * @param options - Parse options * @returns Parsed MDXLD document * * @example * ```ts * const doc = parse(`--- * $id: https://example.com/doc * $type: Article * title: Hello World * --- * * # Hello World * `) * * // Expanded mode (default): * // { id: 'https://example.com/doc', type: 'Article', data: { title: 'Hello World' }, content: '# Hello World\n' } * * // Flat mode: * // { data: { $id: 'https://example.com/doc', $type: 'Article', title: 'Hello World' }, content: '# Hello World\n' } * ``` */ declare function parse(content: string, options?: ParseOptions): MDXLDDocument; /** * Stringify an MDXLD document back to string * * @param doc - MDXLD document to stringify * @param options - Stringify options * @returns String representation with YAML frontmatter and MDX content * * @example * ```ts * const content = stringify({ * id: 'https://example.com/doc', * type: 'Article', * data: { title: 'Hello World' }, * content: '# Hello World\n' * }) * * // Output: * // --- * // $id: https://example.com/doc * // $type: Article * // title: Hello World * // --- * // * // # Hello World * ``` */ declare function stringify(doc: MDXLDDocument, options?: StringifyOptions): string; /** * MDXLD Format Module * * Formats MDX files using Prettier with custom formatting for TypeScript type blocks. * Aligns trailing comments in type definitions to the widest property line. * * @packageDocumentation */ interface FormatOptions { /** Use Prettier for base formatting (default: true) */ prettier?: boolean; /** Prettier config file path */ prettierConfig?: string; /** Tab width for alignment (default: 2) */ tabWidth?: number; /** Minimum gap between code and comment (default: 2) */ minCommentGap?: number; /** Target column for comment alignment (default: auto-calculated) */ commentColumn?: number; } /** * Format MDXLD content * * @param content - Raw MDXLD string content * @param options - Format options * @returns Formatted content */ declare function format(content: string, options?: FormatOptions): Promise; /** * Format TypeScript type blocks with aligned comments * * Looks for code blocks with ```ts type or ```ts types and aligns trailing comments */ declare function formatTypeComments(content: string, options?: FormatOptions): string; /** * Format a single TypeScript type definition string * * Useful for formatting type definitions outside of MDX context * * @param typeCode - TypeScript type definition code * @param options - Format options * @returns Formatted type code with aligned comments */ declare function formatTypeDefinition(typeCode: string, options?: FormatOptions): string; /** * MDXLD Types Extraction * * Extract TypeScript type definitions from MDX code blocks marked with `ts type` or `ts types`. * Generates proper .d.ts files with exports. * * @packageDocumentation */ interface ExtractedType { name: string; kind: 'type' | 'interface'; exported: boolean; code: string; source?: string; } interface TypesExtractOptions { /** Add export to non-exported types (default: true) */ exportAll?: boolean; /** Include source file comments (default: true) */ includeSourceComments?: boolean; /** Header comment for generated file */ header?: string; } /** * Extract TypeScript types from MDX content */ declare function extractTypesFromContent(content: string, source?: string): ExtractedType[]; /** * Generate .d.ts content from extracted types */ declare function generateDtsFromTypes(types: ExtractedType[], options?: TypesExtractOptions): string; /** * Deduplicate types by name, keeping the last definition */ declare function deduplicateTypes(types: ExtractedType[]): ExtractedType[]; /** * Sort types to ensure dependencies come first (basic topological sort) */ declare function sortTypes(types: ExtractedType[]): ExtractedType[]; /** * Convert an MDXLD document to AST * * @param doc - MDXLD document * @returns AST representation */ declare function toAst(doc: MDXLDDocument): MDXLDAst; export { type ExtractedType, type FormatOptions, MDXLDAst, MDXLDDocument, ParseOptions, StringifyOptions, type TypesExtractOptions, deduplicateTypes, extractTypesFromContent, format, formatTypeComments, formatTypeDefinition, generateDtsFromTypes, parse, sortTypes, stringify, toAst };