/** * Concatenation Transform * * Transforms string concatenation operations (a + b) to safe function calls * (__safe_concat__(a, b)). This enables reference-aware concatenation that * can detect and properly handle reference IDs. * * @packageDocumentation */ import type * as acorn from 'acorn'; /** * Configuration for concatenation transformation */ export interface ConcatTransformConfig { /** * Prefix for safe functions * Default: '__safe_' */ prefix?: string; /** * Function name to use for concatenation * Default: 'concat' * Full name will be: prefix + functionName (e.g., '__safe_concat') */ functionName?: string; } /** * Result of concatenation transformation */ export interface ConcatTransformResult { /** * Number of binary expressions transformed */ transformedCount: number; } /** * Transform string concatenation to safe function calls * * This function mutates the AST in place, replacing `+` binary expressions * with calls to `__safe_concat__()`. This allows the runtime to detect * and handle reference IDs in concatenation operations. * * Note: This transforms ALL `+` operations, not just string concatenations. * The safe_concat function at runtime handles both string and numeric addition. * * @param ast - The AST to process (mutated in place) * @param config - Transformation configuration * @returns Information about transformed expressions * * @example * ```typescript * // Input: a + b + c * // Output: __safe_concat__(__safe_concat__(a, b), c) * * const result = transformConcatenation(ast, { prefix: '__safe_' }); * console.log(`Transformed ${result.transformedCount} concatenations`); * ``` */ export declare function transformConcatenation(ast: acorn.Node, config?: ConcatTransformConfig): ConcatTransformResult; /** * Transform template literals with expressions to safe template calls * * Transforms template literals like `Hello ${name}!` to * __safe_template__(['Hello ', '!'], name) * * This is optional and only needed if you want to intercept template * literal interpolation for reference detection. * * @param ast - The AST to process (mutated in place) * @param config - Transformation configuration * @returns Information about transformed templates */ export declare function transformTemplateLiterals(ast: acorn.Node, config?: ConcatTransformConfig): ConcatTransformResult;