@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
63 lines • 2.91 kB
text/typescript
import type { ElementContent } from 'hast';
import type { LanguageCapabilities } from "./getLanguageCapabilities.mjs";
import type { ScanState } from "./scanState.mjs";
/**
* Process a text node for brace/JSX tracking and plain text property extraction.
* Returns an array of ElementContent nodes (possibly splitting the text node).
*/
export declare function processTextNode(text: string, state: ScanState, linkMap: Record<string, string>, linkProps: 'shallow' | 'deep' | undefined, linkParams: boolean | undefined, linkScope: boolean | undefined, linkValues: boolean | undefined, linkArrays: boolean | undefined, typePropRefComponent: string | undefined, lang: LanguageCapabilities, siblings: ElementContent[], siblingIndex: number): ElementContent[];
/**
* Converts a raw literal string (e.g., `'hello'`, `42`) into an expression token.
*/
export declare function tokenFromLiteral(value: string): {
kind: 'number' | 'string';
value: string;
};
/**
* Evaluates a list of expression tokens into a single value string.
* Supports:
* - Numeric arithmetic: `1 + 2` → `3`, `10 * 3` → `30`
* - String concatenation: `'a' + 'b'` → `'ab'`
* - Mixed string + number concat: `'item-' + 3` → `'item-3'`
* - Partial evaluation with variables: `'a' + 'b' + x + 'c'` → `'ab' + x + 'c'`
* where unresolved variables are kept and their type refs recorded.
*
* Returns null if the expression cannot be evaluated at all.
*/
export declare function evaluateExpression(tokens: Array<{
kind: 'number' | 'string' | 'operator' | 'variable';
value: string;
ref?: string;
}>): {
value: string;
refs?: Record<string, string>;
} | null;
/**
* Commits a pending literal candidate as a scope binding and clears it.
* Called at statement boundaries (`;`) and at the end of the top-level code block
* traversal (covers ASI / no-semicolon code).
*/
export declare function flushLiteralCandidate(state: ScanState): void;
/**
* Evaluates and commits a pending compound expression as a scope binding.
* Called at statement boundaries and at end of top-level traversal.
* Returns the evaluated result (for wrapping) or null if evaluation failed.
*/
export declare function flushPendingExpression(state: ScanState): {
value: string;
varName: string;
startChildIndex: number;
endChildIndex: number;
refs?: Record<string, string>;
targetChildren: ElementContent[] | null;
} | null;
/**
* Handles an open brace "{" in text, updating the scan state.
* Returns true if the brace was consumed by owner logic, false otherwise.
*/
export declare function handleOpenBrace(state: ScanState, linkMap: Record<string, string>, linkProps: 'shallow' | 'deep' | undefined): boolean;
/**
* Handles a close brace "}" in text, updating the scan state.
* Returns true if the brace was consumed by owner logic, false otherwise.
*/
export declare function handleCloseBrace(state: ScanState): boolean;