sicua
Version:
A tool for analyzing project structure and dependencies
105 lines (104 loc) • 3.8 kB
TypeScript
import * as t from "@babel/types";
import { PropReference, CodePosition, HTMLElementReference } from "../types";
/**
* Utility functions for component flow analysis
*/
/**
* Parses JSX props into prop references
*/
export declare function parseJSXProps(attributes: (t.JSXAttribute | t.JSXSpreadAttribute)[], sourceCode: string): PropReference[];
/**
* Extracts string representation of expressions
*/
export declare function extractExpressionString(expression: t.Expression, sourceCode: string): string;
/**
* Gets code position from node
*/
export declare function getCodePosition(node: t.Node): CodePosition;
/**
* Checks if a node contains JSX elements
*/
export declare function nodeContainsJSX(node: t.Node): boolean;
/**
* Extracts component references from various node types - ENHANCED VERSION
*/
export declare function extractComponentReferencesFromNode(node: t.Node, sourceCode: string): Array<{
name: string;
isJSXElement: boolean;
props: PropReference[];
position: CodePosition;
}>;
/**
* NEW: Extracts HTML element references from various node types
*/
export declare function extractHTMLElementReferencesFromNode(node: t.Node, sourceCode: string, includeTags?: string[], excludeTags?: string[], includeAll?: boolean): HTMLElementReference[];
/**
* NEW: Parses HTML element into HTMLElementReference
*/
export declare function parseHTMLElement(element: t.JSXElement, sourceCode: string, captureTextContent?: boolean, maxTextLength?: number): HTMLElementReference;
/**
* NEW: Extracts text content from JSX element
*/
export declare function extractTextContentFromJSX(element: t.JSXElement, sourceCode: string): string | undefined;
/**
* NEW: Determines if an HTML tag should be included based on filter criteria
*/
export declare function shouldIncludeHTMLTag(tagName: string, includeTags: string[], excludeTags: string[], includeAll: boolean): boolean;
/**
* Parses JSX element into component reference
*/
export declare function parseJSXElement(element: t.JSXElement, sourceCode: string): {
name: string;
isJSXElement: boolean;
props: PropReference[];
position: CodePosition;
};
/**
* Extracts component references from statements
*/
export declare function extractComponentReferencesFromStatement(statement: t.Statement, sourceCode: string): Array<{
name: string;
isJSXElement: boolean;
props: PropReference[];
position: CodePosition;
}>;
/**
* NEW: Extracts HTML element references from statements
*/
export declare function extractHTMLElementReferencesFromStatement(statement: t.Statement, sourceCode: string, includeTags?: string[], excludeTags?: string[], includeAll?: boolean): HTMLElementReference[];
/**
* Checks if a filename is a page file
*/
export declare function isPageFile(fileName: string): boolean;
/**
* Checks if a segment is dynamic ([param])
*/
export declare function isDynamicSegment(segment: string): boolean;
/**
* Checks if a segment is catch-all ([...param])
*/
export declare function isCatchAllSegment(segment: string): boolean;
/**
* Checks if a segment is a route group ((group))
*/
export declare function isRouteGroup(segment: string): boolean;
/**
* Parses route path into segments
*/
export declare function parseRoutePath(routePath: string): string[];
/**
* Simple pattern matching for route filtering
*/
export declare function matchesPattern(filePath: string, pattern: string): boolean;
/**
* Parses file content to AST
*/
export declare function parseFileToAST(content: string): t.File | null;
/**
* Extracts default export name from AST
*/
export declare function extractDefaultExportName(ast: t.File): string | null;
/**
* Checks if a component has multiple return statements
*/
export declare function checkMultipleReturns(ast: t.File): boolean;