@typecad/typecad
Version:
🤖programmatically 💥create 🛰️hardware
72 lines (71 loc) • 2.14 kB
TypeScript
/**
* Registry for managing component UUIDs and reusing them across builds
*/
export declare class ComponentRegistry {
private static instance;
private components;
/**
* Get the number of components in the registry
*/
getComponentCount(): number;
/**
* Get the number of UUID to hash mappings in the registry
*/
getUuidToHashCount(): number;
private uuidToHash;
private cachePath;
private constructor();
/**
* Get the singleton instance of the registry
*/
static getInstance(): ComponentRegistry;
/**
* Load existing component registry from cache
*/
private loadFromCache;
/**
* Save the current registry to cache
*/
private saveToCache;
/**
* Generate a positional hash for PCB coordinates with tolerance
* This ensures components in roughly the same position get the same hash
* even with minor position adjustments
*/
private getPCBPositionHash;
/**
* Generate a unique hash for a component based on its properties
* Prioritizes stable properties that won't change between builds
* Avoids using reference designator which might change
*
* @param component The component to generate a hash for
* @returns A string hash representing the component's unique properties
*/
private getComponentHash;
/**
* Get or create a UUID for the given component
* Will reuse existing UUID if a similar component is found
*
* @param component The component to get a UUID for
* @returns A UUID string
*/
getUUID(component: any): string;
/**
* Find a component by UUID
* Useful for cross-referencing components
*
* @param uuid UUID to lookup
* @returns The component hash or undefined if not found
*/
findComponentHashByUUID(uuid: string): string | undefined;
/**
* Get all registered UUIDs
* @returns Array of UUIDs
*/
getAllUUIDs(): string[];
/**
* Clear the registry
* Use with caution as this will invalidate all component UUIDs
*/
clear(): void;
}