/** * Generic wire-stub generator for schematic workflow templates. * * The NE555 template was the first workflow to include visible wire stubs, but * they were hand-coded with hardcoded pixel offsets. This module provides a * reusable, data-driven generator that any template can call: supply the * anchor, a list of component pin descriptors (position relative to anchor, * direction, net), and it produces the `WorkflowWireInput[]` array the * planner expects. * * Stubs are always axis-aligned (horizontal or vertical) per EasyEDA's * constraint that diagonal wires are rejected. * * @module */ import type { WorkflowWireInput } from './types.js'; /** Which direction the wire stub extends from the pin. */ export type StubDirection = 'left' | 'right' | 'up' | 'down'; /** One pin on a placed component that needs a visible wire stub. */ export interface PinStubDescriptor { /** Component reference designator (for the wire's role label). */ ref: string; /** Pin number / identifier (for the wire's role label). */ pin: string; /** Net name the stub belongs to. */ netName: string; /** Pin's absolute X position on the schematic canvas. */ x: number; /** Pin's absolute Y position on the schematic canvas. */ y: number; /** Direction the wire stub extends from the pin (default: 'right'). */ direction?: StubDirection; /** Stub length in schematic units (default: 18). */ length?: number; } /** Configuration for the generic wire-stub generator. */ export interface WireStubGeneratorOptions { /** Default stub length when not specified per-pin. */ defaultLength?: number; /** Default wire line width (default: 1). */ lineWidth?: number; } /** * Generate wire stubs from a set of pin descriptors. * * Each descriptor produces exactly one `WorkflowWireInput` — a two-point * axis-aligned wire segment that starts at the pin coordinate and extends * in the specified direction. * * @param pins Array of pin stub descriptors (position, direction, net). * @param options Optional configuration overrides. * @returns An array of workflow wire inputs ready for the planner. */ export declare function generateWireStubs(pins: readonly PinStubDescriptor[], options?: WireStubGeneratorOptions): WorkflowWireInput[]; /** Pin descriptor relative to a component's placement offset from anchor. */ export interface RelativePinStub { /** Pin number / identifier. */ pin: string; /** Net name the stub belongs to. */ netName: string; /** Pin X relative to the component's placement position. */ dx: number; /** Pin Y relative to the component's placement position. */ dy: number; /** Stub direction (default: 'right'). */ direction?: StubDirection; /** Stub length override. */ length?: number; } /** A component with its placement offset and relative pin stubs. */ export interface ComponentStubSpec { /** Reference designator. */ ref: string; /** Component placement offset from anchor. */ placementOffset: { dx: number; dy: number; }; /** Pins that need wire stubs, relative to the component's position. */ pins: readonly RelativePinStub[]; } /** * Generate wire stubs for multiple components, given an anchor point. * * Each component's pin positions are computed as: * pin.x = anchor.x + component.placementOffset.dx + pin.dx * pin.y = anchor.y + component.placementOffset.dy + pin.dy * * This is the primary entry point for template authors — it takes the same * anchor and placement offsets used for component placement, so stub * positions are automatically consistent with component positions. */ export declare function generateStubsForComponents(anchor: { x: number; y: number; }, components: readonly ComponentStubSpec[], options?: WireStubGeneratorOptions): WorkflowWireInput[]; /** * Helper for the common two-pin passive component pattern (resistor, capacitor, LED). * Produces two stubs: pin 1 to the left, pin 2 to the right. */ export declare function twoPinPassiveStubs(ref: string, offset: { dx: number; dy: number; }, pin1Net: string, pin2Net: string, pinSpacing?: number): ComponentStubSpec;