A JSXStructuralPath provides a deterministic way to identify a specific JSX element within a component tree. This is used to ensure that operations (like updates or deletions) target the correct element even if the file structure changes slightly.
It consists of:
componentName: The name of the function containing the element.filePath: The relative path to the source file.segments: An ordered array of JSXPathSegment objects representing the path from the component root to the target.
Each JSXPathSegment includes a name (tag or component name) and a discriminator to resolve ambiguity (e.g., via key, id, or index).
export interface JSXPathSegment {
name: string;
discriminator:
| { type: "key"; value: string }
| { type: "id"; value: string }
| { type: "index"; value: number }
| { type: "map-template" }
| { type: "root" };
classHint?: string[];
}
export interface JSXStructuralPath {
componentName: string;
filePath: string;
segments: JSXPathSegment[];
}