UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

59 lines 2.48 kB
import { type ImportsAndComments } from "../loaderUtils/index.mjs"; import { type SplitArguments } from "./parseFunctionArguments.mjs"; import type { Externals } from "../../CodeHighlighter/types.mjs"; /** * Parse options for create* factory call parsing */ export interface ParseOptions { /** * Only extract metadata (url + options), skipping variant-import resolution. * Treats the call as `create*(url, options?)`. Implies {@link ParseOptions.noVariants}. */ metadataOnly?: boolean; /** * The factory has no variants argument: its call shape is `create*(url, options?)` * (e.g. `createStream`), so the argument after `url` is the options * object rather than variants. Use this (with `replacePrecomputeValue`) to build * a precompute loader for a no-variants factory. Unlike `metadataOnly`, variant * resolution is simply not applicable rather than intentionally skipped. */ noVariants?: boolean; allowExternalVariants?: boolean; allowMultipleFactories?: boolean; } export interface FactoryOptions { name?: string; slug?: string; skipPrecompute?: boolean; precompute?: any; } export interface ParsedCreateFactory { functionName: string; url: string; variants: Record<string, string> | undefined; namedExports: Record<string, string | undefined> | undefined; options: FactoryOptions; fullMatch: string; hasOptions: boolean; externals: Externals; argumentsStartIndex: number; argumentsEndIndex: number; structuredUrl: string; structuredVariants: string | SplitArguments | Record<string, string> | undefined; structuredOptions?: Record<string, any>; hasGenerics: boolean; structuredGenerics?: Record<string, any>; remaining?: string; importsAndComments?: ImportsAndComments; } /** * Parses a file to extract a single create* factory call and its variants and options * Returns the parsed result with remaining content included * Returns null if no create* call is found */ export declare function parseCreateFactoryCall(code: string, filePath: string, parseOptions?: ParseOptions, importsAndComments?: ImportsAndComments): Promise<ParsedCreateFactory | null>; /** * Parses all create* factory calls in a file sequentially * Returns a record of export names mapped to their parsed factory calls */ export declare function parseAllCreateFactoryCalls(code: string, filePath: string, parseOptions?: Omit<ParseOptions, 'allowMultipleFactories'>): Promise<Record<string, ParsedCreateFactory>>;