UNPKG

@lucidlayer/babel-plugin-traceform

Version:

Babel plugin to inject data-traceform-id attributes into React components for Traceform

27 lines (26 loc) 1.09 kB
/** * Creates a standardized Traceform ID. * Format: relativeFilePath::ComponentName::instanceIndex * * @param relativePath - The file path relative to the project root, using forward slashes. * @param componentName - The detected name of the React component. * @param instanceIndex - The index of the component instance (default is 0). * @returns The standardized Traceform ID string. */ export declare function createTraceformId(relativePath: string, componentName: string, instanceIndex?: number): string; /** * Parses a Traceform ID into its components. * @param id - The Traceform ID string to parse. * @returns An object containing the relative path, component name, and instance index. */ export declare function parseTraceformId(id: string): { relativePath: string; componentName: string; instanceIndex: number; }; /** * Utility to check if a string looks like a valid Traceform ID. * @param id - The string to check. * @returns True if the string appears to be a valid Traceform ID. */ export declare function isValidTraceformId(id: string): boolean;