feedbacker-react
Version:
A drop-in React feedback system for component-level feedback capture during development and design review
64 lines • 2.25 kB
TypeScript
/**
* Component Detection Strategy Chain Pattern
* Base class and chain management for component detection strategies
*/
import { ComponentInfo } from '../types';
/**
* Abstract base class for component detection strategies
*/
export declare abstract class DetectionStrategy {
protected next?: DetectionStrategy;
/**
* Set the next strategy in the chain
*/
setNext(strategy: DetectionStrategy): DetectionStrategy;
/**
* Handle component detection - implements chain of responsibility
*/
handle(element: HTMLElement): ComponentInfo | null;
/**
* Abstract method for component detection - must be implemented by subclasses
*/
protected abstract detect(element: HTMLElement): ComponentInfo | null;
/**
* Helper method to build component path from React fiber
*/
protected buildComponentPath(fiber: any): string[];
/**
* Helper method to build hybrid path (Components > HTML elements)
* Shows React components followed by DOM path to the selected element
*/
protected buildHybridPath(element: HTMLElement, _fiber: any): string[];
/**
* Check if a name is a valid React component (not a wrapper)
*/
private isValidReactComponent;
/**
* Helper method to extract props from React fiber (safely)
*/
protected extractProps(fiber: any): Record<string, any> | undefined;
/**
* Helper method to get React fiber from DOM element
*/
protected getReactFiber(element: HTMLElement): any;
/**
* Helper method to sanitize component name
*/
protected sanitizeComponentName(name: string): string;
}
/**
* Detection Strategy Chain Manager
* Sets up and manages the chain of detection strategies
*/
export declare class DetectionChain {
private firstStrategy?;
/**
* Build the complete detection chain
*/
buildChain(devToolsStrategy: DetectionStrategy, fiberStrategy: DetectionStrategy, heuristicStrategy: DetectionStrategy, fallbackStrategy: DetectionStrategy): DetectionStrategy;
/**
* Detect component using the complete strategy chain
*/
detectComponent(element: HTMLElement): ComponentInfo | null;
}
//# sourceMappingURL=DetectionStrategy.d.ts.map