@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
77 lines • 4.14 kB
text/typescript
import { type HighlightedTypesMeta, type HighlightedComponentTypeMeta, type HighlightedHookTypeMeta, type HighlightedFunctionTypeMeta, type HighlightedClassTypeMeta, type HighlightedMethod, type HighlightedRawTypeMeta, type HighlightedEnumMemberMeta, type HighlightedProperty, type HighlightedParameter, type HighlightedClassProperty } from "./highlightTypesMeta.mjs";
import { type SyncTypesOptions } from "../syncTypes/index.mjs";
import type { ExportData } from "../../abstractCreateTypes/index.mjs";
import type { TypesOutputFormat } from "./hastTypeUtils.mjs";
import type { TransformHtmlCodeBlockOptions } from "../transformHtmlCodeBlock/transformHtmlCodeBlock.mjs";
export type { HighlightedTypesMeta, HighlightedComponentTypeMeta, HighlightedHookTypeMeta, HighlightedFunctionTypeMeta, HighlightedClassTypeMeta, HighlightedMethod, HighlightedRawTypeMeta, HighlightedEnumMemberMeta, HighlightedProperty, HighlightedParameter, HighlightedClassProperty };
export type { SerializedHastRoot, SerializedHastCompressed, TypesOutputFormat } from "./hastTypeUtils.mjs";
export interface LoadServerTypesOptions extends SyncTypesOptions {
/**
* When true, calls syncTypes to extract types from TypeScript source,
* generate markdown, and write to disk before highlighting.
*
* When false, loads types from an existing types.md file using
* loadServerTypesText, skipping type extraction and markdown generation.
*
* @default false
*/
sync?: boolean;
/**
* Controls the output format for HAST nodes in the result.
*
* - `'hast'`: Live HAST Root objects (default)
* - `'hastJson'`: JSON-serialized `{ hastJson: string }` wrappers — defers
* tree allocation from module-evaluation time to render time
* - `'hastCompressed'`: Dictionary-compressed + base64-encoded `{ hastCompressed: string }`
* wrappers — smallest payload, decompressed with shared dictionary at render time
*
* @default 'hast'
*/
output?: TypesOutputFormat;
/** Options for code blocks highlighted inside generated type metadata */
codeBlockEmphasisOptions?: TransformHtmlCodeBlockOptions;
}
export interface LoadServerTypesResult {
/** Export data where each export has a main type and related additional types */
exports: Record<string, ExportData>;
/** Top-level non-namespaced types not claimed by any variant-only group */
additionalTypes: HighlightedTypesMeta[];
/**
* Types belonging to variant-only groups (variants with no main export).
* Keyed by variant name, containing the types from that variant.
*/
variantOnlyAdditionalTypes: Record<string, HighlightedTypesMeta[]>;
/**
* Maps variant names to the type names that originated from that variant.
* Used for namespace imports (e.g., `* as Types`) to filter additionalTypes
* to only show types from that specific module.
*/
variantTypeNames: Record<string, string[]>;
/** All dependencies that should be watched for changes */
allDependencies: string[];
/** Type name map from variant processing */
typeNameMap?: Record<string, string>;
/**
* Platform-scoped anchor maps for linking type references in code.
* Keys include both dotted names ("Accordion.Trigger") and flat names ("AccordionTrigger").
*/
anchorMap: {
js?: Record<string, string>;
css?: Record<string, string>;
};
}
/**
* Server-side function for loading and processing TypeScript types.
*
* This function:
* 1. Either syncs types from source (sync: true) or loads from existing types.md (sync: false)
* 2. Applies syntax highlighting to markdown content via highlightTypes
* 3. Highlights type fields with HAST via highlightTypesMeta
*
* The pipeline is:
* - sync: true: syncTypes extracts types, formats to plain text, generates markdown
* - sync: false: loadServerTypesText reads and parses an existing types.md file
* - highlightTypes: highlights markdown code blocks, builds highlightedExports map
* - highlightTypesMeta: converts type text to HAST, derives shortType/detailedType
*/
export declare function loadServerTypes(options: LoadServerTypesOptions): Promise<LoadServerTypesResult>;