mp-lens
Version:
微信小程序分析工具 (Unused Code, Dependencies, Visualization)
25 lines (24 loc) • 1.1 kB
TypeScript
import type { ProjectStructure } from '../../analyzer/project-structure';
import type { TreeNodeData } from '../types';
/**
* Helper function to format bytes into human-readable form.
*/
export declare function formatBytes(bytes: number, decimals?: number): string;
/**
* Converts flat graph data (nodes and links) into a hierarchical tree structure
* with calculated statistics for each node.
*/
export declare function buildTreeWithStats(projectStructure: ProjectStructure): TreeNodeData | null;
/**
* Compute aggregated stats (fileCount, totalSize, sizeByType, etc.) for a node by traversing
* the full graph. If reachableModuleIds is provided, it will be used directly.
* Returns both stats and the set of reachable module IDs for reuse in views.
*/
export declare function computeAggregatedStatsForNode(projectStructure: ProjectStructure, nodeId: string, nodeType: string, reachableModuleIds?: Set<string>): {
moduleIds: Set<string>;
fileCount: number;
totalSize: number;
fileTypes: Record<string, number>;
sizeByType: Record<string, number>;
selfSize?: number;
};