UNPKG

mp-lens

Version:

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

22 lines (21 loc) 1.05 kB
/** * Normalizes a given absolute path by removing the file extension and any trailing '/index'. * This creates a canonical base path for a component or page. * e.g., /path/to/comp/index.wxml -> /path/to/comp * e.g., /path/to/page.json -> /path/to/page * @param absolutePath The absolute file path. * @returns The canonical absolute base path. */ export declare function getCanonicalBasePath(absolutePath: string): string; /** * Generates a canonical node ID and label from a file's absolute path. * The ID is prefixed and relative to the miniapp root, ensuring uniqueness and consistency. * @param type The type of the node ('Page' or 'Component'). * @param absolutePath The absolute path to one of the entity's files (e.g., .wxml, .json). * @param miniappRoot The absolute path to the miniapp root directory. * @returns An object containing the canonical id and label. */ export declare function generateNodeIdAndLabel(type: 'Page' | 'Component', absolutePath: string, miniappRoot: string): { id: string; label: string; };