UNPKG

mp-lens

Version:

微信小程序分析工具 (Unused Code, Dependencies, Visualization)

29 lines (28 loc) 1.38 kB
import { PathResolver } from '../../utils/path-resolver'; export interface WxmlPurgeAnalysisResult { wxmlFilePaths: Set<string>; tagNames: Set<string>; staticClassNames: Set<string>; dynamicClassValues: Set<string>; riskyDynamicClassPatterns: Array<{ filePath: string; expression: string; }>; } /** * Analyzes a WXML file and its imports/includes to extract tags, static classes, * and dynamic class expressions for PurgeCSS. * * @param initialWxmlFilePath Path to the initial WXML file to analyze * @param pathResolver Instance of PathResolver to resolve import/include paths * @param visited Set of already visited files (to prevent infinite loops and redundant work) * @returns Promise<WxmlPurgeAnalysisResult> */ export declare function analyzeWxmlForPurge(initialWxmlFilePath: string, pathResolver: PathResolver, visited?: Set<string>): Promise<WxmlPurgeAnalysisResult>; /** * Checks if a WXML class expression (the content inside {{...}}) is safe. * Safe: simple literals, or ternary operators yielding simple literals. * Unsafe: contains '+' for concatenation, unless it's part of a more complex, unhandled safe pattern. * @param expression The content of the class binding, e.g., "condition ? 'classA' : 'classB'" or "'prefix-' + varName" */ export declare function isSafeClassExpression(expression: string): boolean;