mp-lens
Version:
微信小程序分析工具 (Unused Code, Dependencies, Visualization)
43 lines (42 loc) • 1.43 kB
TypeScript
/**
* Parser for WXML files that finds dependencies to other files using AST parsing.
*
* Path resolution rules for WeChat Mini Program WXML files:
* 1. Paths starting with '/' are relative to the mini program root
* Example: <import src="/templates/header.wxml" />
*
* 2. Paths starting with './' or '../' are relative to the current file's directory
* Example: <import src="../templates/header.wxml" />
*
* 3. Paths with no prefix (like "templates/header.wxml") should be treated as relative
* to the current file's directory, equivalent to adding a './' prefix.
* This parser automatically adds the './' prefix to follow Mini Program conventions.
*/
export declare class WXMLParser {
constructor();
parse(content: string, filePath: string): Promise<string[]>;
/**
* Processes import and include tags to extract template dependencies
*/
private processImportIncludeTags;
/**
* Processes wxs tags to extract WXS script dependencies
*/
private processWxsTags;
/**
* Processes image tags to extract image dependencies
*/
private processImageSources;
/**
* Recursively finds import and include tags in the AST
*/
private findImportIncludeTags;
/**
* Recursively finds wxs tags in the AST
*/
private findWxsTags;
/**
* Recursively finds image tags in the AST
*/
private findImageTags;
}