import { Schematic } from "../schematic.js"; import { Pin } from "../pin.js"; /** * Length matching pattern configuration */ export interface ILengthMatchPatternConfig { type: 'sawtooth'; amplitude?: number; pitch?: number; } /** * Length matching configuration */ export interface ILengthMatchConfig { tolerance: number; pattern?: ILengthMatchPatternConfig; minStraightSegment?: number; maxIterations?: number; debug?: boolean; } /** * Options for creating a PCB instance. * Passed to the `new PCB()` constructor to configure board properties. */ export interface IPcbOptions { /** * Associated schematic. If not provided, a new Schematic is created * with the same board name. */ schematic?: Schematic; /** * If true (default), unmatched existing board elements are removed * during board generation. Set to false to preserve them. */ remove_orphans?: boolean; /** * Board thickness in mm. Defaults to 1.6mm (standard FR4). */ thickness?: number; /** * Copper plating thickness in microns. Defaults to 35μm (1 oz/ft²). */ copper_thickness?: number; } /** * Result of resolving a net assignment for a component pin or via. * Maps a component+pin combination to its KiCad net code and name. */ export interface INetResolution { /** Whether the net was found in the schematic */ found: boolean; /** The resolved net code to use in the PCB S-expression */ netCode: number; /** The resolved net name to use in the PCB S-expression */ netName: string; /** The original schematic net code (if found via schematic resolution) */ schematicNetCode?: number; /** The original schematic net name (if found via schematic resolution) */ schematicNetName?: string; } /** * Describes a plated through-hole via for layer transitions. * Used by `pcb.via()` and `TrackBuilder.via()` to create vias. */ export interface IVia { /** UUID for tracking. Auto-generated if omitted. */ uuid?: string; /** Net code assigned to the via. Resolved automatically via net name. */ netCode?: number; /** Net name to resolve the net code from. */ net?: string; /** Copper layers the via spans. Defaults to ["F.Cu", "B.Cu"]. */ layers?: string[]; /** XY position of the via center. */ at?: { x: number; y: number; }; /** Via annular ring diameter in mm. Defaults to 0.8mm. */ size?: number; /** Drill hole diameter in mm. Defaults to 0.4mm. */ drill?: number; /** Power characteristics for automatic via current capacity calculation. */ powerInfo?: IViaPowerInfo; } /** * Base interface for all graphical primitives on the PCB. */ export interface IGraphicPrimitive { /** Unique identifier for tracking and updating. */ uuid: string; /** KiCad layer name (e.g., "F.Cu", "B.SilkS", "Edge.Cuts"). */ layer: string; /** Line width in mm. */ strokeWidth: number; } /** * A straight line segment on the PCB (graphical or track). */ export interface IGrLine extends IGraphicPrimitive { type: 'line'; /** Start point coordinates in mm. */ start: { x: number; y: number; }; /** End point coordinates in mm. */ end: { x: number; y: number; }; /** If true, the line is locked against manual editing in KiCad. */ locked?: boolean; /** Net name for net-aware routing obstacle detection. */ net?: string; } /** * An arc segment on the PCB (used for rounded corners and curved traces). */ export interface IGrArc extends IGraphicPrimitive { type: 'arc'; /** Start point coordinates in mm. */ start: { x: number; y: number; }; /** Midpoint coordinates defining arc curvature. */ mid: { x: number; y: number; }; /** End point coordinates in mm. */ end: { x: number; y: number; }; } /** * A filled or outlined circle on the PCB. */ export interface IGrCircle extends IGraphicPrimitive { type: 'circle'; /** Center coordinates in mm. */ center: { x: number; y: number; }; /** Point on the circumference defining the radius (end = center + radius). */ end: { x: number; y: number; }; /** If true, the circle is filled solid. Otherwise outlined. */ fill?: boolean; /** If true, locked against manual editing in KiCad. */ locked?: boolean; } /** * A filled or outlined rectangle on the PCB. */ export interface IGrRect extends IGraphicPrimitive { type: 'rect'; /** Top-left corner coordinates in mm. */ start: { x: number; y: number; }; /** Bottom-right corner coordinates in mm. */ end: { x: number; y: number; }; /** If true, the rectangle is filled solid. Otherwise outlined. */ fill?: boolean; /** If true, locked against manual editing in KiCad. */ locked?: boolean; } /** * A filled or outlined polygon on the PCB. */ export interface IGrPoly extends IGraphicPrimitive { type: 'poly'; /** Ordered vertices of the polygon in mm. */ points: { x: number; y: number; }[]; /** If true, the polygon is filled solid. Otherwise outlined. */ fill?: boolean; /** If true, locked against manual editing in KiCad. */ locked?: boolean; } /** * Elements that can appear in outlines (board edge cuts and track segments). */ export type OutlineElement = IGrLine | IGrArc; /** * Source location information for tracking where PCB elements originate from. */ export interface ISourceInfo { /** Source file path. */ file: string; /** Line number in the source file. */ line: number; /** Column number (optional). */ column?: number; /** Variable name associated with the source. */ variable?: string; /** Whether the variable is assigned to this.X (class member). */ isThis?: boolean; /** Additional parameters from the call site. */ params?: Record; } /** * Describes a rectangular outline on the Edge.Cuts layer or a track group. * Outlines define the board shape boundary. Tracks use outlines internally * for grouping line segments into logical traces. */ export interface IOutline { /** UUID for the outline group. */ uuid: string; /** X coordinate of the start corner. */ x: number; /** Y coordinate of the start corner. */ y: number; /** Width of the rectangular outline in mm. */ width: number; /** Height of the rectangular outline in mm. */ height: number; /** Corner fillet radius (0 for sharp corners). */ filletRadius: number; /** Elements making up this outline (lines and arcs). */ elements: OutlineElement[]; /** Source location where this outline was created. */ sourceInfo?: ISourceInfo; } export interface IPowerInfo { current: number; maxTempRise?: number; thickness?: number; } export interface IViaPowerInfo { current: number; maxTempRise?: number; thickness?: number; } export interface IPinPowerInfo { minimum_voltage?: number; maximum_voltage?: number; current?: number; } export interface ITrackDetails { start: { x: number; y: number; }; end: { x: number; y: number; }; width: number; layer: string; locked: boolean; powerInfo?: IPowerInfo; } export interface IGeneratedElement { type: 'track' | 'via'; uuid: string; details: ITrackDetails | IVia; } export interface ITextPositioning { x: number; y: number; rotation?: number; layer?: string; width?: number; height?: number; fontSize?: number; thickness?: number; bold?: boolean; italic?: boolean; justify?: { horizontal?: 'left' | 'right' | 'center'; vertical?: 'top' | 'bottom' | 'middle'; mirror?: boolean; }; show?: boolean; } export interface IGrTextOptions { text: string; x: number; y: number; rotation?: number; layer?: string; font?: string; width?: number; height?: number; thickness?: number; bold?: boolean; italic?: boolean; justify?: { horizontal?: 'left' | 'right' | 'center'; vertical?: 'top' | 'bottom' | 'middle'; mirror?: boolean; }; hide?: boolean; uuid?: string; } export interface IZone { uuid: string; layers: string[]; x: number; y: number; width: number; height: number; polygon: { x: number; y: number; }[]; priority?: number; locked?: boolean; name?: string; } export interface IFilledZone extends IZone { net?: string; netCode?: number; netName?: string; fillMode?: 'solid' | 'hatched'; filled?: boolean; hatchStyle?: 'none' | 'edge' | 'full'; hatchPitch?: number; minThickness?: number; clearance?: number; connectPads?: 'thru_hole_only' | 'full' | 'no'; thermalGap?: number; thermalBridgeWidth?: number; smoothing?: 'chamfer' | 'fillet' | 'none'; smoothingRadius?: number; islandRemovalMode?: number; islandAreaMin?: number; hatchThickness?: number; hatchGap?: number; hatchOrientation?: number; hatchSmoothingLevel?: number; hatchSmoothingValue?: number; hatchBorderAlgorithm?: 'hatch_thickness' | 'min_thickness'; hatchMinHoleArea?: number; fillArcSegments?: number; filledAreasThickness?: boolean; } export interface IKeepoutZone extends IZone { restrictions?: { tracks?: boolean; vias?: boolean; pads?: boolean; copperpour?: boolean; footprints?: boolean; }; hatchStyle?: 'none' | 'edge' | 'full'; hatchPitch?: number; smoothing?: 'chamfer' | 'fillet' | 'none'; smoothingRadius?: number; } /** * Waypoint coordinate for autorouting hints. * Suggests points the autorouter should try to route through. */ export interface IAutorouteWaypoint { x: number; y: number; layer?: string; } /** * Forced via insertion directive for autorouting. * Specifies where to transition layers and which layer to continue on after the via. */ export interface IAutorouteVia { x: number; y: number; layer: string; } /** * Combined routing directives that can include waypoints and forced vias. */ export interface IRouteDirectives { waypoints?: IAutorouteWaypoint[]; vias?: IAutorouteVia[]; } /** * Impedance control specifications for controlled impedance routing. */ export interface IImpedanceConstraint { /** Target impedance in ohms */ target: number; /** Tolerance in ohms or percentage (if target is provided) */ tolerance: number; } /** * Identifier for a specific connection between two pins. * Used to exclude connections from autorouting or to specify manual routes. */ export interface IConnectionIdentifier { /** Source pin */ from: Pin; /** Destination pin */ to: Pin; } /** * Pre-specified manual route for a specific connection. * When provided, the autorouter will use this exact path instead of calculating one. */ export interface IManualRoute { /** * Source pin (optional if can be inferred from route endpoints and net pins) * If not provided, will attempt to match route start position to a pin in the net */ from?: Pin; /** * Destination pin (optional if can be inferred from route endpoints and net pins) * If not provided, will attempt to match route end position to a pin in the net */ to?: Pin; /** * The pre-defined route to use for this connection. * Can be: * - An IRoutePath object (low-level path with nodes) * - An IAutorouteResult from a previous autoroute() or route() call * (will use the first route's path) */ route: IRoutePath | IAutorouteResult; } /** * Options for the PCB autoroute functionality. * Autorouting automatically generates traces between specified pins. */ export interface IAutorouteOptions { /** Starting pin(s) for the route */ from: Pin | Pin[]; /** Destination pin(s) for the route */ to: Pin | Pin[]; /** Optional waypoints to hint the routing path */ waypoints?: IAutorouteWaypoint[]; /** * Optional forced vias that will be inserted along the route before continuing on the specified layer. * These behave similarly to waypoints but guarantee a layer change at the provided XY coordinate. */ vias?: IAutorouteVia[]; /** Impedance control settings for controlled impedance traces */ impedance?: IImpedanceConstraint; /** Restrict routing to specific copper layers (e.g., ['F.Cu', 'B.Cu']) */ layers?: string[]; /** * Select the routing algorithm to use (must be registered with RouterRegistry). * If omitted, the host will use the sole registered algorithm, or the first registered when multiple exist. */ algorithm?: string; /** * Maximum solver iterations per route. */ maxIterations?: number; /** * Cost penalty applied when using a via. * Higher values discourage vias; set allowVias=false to prohibit them. */ viaCost?: number; /** Cost penalty for changing direction (bend). */ bendCost?: number; /** Whether vias are allowed during autorouting. */ allowVias?: boolean; /** Trace width in mm */ width?: number; /** Enable debug console logging for routing operations */ debug?: boolean; /** Minimum clearance from other objects in mm */ clearance?: number; /** * Minimum edge-to-edge clearance for vias in mm. * Defaults to 0.2mm if omitted; used in addition to obstacle clearances when placing vias. */ viaClearance?: number; /** * Routing grid resolution in mm per cell. * If not provided, defaults to 0.1mm. */ gridResolution?: number; /** Heuristic weight (>1 speeds up, may be slightly suboptimal) */ heuristicWeight?: number; /** Number of parallel workers to use for MST edge routing (beta). Default: 1 (disabled) */ parallelMSTWorkers?: number; /** * Explicit net name for the route. * If not provided, the net is inferred from the pins. */ net?: string; /** Power information for trace width calculation */ powerInfo?: IPowerInfo; /** Lock the generated traces to prevent manual editing in KiCAD */ locked?: boolean; /** * Apply Steiner Minimum Tree optimization after initial routing. * Adds intermediate junction points to reduce total trace length. * Only applies to nets with 3+ connection points. * Default: true */ useSteinerOptimization?: boolean; /** * Pre-specified routes for connections. * Provide a list of previously generated routes (IAutorouteResult) or raw paths (IRoutePath). * The endpoints of each route will be inferred and matched to the current net's pins. */ routes?: (IRoutePath | IAutorouteResult)[]; /** * If true, TrackBuilders won't stage tracks immediately. * Used when creating routes that will be passed as manual routes. * @internal */ deferStaging?: boolean; /** * Connections to exclude from autorouting. * These pin pairs will be skipped and must be routed manually by the user. */ excludeConnections?: IConnectionIdentifier[]; /** * Length matching configuration for matched trace lengths */ lengthMatch?: ILengthMatchConfig; } /** * Result of a low-level routing operation. */ export interface IRoutePath { /** Ordered list of waypoints describing the routed path */ nodes: { x: number; y: number; layer: string; }[]; /** Optional grid coordinates for debugging/visualization */ gridNodes?: { gridX: number; gridY: number; layer: string; }[]; /** Total path length in mm */ length: number; /** Number of vias used */ viaCount: number; /** Whether routing succeeded */ success: boolean; /** Error description if routing failed */ error?: string; /** Optional sub-segments (e.g., for multi-hop routes) */ segments?: IRoutePath[]; } /** * Metadata for a single routed trace. */ export interface IRouteMetadata { /** Actual trace length in mm */ length: number; /** Number of vias used in this route */ viaCount: number; /** Layers used by this route */ layers: string[]; /** Whether this specific route succeeded */ success: boolean; /** Error message if route failed */ error?: string; /** The actual routing path (nodes and segments) */ path?: IRoutePath; } /** * Result of an autoroute operation. * This is an array of TrackBuilder objects with attached metadata. * Can be spread directly into pcb.create() or used to access routing details. */ export interface IAutorouteResult extends Array { /** Whether all routes were successful */ success: boolean; /** Total number of routes attempted */ routeCount: number; /** Number of successfully completed routes */ completedCount: number; /** Routing metadata for each trace */ routeDetails: IRouteMetadata[]; } /** * Route-only options for batch orchestration that exclude endpoints. * Used by autorouteBatch where from/to are provided separately. */ export type IAutorouteRouteOptions = Omit; export interface IPcbZoneOptions { pin?: Pin; net?: string; layers: string[]; x: number; y: number; width: number; height: number; fillMode?: 'solid' | 'hatched'; filled?: boolean; priority?: number; locked?: boolean; name?: string; minThickness?: number; hatchStyle?: 'none' | 'edge' | 'full'; hatchPitch?: number; clearance?: number; connectPads?: 'thru_hole_only' | 'full' | 'no'; thermalGap?: number; thermalBridgeWidth?: number; smoothing?: 'chamfer' | 'fillet' | 'none'; smoothingRadius?: number; islandRemovalMode?: number; islandAreaMin?: number; hatchThickness?: number; hatchGap?: number; hatchOrientation?: number; hatchSmoothingLevel?: number; hatchSmoothingValue?: number; hatchBorderAlgorithm?: 'hatch_thickness' | 'min_thickness'; hatchMinHoleArea?: number; fillArcSegments?: number; filledAreasThickness?: boolean; } export interface IPcbKeepoutOptions { layers: string[]; x: number; y: number; width: number; height: number; restrictions?: { tracks?: boolean; vias?: boolean; pads?: boolean; copperpour?: boolean; footprints?: boolean; }; priority?: number; locked?: boolean; name?: string; hatchStyle?: 'none' | 'edge' | 'full'; hatchPitch?: number; smoothing?: 'chamfer' | 'fillet' | 'none'; smoothingRadius?: number; } export interface IPcbLineOptions { start: { x: number; y: number; }; end: { x: number; y: number; }; layer?: string; width?: number; locked?: boolean; } export interface IPcbCircleOptions { center: { x: number; y: number; }; radius?: number; end?: { x: number; y: number; }; layer?: string; width?: number; fill?: boolean; locked?: boolean; } export interface IPcbRectOptions { x?: number; y?: number; width?: number; height?: number; start?: { x: number; y: number; }; end?: { x: number; y: number; }; layer?: string; strokeWidth?: number; fill?: boolean; locked?: boolean; } export interface IPcbPolyOptions { points: { x: number; y: number; }[]; layer?: string; width?: number; fill?: boolean; locked?: boolean; } //# sourceMappingURL=pcb_interfaces.d.ts.map