UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

125 lines 5.39 kB
import { type ClassTypeMeta as ClassType } from "./formatClass.mjs"; import { type ComponentTypeMeta as ComponentType } from "./formatComponent.mjs"; import { type HookTypeMeta as HookType } from "./formatHook.mjs"; import { type FunctionTypeMeta as FunctionType } from "./formatFunction.mjs"; import { type RawTypeMeta as RawType, type ReExportInfo } from "./formatRaw.mjs"; import { type FormattedProperty, type FormattedEnumMember, type FormattedParameter, type FormatInlineTypeOptions, type DescriptionReplacement } from "./format.mjs"; import type { OrderingConfig } from "../loadServerTypesText/order.mjs"; import { type OrganizeTypesResult } from "../loadServerTypesText/organizeTypesByExport.mjs"; export type ClassTypeMeta = ClassType; export type ComponentTypeMeta = ComponentType; export type HookTypeMeta = HookType; export type FunctionTypeMeta = FunctionType; export type RawTypeMeta = RawType; export type { FormatInlineTypeOptions, FormattedProperty, FormattedEnumMember, FormattedParameter, ReExportInfo, DescriptionReplacement }; export type TypesMeta = { type: 'class'; name: string; slug?: string; /** Alternative names this type can be looked up by (e.g., flat export name like "AccordionRootState") */ aliases?: string[]; data: ClassTypeMeta; } | { type: 'component'; name: string; slug?: string; /** Alternative names this type can be looked up by (e.g., flat export name like "AccordionRootProps") */ aliases?: string[]; data: ComponentTypeMeta; } | { type: 'hook'; name: string; slug?: string; /** Alternative names this type can be looked up by */ aliases?: string[]; data: HookTypeMeta; } | { type: 'function'; name: string; slug?: string; /** Alternative names this type can be looked up by */ aliases?: string[]; data: FunctionTypeMeta; } | { type: 'raw'; name: string; slug?: string; /** Alternative names this type can be looked up by (e.g., flat export name like "AccordionRootState") */ aliases?: string[]; data: RawTypeMeta; }; export interface LoadServerTypesMetaOptions { /** Absolute path to the types.md file (used for deriving paths) */ typesMarkdownPath: string; /** Root context directory (workspace root) */ rootContext: string; /** * Map of variant name to file path (relative or package path). * Each variant is an entrypoint whose types are extracted independently then merged. * For single component: `{ Default: '@base-ui/react/checkbox' }` * For multiple: `{ Checkbox: '@base-ui/react/checkbox', Button: '@base-ui/react/button' }` */ variants?: Record<string, string>; /** * When true, resolves library paths to their source files for watching. * Useful during development to watch the original source rather than built files. */ watchSourceDirectly?: boolean; /** Options for formatting types in tables */ formattingOptions?: FormatInlineTypeOptions; /** * Directory path for socket and lock files used for IPC between workers. * Useful for Windows where the default temp directory may not support Unix domain sockets. */ socketDir?: string; /** * Optional regex pattern string to filter which external types to include. * External types are named union types (like `Orientation = 'horizontal' | 'vertical'`) * that are referenced in props but not exported from the component's module. * * When not provided, ALL qualifying named union types (unions of literals) will be * collected automatically. This is the recommended behavior for most projects. * * When provided, only external types whose names match this pattern will be collected. * * @example undefined // Collect all qualifying external types (recommended) * @example '^(Orientation|Alignment|Side)$' // Only include specific types */ externalTypesPattern?: string; /** Custom ordering configuration for sorting props, data attributes, exports, etc. */ ordering?: OrderingConfig; /** * Pattern/replacement pairs to apply to JSDoc descriptions. * Each entry has a `pattern` (regex string) and `replacement` string. */ descriptionReplacements?: DescriptionReplacement[]; } export interface LoadServerTypesMetaResult extends OrganizeTypesResult<TypesMeta> { /** All dependencies that should be watched for changes */ allDependencies: string[]; /** Type name map from variant processing */ typeNameMap?: Record<string, string>; /** * External types discovered during formatting. * These are types referenced in props/params that are not publicly exported, * but whose definitions are useful for documentation (e.g., union types). * Map from type name to its definition string. */ externalTypes: Record<string, string>; /** Resource name derived from the types path */ resourceName: string; } /** * Loads and formats TypeScript types from source files. * * This function handles: * - Loading TypeScript configuration * - Resolving library source files and variants * - Finding meta files (DataAttributes, CssVars) * - Processing types via worker thread * - Formatting component, hook, function, and raw types * - Collecting external types referenced in props/params * * The result can be used by syncTypes for markdown generation or by other consumers. */ export declare function loadServerTypesMeta(options: LoadServerTypesMetaOptions): Promise<LoadServerTypesMetaResult>;