@tscircuit/core 0.0.1156 → 0.0.1158

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +395 -388
  2. package/dist/index.js +88 -75
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as circuit_json from 'circuit-json';
2
- import { PcbTraceError, PcbPlacementError, PcbManualEditConflictWarning, PcbViaClearanceError, LayerRef, AnyCircuitElement, Size, AnySourceComponent, PcbTraceRoutePoint, PcbTrace as PcbTrace$1, PcbVia, SchematicPort, SchematicComponent, RouteHintPoint, CircuitJson } from 'circuit-json';
2
+ import { PcbTraceError, PcbPlacementError, PcbManualEditConflictWarning, PcbViaClearanceError, LayerRef, AnyCircuitElement, Size, PcbTraceRoutePoint, AnySourceComponent, PcbTrace as PcbTrace$1, PcbVia, SchematicPort, SchematicComponent, RouteHintPoint, CircuitJson } from 'circuit-json';
3
3
  import * as _tscircuit_props from '@tscircuit/props';
4
- import { PlatformConfig, subcircuitGroupProps, AutorouterConfig, PcbSx, traceProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, subcircuitProps, subpanelProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, interconnectProps, solderjumperProps, ledProps, powerSourceProps, voltageSourceProps, currentSourceProps, resistorProps, constraintProps, fabricationNoteRectProps, fabricationNotePathProps, fabricationNoteTextProps, fabricationNoteDimensionProps, pcbNoteLineProps, pcbNoteRectProps, pcbNoteTextProps, pcbNotePathProps, pcbNoteDimensionProps, footprintProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, courtyardCircleProps, courtyardOutlineProps, courtyardRectProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, fiducialProps, traceHintProps, viaProps, copperPourProps, copperTextProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, opampProps, OpAmpPinLabels, switchProps, SwitchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicPathProps, schematicBoxProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, voltageProbeProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
4
+ import { PlatformConfig, traceProps, subcircuitGroupProps, AutorouterConfig, PcbSx, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, subcircuitProps, subpanelProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, interconnectProps, solderjumperProps, ledProps, powerSourceProps, voltageSourceProps, currentSourceProps, resistorProps, constraintProps, fabricationNoteRectProps, fabricationNotePathProps, fabricationNoteTextProps, fabricationNoteDimensionProps, pcbNoteLineProps, pcbNoteRectProps, pcbNoteTextProps, pcbNotePathProps, pcbNoteDimensionProps, footprintProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, courtyardCircleProps, courtyardOutlineProps, courtyardRectProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, fiducialProps, traceHintProps, viaProps, copperPourProps, copperTextProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, opampProps, OpAmpPinLabels, switchProps, SwitchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicPathProps, schematicBoxProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, voltageProbeProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
5
5
  export { kicadFootprintStrings } from '@tscircuit/props';
6
6
  import * as react from 'react';
7
7
  import react__default, { ReactElement, DetailedHTMLProps, SVGProps } from 'react';
@@ -397,402 +397,73 @@ interface IGroup extends PrimitiveComponent {
397
397
  }): void;
398
398
  }
399
399
 
400
- interface ISubcircuit extends PrimitiveComponent {
401
- _shouldUseTraceByTraceRouting(): boolean;
402
- _parsedProps: z.infer<typeof subcircuitGroupProps>;
403
- _getAutorouterConfig(): AutorouterConfig;
404
- _isAutoJumperAutorouter(autorouterConfig?: AutorouterConfig): boolean;
405
- getNextAvailableName(elm: PrimitiveComponent): string;
406
- _getSubcircuitLayerCount(): number;
407
- subcircuit_id: string | null;
408
- getNormalComponentNameMap?: () => Map<string, NormalComponent[]>;
409
- _isInflatedFromCircuitJson: boolean;
410
- _isIsolatedSubcircuit: boolean;
411
- _isolatedCircuitJson: AnyCircuitElement[] | null;
412
- _normalComponentNameMap: Map<string, NormalComponent[]> | null;
413
- getSubcircuitPropHash?(): string;
414
- }
415
-
416
- interface SchematicSymbolBounds {
417
- minX: number;
418
- maxX: number;
419
- minY: number;
420
- maxY: number;
421
- }
422
- interface ISymbol {
423
- /**
424
- * The circuit-json schematic_symbol_id for this symbol.
425
- * Created during SchematicPrimitiveRender phase.
426
- */
427
- schematic_symbol_id?: string;
428
- /**
429
- * The transformation matrix to convert from user coordinates (as specified
430
- * in the symbol's children) to the final resized symbol coordinates.
431
- * This is computed lazily when first requested.
432
- */
433
- userCoordinateToResizedSymbolTransformMat?: Matrix;
434
- /**
435
- * The computed bounds of the symbol's schematic primitives before any
436
- * resizing is applied.
437
- */
438
- schematicSymbolBoundsInUserCoordinates?: SchematicSymbolBounds;
400
+ declare const netProps: z.ZodObject<{
401
+ name: z.ZodEffects<z.ZodString, string, string>;
402
+ }, "strip", z.ZodTypeAny, {
403
+ name: string;
404
+ }, {
405
+ name: string;
406
+ }>;
407
+ declare class Net extends PrimitiveComponent<typeof netProps> {
408
+ source_net_id?: string;
409
+ subcircuit_connectivity_map_key: string | null;
410
+ get config(): {
411
+ componentName: string;
412
+ zodProps: z.ZodObject<{
413
+ name: z.ZodEffects<z.ZodString, string, string>;
414
+ }, "strip", z.ZodTypeAny, {
415
+ name: string;
416
+ }, {
417
+ name: string;
418
+ }>;
419
+ };
420
+ getPortSelector(): string;
421
+ doInitialSourceRender(): void;
422
+ doInitialSourceParentAttachment(): void;
439
423
  /**
440
- * Get the bounds of the symbol's schematic primitives.
441
- * This triggers computation if not already done.
424
+ * Get all ports connected to this net.
425
+ *
426
+ * TODO currently we're not checking for indirect connections (traces that are
427
+ * connected to other traces that are in turn connected to the net)
442
428
  */
443
- getSchematicSymbolBounds(): SchematicSymbolBounds | null;
429
+ getAllConnectedPorts(): Port[];
444
430
  /**
445
- * Get the transformation matrix for resizing symbol contents.
446
- * Returns null if no resizing is needed (no width/height specified).
431
+ * Get all traces that are directly connected to this net, i.e. they list
432
+ * this net in their path, from, or to props
447
433
  */
448
- getUserCoordinateToResizedSymbolTransform(): Matrix | null;
434
+ _getAllDirectlyConnectedTraces(): Trace[];
449
435
  /**
450
- * Check if this symbol has explicit width/height that requires resizing.
436
+ * Add PCB Traces to connect net islands together. A net island is a set of
437
+ * ports that are connected to each other. If a there are multiple net islands
438
+ * that means that the net is not fully connected and we need to add traces
439
+ * such that the nets are fully connected
440
+ *
441
+ * Sometimes this phase doesn't find any net islands if the autorouter did
442
+ * a good job and connected the islands. In some sense this is a "backup"
443
+ * routing phase for autorouters that don't care about connecting nets.
444
+ *
445
+ * This should only run if the autorouter is sequential-trace
451
446
  */
452
- hasExplicitSize(): boolean;
447
+ doInitialPcbRouteNetIslands(): void;
448
+ renderError(message: Parameters<typeof PrimitiveComponent.prototype.renderError>[0]): void;
453
449
  }
454
450
 
455
- type Ftype = Extract<AnySourceComponent, {
456
- ftype: string;
457
- }>["ftype"];
458
- type TwoPinPorts = "pin1" | "pin2";
459
- type PassivePorts = TwoPinPorts;
460
- type PolarizedPassivePorts = PassivePorts | "anode" | "cathode" | "pos" | "neg";
461
- type TransistorPorts = "pin1" | "pin2" | "pin3" | "emitter" | "collector" | "base";
462
-
463
- interface BaseComponentConfig {
464
- componentName: string;
465
- schematicSymbolName?: string | null;
466
- zodProps: z.ZodType;
467
- sourceFtype?: Ftype | null;
468
- shouldRenderAsSchematicBox?: boolean;
451
+ interface TraceI extends PrimitiveComponent<typeof traceProps> {
452
+ source_trace_id: string | null;
453
+ subcircuit_connectivity_map_key: string | null;
469
454
  }
470
- /**
471
- * A PrimitiveComponent (SmtPad, Port etc.) doesn't have the ability to contain
472
- * React subtrees or explicit handling of the "footprint" prop. But otherwise
473
- * has most of the features of a NormalComponent.
474
- */
475
- declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extends Renderable {
476
- parent: PrimitiveComponent | null;
477
- children: PrimitiveComponent[];
478
- childrenPendingRemoval: PrimitiveComponent[];
479
- get config(): BaseComponentConfig;
480
- props: z.input<ZodProps>;
481
- _parsedProps: z.infer<ZodProps>;
482
- get componentName(): string;
483
- getInheritedProperty(propertyName: string): any;
484
- getInheritedMergedProperty(propertyName: string): any;
485
- getResolvedPcbSx(): PcbSx;
486
- get lowercaseComponentName(): string;
487
- externallyAddedAliases: string[];
488
- /**
489
- * An subcircuit is self-contained. All the selectors inside
490
- * a subcircuit are relative to the subcircuit group. You can have multiple
491
- * subcircuits and their selectors will not interact with each other (even if the
492
- * components share the same names) unless you explicitly break out some ports
493
- */
494
- get isSubcircuit(): any;
495
- get isGroup(): boolean;
496
- get name(): any;
497
- /**
498
- * A primitive container is a component that contains one or more ports and
499
- * primitive components that are designed to interact.
500
- *
501
- * For example a resistor contains ports and smtpads that interact, so the
502
- * resistor is a primitive container. Inside a primitive container, the ports
503
- * and pads are likely to reference each other and look for eachother during
504
- * the port matching phase.
505
- *
506
- */
507
- isPrimitiveContainer: boolean;
508
- canHaveTextChildren: boolean;
509
- source_group_id: string | null;
510
- source_component_id: string | null;
511
- schematic_component_id: string | null;
512
- pcb_component_id: string | null;
513
- cad_component_id: string | null;
514
- _reportedInvalidPcbCalcWarnings: Set<string>;
515
- private _reportInvalidComponentPropertyError;
516
- fallbackUnassignedName?: string;
517
- constructor(props: z.input<ZodProps>);
518
- setProps(props: Partial<z.input<ZodProps>>): void;
519
- _getPcbRotationBeforeLayout(): number | null;
520
- getResolvedPcbPositionProp(): {
521
- pcbX: number;
522
- pcbY: number;
523
- };
524
- doInitialValidatePcbCoordinates(): void;
525
- protected _validatePcbCoordinateReferences(params: {
526
- rawValue: unknown;
527
- axis: "pcbX" | "pcbY";
528
- propertyName?: string;
529
- }): void;
530
- protected _resolvePcbCoordinate(rawValue: unknown, axis: "pcbX" | "pcbY", options?: {
531
- allowBoardVariables?: boolean;
532
- allowComponentVariables?: boolean;
533
- componentVariables?: Record<string, number>;
534
- propertyName?: string;
535
- }): number;
536
- private _shouldAllowBoardVariablesByDefault;
537
- private _isInsideFootprint;
538
- private _isInsideNonBoardSubcircuit;
539
- /**
540
- * Check if this component has a user-defined PCB position.
541
- * Position can be specified via pcbX/pcbY or edge-based props.
542
- */
543
- _hasUserDefinedPcbPosition(): boolean;
544
- resolvePcbCoordinate(params: {
545
- rawValue: unknown;
546
- axis: "pcbX" | "pcbY";
547
- allowBoardVariables?: boolean;
548
- allowComponentVariables?: boolean;
549
- componentVariables?: Record<string, number>;
550
- propertyName?: string;
551
- }): number;
552
- /**
553
- * Computes a transformation matrix from the props of this component for PCB
554
- * components
555
- */
556
- computePcbPropsTransform(): Matrix;
557
- /**
558
- * Compute a transformation matrix combining all parent transforms for PCB
559
- * components, including this component's translation and rotation.
560
- *
561
- * This is used to compute this component's position as well as all children
562
- * components positions before layout is applied
563
- */
564
- _computePcbGlobalTransformBeforeLayout(): Matrix;
565
- getPrimitiveContainer(): PrimitiveComponent | null;
566
- /**
567
- * Get the Symbol ancestor if this component is inside a Symbol primitive container.
568
- * Used by schematic primitives to access the symbol's resize transform.
569
- */
570
- _getSymbolAncestor(): ISymbol | null;
571
- /**
572
- * Walk up the component hierarchy to find the nearest NormalComponent ancestor.
573
- * This is useful for primitive components that need access to component IDs
574
- * (pcb_component_id, schematic_component_id, source_component_id) from their
575
- * parent NormalComponent, even when there are intermediate primitive containers
576
- * like Symbol in the hierarchy.
577
- */
578
- getParentNormalComponent(): any | null;
579
- /**
580
- * Replaces text like {NAME}, {REF}, and {REFERENCE} with the
581
- * reference designator (name) of the parent NormalComponent.
582
- */
583
- protected _resolveText(): string;
584
- /**
585
- * Emit a warning when coveredWithSolderMask is true but solderMaskMargin is also set
586
- */
587
- emitSolderMaskMarginWarning(isCoveredWithSolderMask: boolean, solderMaskMargin: number | undefined): void;
455
+
456
+ declare class Trace extends PrimitiveComponent<typeof traceProps> implements TraceI {
457
+ source_trace_id: string | null;
458
+ pcb_trace_id: string | null;
459
+ schematic_trace_id: string | null;
460
+ _portsRoutedOnPcb: Port[];
461
+ subcircuit_connectivity_map_key: string | null;
462
+ _traceConnectionHash: string | null;
463
+ _couldNotFindPort?: boolean;
464
+ constructor(props: z.input<typeof traceProps>);
588
465
  /**
589
- * Compute the PCB bounds of this component the circuit json elements
590
- * associated with it.
591
- */
592
- _getPcbCircuitJsonBounds(): {
593
- center: {
594
- x: number;
595
- y: number;
596
- };
597
- bounds: {
598
- left: number;
599
- top: number;
600
- right: number;
601
- bottom: number;
602
- };
603
- width: number;
604
- height: number;
605
- };
606
- /**
607
- * Determine if this pcb primitive should be flipped because the primitive
608
- * container is flipped
609
- *
610
- * TODO use footprint.originalLayer instead of assuming everything is defined
611
- * relative to the top layer
612
- */
613
- _getPcbPrimitiveFlippedHelpers(): {
614
- isFlipped: boolean;
615
- maybeFlipLayer: (layer: LayerRef) => LayerRef;
616
- };
617
- /**
618
- * Set the position of this component from the layout solver. This method
619
- * should operate using CircuitJson associated with this component, like
620
- * _getPcbCircuitJsonBounds it can be called multiple times as different
621
- * parents apply layout to their children.
622
- */
623
- _setPositionFromLayout(newCenter: {
624
- x: number;
625
- y: number;
626
- }): void;
627
- /**
628
- * Computes a transformation matrix from the props of this component for
629
- * schematic components
630
- */
631
- computeSchematicPropsTransform(): Matrix;
632
- /**
633
- * Compute a transformation matrix combining all parent transforms for this
634
- * component
635
- */
636
- computeSchematicGlobalTransform(): Matrix;
637
- _getSchematicSymbolName(): keyof typeof symbols | undefined;
638
- _getSchematicSymbolNameOrThrow(): keyof typeof symbols;
639
- getSchematicSymbol(): SchSymbol | null;
640
- /**
641
- * Subcircuit groups have a prop called "layout" that can include manual
642
- * placements for pcb components. These are typically added from an IDE
643
- */
644
- _getPcbManualPlacementForComponent(component: PrimitiveComponent): {
645
- x: number;
646
- y: number;
647
- } | null;
648
- _getSchematicManualPlacementForComponent(component: PrimitiveComponent): {
649
- x: number;
650
- y: number;
651
- } | null;
652
- _getSchematicGlobalManualPlacementTransform(component: PrimitiveComponent): Matrix | null;
653
- _getGlobalPcbPositionBeforeLayout(): {
654
- x: number;
655
- y: number;
656
- };
657
- _getGlobalSchematicPositionBeforeLayout(): {
658
- x: number;
659
- y: number;
660
- };
661
- _getBoard(): (PrimitiveComponent & BoardI) | undefined;
662
- get root(): IsolatedCircuit | null;
663
- onAddToParent(parent: PrimitiveComponent): void;
664
- /**
665
- * Called whenever the props change
666
- */
667
- onPropsChange(params: {
668
- oldProps: z.infer<ZodProps>;
669
- newProps: z.infer<ZodProps>;
670
- changedProps: string[];
671
- }): void;
672
- onChildChanged(child: PrimitiveComponent): void;
673
- add(component: PrimitiveComponent): void;
674
- addAll(components: PrimitiveComponent[]): void;
675
- remove(component: PrimitiveComponent): void;
676
- getSubcircuitSelector(): string;
677
- getFullPathSelector(): string;
678
- getNameAndAliases(): string[];
679
- isMatchingNameOrAlias(name: string): boolean;
680
- isMatchingAnyOf(aliases: Array<string | number>): boolean;
681
- getPcbSize(): {
682
- width: number;
683
- height: number;
684
- };
685
- doesSelectorMatch(selector: string): boolean;
686
- getSubcircuit(): ISubcircuit;
687
- getGroup(): IGroup | null;
688
- doInitialAssignNameToUnnamedComponents(): void;
689
- doInitialOptimizeSelectorCache(): void;
690
- _cachedSelectAllQueries: Map<string, PrimitiveComponent[]>;
691
- selectAll<T extends PrimitiveComponent = PrimitiveComponent>(selectorRaw: string): T[];
692
- _cachedSelectOneQueries: Map<string, PrimitiveComponent | null>;
693
- selectOne<T = PrimitiveComponent>(selectorRaw: string, options?: {
694
- type?: string;
695
- port?: boolean;
696
- pcbPrimitive?: boolean;
697
- schematicPrimitive?: boolean;
698
- }): T | null;
699
- getAvailablePcbLayers(): string[];
700
- /**
701
- * Returns all descendants
702
- *
703
- * NOTE: This crosses subcircuit boundaries, you may want to use
704
- * getSelectableDescendants instead
705
- */
706
- getDescendants(): PrimitiveComponent[];
707
- /**
708
- * Returns all descendants that are accessible without crossing a subcircuit
709
- * boundary
710
- */
711
- getSelectableDescendants(): PrimitiveComponent[];
712
- /**
713
- * Return the number of pins in this component, this is important for
714
- * NormalComponents
715
- */
716
- _getPinCount(): number;
717
- /**
718
- * If this component represents a SchematicBox (like a Chip), return the
719
- * dimensions of the box, which allows computing the position of ports etc.
720
- */
721
- _getSchematicBoxDimensions(): SchematicBoxDimensions | null;
722
- _getSchematicBoxComponentDimensions(): SchematicBoxComponentDimensions | null;
723
- renderError(message: Parameters<typeof Renderable.prototype.renderError>[0]): void;
724
- getString(): string;
725
- getDisplayName(): string;
726
- get [Symbol.toStringTag](): string;
727
- }
728
-
729
- declare const netProps: z.ZodObject<{
730
- name: z.ZodEffects<z.ZodString, string, string>;
731
- }, "strip", z.ZodTypeAny, {
732
- name: string;
733
- }, {
734
- name: string;
735
- }>;
736
- declare class Net extends PrimitiveComponent<typeof netProps> {
737
- source_net_id?: string;
738
- subcircuit_connectivity_map_key: string | null;
739
- get config(): {
740
- componentName: string;
741
- zodProps: z.ZodObject<{
742
- name: z.ZodEffects<z.ZodString, string, string>;
743
- }, "strip", z.ZodTypeAny, {
744
- name: string;
745
- }, {
746
- name: string;
747
- }>;
748
- };
749
- getPortSelector(): string;
750
- doInitialSourceRender(): void;
751
- doInitialSourceParentAttachment(): void;
752
- /**
753
- * Get all ports connected to this net.
754
- *
755
- * TODO currently we're not checking for indirect connections (traces that are
756
- * connected to other traces that are in turn connected to the net)
757
- */
758
- getAllConnectedPorts(): Port[];
759
- /**
760
- * Get all traces that are directly connected to this net, i.e. they list
761
- * this net in their path, from, or to props
762
- */
763
- _getAllDirectlyConnectedTraces(): Trace[];
764
- /**
765
- * Add PCB Traces to connect net islands together. A net island is a set of
766
- * ports that are connected to each other. If a there are multiple net islands
767
- * that means that the net is not fully connected and we need to add traces
768
- * such that the nets are fully connected
769
- *
770
- * Sometimes this phase doesn't find any net islands if the autorouter did
771
- * a good job and connected the islands. In some sense this is a "backup"
772
- * routing phase for autorouters that don't care about connecting nets.
773
- *
774
- * This should only run if the autorouter is sequential-trace
775
- */
776
- doInitialPcbRouteNetIslands(): void;
777
- renderError(message: Parameters<typeof PrimitiveComponent.prototype.renderError>[0]): void;
778
- }
779
-
780
- interface TraceI extends PrimitiveComponent<typeof traceProps> {
781
- source_trace_id: string | null;
782
- subcircuit_connectivity_map_key: string | null;
783
- }
784
-
785
- declare class Trace extends PrimitiveComponent<typeof traceProps> implements TraceI {
786
- source_trace_id: string | null;
787
- pcb_trace_id: string | null;
788
- schematic_trace_id: string | null;
789
- _portsRoutedOnPcb: Port[];
790
- subcircuit_connectivity_map_key: string | null;
791
- _traceConnectionHash: string | null;
792
- _couldNotFindPort?: boolean;
793
- constructor(props: z.input<typeof traceProps>);
794
- /**
795
- * Get the explicit trace thickness, supporting 'width' as an alias for 'thickness'
466
+ * Get the explicit trace thickness, supporting 'width' as an alias for 'thickness'
796
467
  */
797
468
  _getExplicitTraceThickness(): number | undefined;
798
469
  get config(): {
@@ -1378,6 +1049,341 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
1378
1049
  doInitialSchematicTraceRender(): void;
1379
1050
  }
1380
1051
 
1052
+ interface RoutingPhasePlan {
1053
+ routingPhaseIndex: number | null;
1054
+ traces: Trace[];
1055
+ }
1056
+
1057
+ interface ISubcircuit extends PrimitiveComponent {
1058
+ _shouldUseTraceByTraceRouting(): boolean;
1059
+ _getRoutingPhasePlans(): RoutingPhasePlan[];
1060
+ _parsedProps: z.infer<typeof subcircuitGroupProps>;
1061
+ _getAutorouterConfig(): AutorouterConfig;
1062
+ _isAutoJumperAutorouter(autorouterConfig?: AutorouterConfig): boolean;
1063
+ getNextAvailableName(elm: PrimitiveComponent): string;
1064
+ _getSubcircuitLayerCount(): number;
1065
+ subcircuit_id: string | null;
1066
+ getNormalComponentNameMap?: () => Map<string, NormalComponent[]>;
1067
+ _isInflatedFromCircuitJson: boolean;
1068
+ _isIsolatedSubcircuit: boolean;
1069
+ _isolatedCircuitJson: AnyCircuitElement[] | null;
1070
+ _normalComponentNameMap: Map<string, NormalComponent[]> | null;
1071
+ getSubcircuitPropHash?(): string;
1072
+ }
1073
+
1074
+ interface SchematicSymbolBounds {
1075
+ minX: number;
1076
+ maxX: number;
1077
+ minY: number;
1078
+ maxY: number;
1079
+ }
1080
+ interface ISymbol {
1081
+ /**
1082
+ * The circuit-json schematic_symbol_id for this symbol.
1083
+ * Created during SchematicPrimitiveRender phase.
1084
+ */
1085
+ schematic_symbol_id?: string;
1086
+ /**
1087
+ * The transformation matrix to convert from user coordinates (as specified
1088
+ * in the symbol's children) to the final resized symbol coordinates.
1089
+ * This is computed lazily when first requested.
1090
+ */
1091
+ userCoordinateToResizedSymbolTransformMat?: Matrix;
1092
+ /**
1093
+ * The computed bounds of the symbol's schematic primitives before any
1094
+ * resizing is applied.
1095
+ */
1096
+ schematicSymbolBoundsInUserCoordinates?: SchematicSymbolBounds;
1097
+ /**
1098
+ * Get the bounds of the symbol's schematic primitives.
1099
+ * This triggers computation if not already done.
1100
+ */
1101
+ getSchematicSymbolBounds(): SchematicSymbolBounds | null;
1102
+ /**
1103
+ * Get the transformation matrix for resizing symbol contents.
1104
+ * Returns null if no resizing is needed (no width/height specified).
1105
+ */
1106
+ getUserCoordinateToResizedSymbolTransform(): Matrix | null;
1107
+ /**
1108
+ * Check if this symbol has explicit width/height that requires resizing.
1109
+ */
1110
+ hasExplicitSize(): boolean;
1111
+ }
1112
+
1113
+ type Ftype = Extract<AnySourceComponent, {
1114
+ ftype: string;
1115
+ }>["ftype"];
1116
+ type TwoPinPorts = "pin1" | "pin2";
1117
+ type PassivePorts = TwoPinPorts;
1118
+ type PolarizedPassivePorts = PassivePorts | "anode" | "cathode" | "pos" | "neg";
1119
+ type TransistorPorts = "pin1" | "pin2" | "pin3" | "emitter" | "collector" | "base";
1120
+
1121
+ interface BaseComponentConfig {
1122
+ componentName: string;
1123
+ schematicSymbolName?: string | null;
1124
+ zodProps: z.ZodType;
1125
+ sourceFtype?: Ftype | null;
1126
+ shouldRenderAsSchematicBox?: boolean;
1127
+ }
1128
+ /**
1129
+ * A PrimitiveComponent (SmtPad, Port etc.) doesn't have the ability to contain
1130
+ * React subtrees or explicit handling of the "footprint" prop. But otherwise
1131
+ * has most of the features of a NormalComponent.
1132
+ */
1133
+ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extends Renderable {
1134
+ parent: PrimitiveComponent | null;
1135
+ children: PrimitiveComponent[];
1136
+ childrenPendingRemoval: PrimitiveComponent[];
1137
+ get config(): BaseComponentConfig;
1138
+ props: z.input<ZodProps>;
1139
+ _parsedProps: z.infer<ZodProps>;
1140
+ get componentName(): string;
1141
+ getInheritedProperty(propertyName: string): any;
1142
+ getInheritedMergedProperty(propertyName: string): any;
1143
+ getResolvedPcbSx(): PcbSx;
1144
+ get lowercaseComponentName(): string;
1145
+ externallyAddedAliases: string[];
1146
+ /**
1147
+ * An subcircuit is self-contained. All the selectors inside
1148
+ * a subcircuit are relative to the subcircuit group. You can have multiple
1149
+ * subcircuits and their selectors will not interact with each other (even if the
1150
+ * components share the same names) unless you explicitly break out some ports
1151
+ */
1152
+ get isSubcircuit(): any;
1153
+ get isGroup(): boolean;
1154
+ get name(): any;
1155
+ /**
1156
+ * A primitive container is a component that contains one or more ports and
1157
+ * primitive components that are designed to interact.
1158
+ *
1159
+ * For example a resistor contains ports and smtpads that interact, so the
1160
+ * resistor is a primitive container. Inside a primitive container, the ports
1161
+ * and pads are likely to reference each other and look for eachother during
1162
+ * the port matching phase.
1163
+ *
1164
+ */
1165
+ isPrimitiveContainer: boolean;
1166
+ canHaveTextChildren: boolean;
1167
+ source_group_id: string | null;
1168
+ source_component_id: string | null;
1169
+ schematic_component_id: string | null;
1170
+ pcb_component_id: string | null;
1171
+ cad_component_id: string | null;
1172
+ _reportedInvalidPcbCalcWarnings: Set<string>;
1173
+ private _reportInvalidComponentPropertyError;
1174
+ fallbackUnassignedName?: string;
1175
+ constructor(props: z.input<ZodProps>);
1176
+ setProps(props: Partial<z.input<ZodProps>>): void;
1177
+ _getPcbRotationBeforeLayout(): number | null;
1178
+ getResolvedPcbPositionProp(): {
1179
+ pcbX: number;
1180
+ pcbY: number;
1181
+ };
1182
+ doInitialValidatePcbCoordinates(): void;
1183
+ protected _validatePcbCoordinateReferences(params: {
1184
+ rawValue: unknown;
1185
+ axis: "pcbX" | "pcbY";
1186
+ propertyName?: string;
1187
+ }): void;
1188
+ protected _resolvePcbCoordinate(rawValue: unknown, axis: "pcbX" | "pcbY", options?: {
1189
+ allowBoardVariables?: boolean;
1190
+ allowComponentVariables?: boolean;
1191
+ componentVariables?: Record<string, number>;
1192
+ propertyName?: string;
1193
+ }): number;
1194
+ private _shouldAllowBoardVariablesByDefault;
1195
+ private _isInsideFootprint;
1196
+ private _isInsideNonBoardSubcircuit;
1197
+ /**
1198
+ * Check if this component has a user-defined PCB position.
1199
+ * Position can be specified via pcbX/pcbY or edge-based props.
1200
+ */
1201
+ _hasUserDefinedPcbPosition(): boolean;
1202
+ resolvePcbCoordinate(params: {
1203
+ rawValue: unknown;
1204
+ axis: "pcbX" | "pcbY";
1205
+ allowBoardVariables?: boolean;
1206
+ allowComponentVariables?: boolean;
1207
+ componentVariables?: Record<string, number>;
1208
+ propertyName?: string;
1209
+ }): number;
1210
+ /**
1211
+ * Computes a transformation matrix from the props of this component for PCB
1212
+ * components
1213
+ */
1214
+ computePcbPropsTransform(): Matrix;
1215
+ /**
1216
+ * Compute a transformation matrix combining all parent transforms for PCB
1217
+ * components, including this component's translation and rotation.
1218
+ *
1219
+ * This is used to compute this component's position as well as all children
1220
+ * components positions before layout is applied
1221
+ */
1222
+ _computePcbGlobalTransformBeforeLayout(): Matrix;
1223
+ getPrimitiveContainer(): PrimitiveComponent | null;
1224
+ /**
1225
+ * Get the Symbol ancestor if this component is inside a Symbol primitive container.
1226
+ * Used by schematic primitives to access the symbol's resize transform.
1227
+ */
1228
+ _getSymbolAncestor(): ISymbol | null;
1229
+ /**
1230
+ * Walk up the component hierarchy to find the nearest NormalComponent ancestor.
1231
+ * This is useful for primitive components that need access to component IDs
1232
+ * (pcb_component_id, schematic_component_id, source_component_id) from their
1233
+ * parent NormalComponent, even when there are intermediate primitive containers
1234
+ * like Symbol in the hierarchy.
1235
+ */
1236
+ getParentNormalComponent(): any | null;
1237
+ /**
1238
+ * Replaces text like {NAME}, {REF}, and {REFERENCE} with the
1239
+ * reference designator (name) of the parent NormalComponent.
1240
+ */
1241
+ protected _resolveText(): string;
1242
+ /**
1243
+ * Emit a warning when coveredWithSolderMask is true but solderMaskMargin is also set
1244
+ */
1245
+ emitSolderMaskMarginWarning(isCoveredWithSolderMask: boolean, solderMaskMargin: number | undefined): void;
1246
+ /**
1247
+ * Compute the PCB bounds of this component the circuit json elements
1248
+ * associated with it.
1249
+ */
1250
+ _getPcbCircuitJsonBounds(): {
1251
+ center: {
1252
+ x: number;
1253
+ y: number;
1254
+ };
1255
+ bounds: {
1256
+ left: number;
1257
+ top: number;
1258
+ right: number;
1259
+ bottom: number;
1260
+ };
1261
+ width: number;
1262
+ height: number;
1263
+ };
1264
+ /**
1265
+ * Determine if this pcb primitive should be flipped because the primitive
1266
+ * container is flipped
1267
+ *
1268
+ * TODO use footprint.originalLayer instead of assuming everything is defined
1269
+ * relative to the top layer
1270
+ */
1271
+ _getPcbPrimitiveFlippedHelpers(): {
1272
+ isFlipped: boolean;
1273
+ maybeFlipLayer: (layer: LayerRef) => LayerRef;
1274
+ };
1275
+ /**
1276
+ * Set the position of this component from the layout solver. This method
1277
+ * should operate using CircuitJson associated with this component, like
1278
+ * _getPcbCircuitJsonBounds it can be called multiple times as different
1279
+ * parents apply layout to their children.
1280
+ */
1281
+ _setPositionFromLayout(newCenter: {
1282
+ x: number;
1283
+ y: number;
1284
+ }): void;
1285
+ /**
1286
+ * Computes a transformation matrix from the props of this component for
1287
+ * schematic components
1288
+ */
1289
+ computeSchematicPropsTransform(): Matrix;
1290
+ /**
1291
+ * Compute a transformation matrix combining all parent transforms for this
1292
+ * component
1293
+ */
1294
+ computeSchematicGlobalTransform(): Matrix;
1295
+ _getSchematicSymbolName(): keyof typeof symbols | undefined;
1296
+ _getSchematicSymbolNameOrThrow(): keyof typeof symbols;
1297
+ getSchematicSymbol(): SchSymbol | null;
1298
+ /**
1299
+ * Subcircuit groups have a prop called "layout" that can include manual
1300
+ * placements for pcb components. These are typically added from an IDE
1301
+ */
1302
+ _getPcbManualPlacementForComponent(component: PrimitiveComponent): {
1303
+ x: number;
1304
+ y: number;
1305
+ } | null;
1306
+ _getSchematicManualPlacementForComponent(component: PrimitiveComponent): {
1307
+ x: number;
1308
+ y: number;
1309
+ } | null;
1310
+ _getSchematicGlobalManualPlacementTransform(component: PrimitiveComponent): Matrix | null;
1311
+ _getGlobalPcbPositionBeforeLayout(): {
1312
+ x: number;
1313
+ y: number;
1314
+ };
1315
+ _getGlobalSchematicPositionBeforeLayout(): {
1316
+ x: number;
1317
+ y: number;
1318
+ };
1319
+ _getBoard(): (PrimitiveComponent & BoardI) | undefined;
1320
+ get root(): IsolatedCircuit | null;
1321
+ onAddToParent(parent: PrimitiveComponent): void;
1322
+ /**
1323
+ * Called whenever the props change
1324
+ */
1325
+ onPropsChange(params: {
1326
+ oldProps: z.infer<ZodProps>;
1327
+ newProps: z.infer<ZodProps>;
1328
+ changedProps: string[];
1329
+ }): void;
1330
+ onChildChanged(child: PrimitiveComponent): void;
1331
+ add(component: PrimitiveComponent): void;
1332
+ addAll(components: PrimitiveComponent[]): void;
1333
+ remove(component: PrimitiveComponent): void;
1334
+ getSubcircuitSelector(): string;
1335
+ getFullPathSelector(): string;
1336
+ getNameAndAliases(): string[];
1337
+ isMatchingNameOrAlias(name: string): boolean;
1338
+ isMatchingAnyOf(aliases: Array<string | number>): boolean;
1339
+ getPcbSize(): {
1340
+ width: number;
1341
+ height: number;
1342
+ };
1343
+ doesSelectorMatch(selector: string): boolean;
1344
+ getSubcircuit(): ISubcircuit;
1345
+ getGroup(): IGroup | null;
1346
+ doInitialAssignNameToUnnamedComponents(): void;
1347
+ doInitialOptimizeSelectorCache(): void;
1348
+ _cachedSelectAllQueries: Map<string, PrimitiveComponent[]>;
1349
+ selectAll<T extends PrimitiveComponent = PrimitiveComponent>(selectorRaw: string): T[];
1350
+ _cachedSelectOneQueries: Map<string, PrimitiveComponent | null>;
1351
+ selectOne<T = PrimitiveComponent>(selectorRaw: string, options?: {
1352
+ type?: string;
1353
+ port?: boolean;
1354
+ pcbPrimitive?: boolean;
1355
+ schematicPrimitive?: boolean;
1356
+ }): T | null;
1357
+ getAvailablePcbLayers(): string[];
1358
+ /**
1359
+ * Returns all descendants
1360
+ *
1361
+ * NOTE: This crosses subcircuit boundaries, you may want to use
1362
+ * getSelectableDescendants instead
1363
+ */
1364
+ getDescendants(): PrimitiveComponent[];
1365
+ /**
1366
+ * Returns all descendants that are accessible without crossing a subcircuit
1367
+ * boundary
1368
+ */
1369
+ getSelectableDescendants(): PrimitiveComponent[];
1370
+ /**
1371
+ * Return the number of pins in this component, this is important for
1372
+ * NormalComponents
1373
+ */
1374
+ _getPinCount(): number;
1375
+ /**
1376
+ * If this component represents a SchematicBox (like a Chip), return the
1377
+ * dimensions of the box, which allows computing the position of ports etc.
1378
+ */
1379
+ _getSchematicBoxDimensions(): SchematicBoxDimensions | null;
1380
+ _getSchematicBoxComponentDimensions(): SchematicBoxComponentDimensions | null;
1381
+ renderError(message: Parameters<typeof Renderable.prototype.renderError>[0]): void;
1382
+ getString(): string;
1383
+ getDisplayName(): string;
1384
+ get [Symbol.toStringTag](): string;
1385
+ }
1386
+
1381
1387
  declare const portProps: z.ZodObject<{
1382
1388
  name: z.ZodOptional<z.ZodString>;
1383
1389
  pinNumber: z.ZodOptional<z.ZodNumber>;
@@ -1805,6 +1811,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
1805
1811
  doInitialSourceAddConnectivityMapKey(): void;
1806
1812
  _areChildSubcircuitsRouted(): boolean;
1807
1813
  _shouldRouteAsync(): boolean;
1814
+ _getRoutingPhasePlans(): RoutingPhasePlan[];
1808
1815
  _hasTracesToRoute(): boolean;
1809
1816
  _runEffectMakeHttpAutoroutingRequest(): Promise<void>;
1810
1817
  /**
package/dist/index.js CHANGED
@@ -17321,6 +17321,18 @@ function Group_doInitialSourceAddConnectivityMapKey(group) {
17321
17321
  }
17322
17322
  }
17323
17323
 
17324
+ // lib/components/primitive-components/Group/Group_getRoutingPhasePlans.ts
17325
+ function Group_getRoutingPhasePlans(group) {
17326
+ const traces = group.selectAll("trace");
17327
+ if (traces.length === 0) return [];
17328
+ return [
17329
+ {
17330
+ routingPhaseIndex: null,
17331
+ traces
17332
+ }
17333
+ ];
17334
+ }
17335
+
17324
17336
  // lib/components/primitive-components/Group/add-port-ids-to-traces-at-jumper-pads.ts
17325
17337
  function getJumperPadInfos(db) {
17326
17338
  const padInfos = [];
@@ -17865,11 +17877,18 @@ var Group6 = class extends NormalComponent3 {
17865
17877
  if (!autorouter.local) return true;
17866
17878
  return false;
17867
17879
  }
17880
+ _getRoutingPhasePlans() {
17881
+ return Group_getRoutingPhasePlans(this);
17882
+ }
17868
17883
  _hasTracesToRoute() {
17869
17884
  const debug11 = Debug13("tscircuit:core:_hasTracesToRoute");
17870
- const traces = this.selectAll("trace");
17871
- debug11(`[${this.getString()}] has ${traces.length} traces to route`);
17872
- return traces.length > 0;
17885
+ const routingPhasePlans = this._getRoutingPhasePlans();
17886
+ let traceCount = 0;
17887
+ for (const routingPhasePlan of routingPhasePlans) {
17888
+ traceCount += routingPhasePlan.traces.length;
17889
+ }
17890
+ debug11(`[${this.getString()}] has ${traceCount} traces to route`);
17891
+ return traceCount > 0;
17873
17892
  }
17874
17893
  async _runEffectMakeHttpAutoroutingRequest() {
17875
17894
  const { db } = this.root;
@@ -19296,7 +19315,7 @@ import { identity as identity5 } from "transformation-matrix";
19296
19315
  var package_default = {
19297
19316
  name: "@tscircuit/core",
19298
19317
  type: "module",
19299
- version: "0.0.1155",
19318
+ version: "0.0.1157",
19300
19319
  types: "dist/index.d.ts",
19301
19320
  main: "dist/index.js",
19302
19321
  module: "dist/index.js",
@@ -23094,83 +23113,77 @@ import {
23094
23113
  } from "@tscircuit/props";
23095
23114
  import { unknown_error_finding_part as unknown_error_finding_part2 } from "circuit-json";
23096
23115
 
23097
- // lib/utils/connectors/rewriteToStandardUsbCPortHints.ts
23098
- var PIN_HINT_RE = /^(?:pin)?(\d+)$/i;
23099
- var USB_C_STANDARD_PORT_HINT_ALIASES = {
23100
- GND1: [],
23101
- VBUS1: [],
23102
- SBU2: [],
23103
- CC1: [],
23104
- DM2: ["DN2"],
23105
- DP1: [],
23106
- DM1: ["DN1"],
23107
- DP2: [],
23108
- SBU1: [],
23109
- CC2: [],
23110
- VBUS2: [],
23111
- GND2: [],
23112
- SHELL1: [],
23113
- SHELL2: [],
23114
- SHELL3: [],
23115
- SHELL4: []
23116
- };
23117
- var unique = (hints) => Array.from(new Set(hints));
23118
- var rewriteToStandardUsbCPortHints = (circuitJson) => {
23119
- const aliasToStandardHint = {};
23120
- for (const [standardHint, aliases] of Object.entries(
23121
- USB_C_STANDARD_PORT_HINT_ALIASES
23122
- )) {
23123
- aliasToStandardHint[standardHint] = standardHint;
23124
- for (const alias of aliases) {
23125
- aliasToStandardHint[alias] = standardHint;
23126
- }
23127
- }
23128
- const sourceAliasesByPin = /* @__PURE__ */ new Map();
23129
- for (const elm of circuitJson) {
23130
- if (elm && typeof elm === "object" && elm.type === "source_port" && typeof elm.pin_number === "number") {
23131
- const pin = elm.pin_number;
23132
- const hints = Array.isArray(elm.port_hints) ? elm.port_hints.filter((h) => typeof h === "string").map((h) => h.trim()).filter((h) => h.length > 0 && !PIN_HINT_RE.test(h)) : [];
23133
- if (hints.length > 0) sourceAliasesByPin.set(pin, unique(hints));
23134
- }
23135
- }
23136
- if (sourceAliasesByPin.size === 0) return circuitJson;
23137
- return circuitJson.map((elm) => {
23138
- if (!elm || typeof elm !== "object" || !("port_hints" in elm)) return elm;
23139
- if (!Array.isArray(elm.port_hints)) return elm;
23116
+ // lib/utils/connectors/convertCircuitJsonToUsbCStandardCircuitJson.ts
23117
+ var STANDARD_USB_C_PIN_LABELS = [
23118
+ { label: "GND1", aliases: [] },
23119
+ { label: "VBUS1", aliases: [] },
23120
+ { label: "CC1", aliases: [] },
23121
+ { label: "DP1", aliases: [] },
23122
+ { label: "DM1", aliases: ["DN1"] },
23123
+ { label: "SBU1", aliases: [] },
23124
+ { label: "SBU2", aliases: [] },
23125
+ { label: "DM2", aliases: ["DN2"] },
23126
+ { label: "DP2", aliases: [] },
23127
+ { label: "CC2", aliases: [] },
23128
+ { label: "VBUS2", aliases: [] },
23129
+ { label: "GND2", aliases: [] },
23130
+ { label: "SHELL1", aliases: ["MH1", "EH1", "MOUNT1"] },
23131
+ { label: "SHELL2", aliases: ["MH2", "EH2", "MOUNT2"] },
23132
+ { label: "SHELL3", aliases: ["MH3", "EH3", "MOUNT3"] },
23133
+ { label: "SHELL4", aliases: ["MH4", "EH4", "MOUNT4"] }
23134
+ ];
23135
+ var PIN_NUMBER_HINT_PATTERN = /^(?:pin)?(\d+)$/i;
23136
+ var dedupeHintsPreservingOrder = (hints) => Array.from(new Set(hints));
23137
+ var convertCircuitJsonToUsbCStandardCircuitJson = (partCircuitJson) => {
23138
+ const unassignedPorts = [];
23139
+ for (const elm of partCircuitJson) {
23140
+ if (elm.type !== "source_port") continue;
23141
+ const pinNumber = elm.pin_number;
23142
+ if (typeof pinNumber !== "number") continue;
23143
+ const upperCaseHints = /* @__PURE__ */ new Set();
23144
+ for (const hint of elm.port_hints ?? []) {
23145
+ upperCaseHints.add(hint.trim().toUpperCase());
23146
+ }
23147
+ unassignedPorts.push({ pinKey: `pin${pinNumber}`, upperCaseHints });
23148
+ }
23149
+ const canonicalHintsByPin = {};
23150
+ for (const { label, aliases } of STANDARD_USB_C_PIN_LABELS) {
23151
+ const canonicalAndAliasHintsUpper = [label, ...aliases].map(
23152
+ (s) => s.toUpperCase()
23153
+ );
23154
+ const matchIndex = unassignedPorts.findIndex(
23155
+ (port) => canonicalAndAliasHintsUpper.some((hint) => port.upperCaseHints.has(hint))
23156
+ );
23157
+ if (matchIndex === -1) continue;
23158
+ const { pinKey } = unassignedPorts[matchIndex];
23159
+ canonicalHintsByPin[pinKey] = [label];
23160
+ unassignedPorts.splice(matchIndex, 1);
23161
+ }
23162
+ if (Object.keys(canonicalHintsByPin).length === 0) return partCircuitJson;
23163
+ return partCircuitJson.map((elm) => {
23164
+ if (!("port_hints" in elm) || !Array.isArray(elm.port_hints)) return elm;
23140
23165
  const originalHints = elm.port_hints.filter((h) => typeof h === "string").map((h) => h.trim()).filter((h) => h.length > 0);
23141
23166
  if (originalHints.length === 0) return elm;
23142
- const pinNumbers = /* @__PURE__ */ new Set();
23167
+ const pinKeys = /* @__PURE__ */ new Set();
23143
23168
  if (elm.type === "source_port" && typeof elm.pin_number === "number") {
23144
- pinNumbers.add(elm.pin_number);
23169
+ pinKeys.add(`pin${elm.pin_number}`);
23145
23170
  }
23146
23171
  for (const hint of originalHints) {
23147
- const m = hint.match(PIN_HINT_RE);
23148
- if (m) pinNumbers.add(Number.parseInt(m[1], 10));
23149
- }
23150
- const sourceAliases = [];
23151
- for (const pin of pinNumbers) {
23152
- sourceAliases.push(...sourceAliasesByPin.get(pin) ?? []);
23153
- }
23154
- const standardHints = /* @__PURE__ */ new Set();
23155
- for (const hint of [...originalHints, ...sourceAliases]) {
23156
- const standard = aliasToStandardHint[hint.toUpperCase()];
23157
- if (standard) standardHints.add(standard);
23158
- }
23159
- const addedHints = [];
23160
- for (const standardHint of standardHints) {
23161
- addedHints.push(
23162
- standardHint,
23163
- ...USB_C_STANDARD_PORT_HINT_ALIASES[standardHint]
23164
- );
23172
+ const matchedPin = hint.match(PIN_NUMBER_HINT_PATTERN);
23173
+ if (!matchedPin) continue;
23174
+ pinKeys.add(`pin${Number.parseInt(matchedPin[1], 10)}`);
23165
23175
  }
23166
- const rewrittenPortHints = unique([
23167
- ...originalHints,
23168
- ...sourceAliases,
23169
- ...addedHints
23170
- ]);
23176
+ const canonicalHintsToAdd = [];
23177
+ for (const pinKey of pinKeys) {
23178
+ canonicalHintsToAdd.push(...canonicalHintsByPin[pinKey] ?? []);
23179
+ }
23180
+ if (canonicalHintsToAdd.length === 0) return elm;
23171
23181
  return {
23172
23182
  ...elm,
23173
- port_hints: rewrittenPortHints
23183
+ port_hints: dedupeHintsPreservingOrder([
23184
+ ...originalHints,
23185
+ ...canonicalHintsToAdd
23186
+ ])
23174
23187
  };
23175
23188
  });
23176
23189
  };
@@ -23316,8 +23329,8 @@ var Connector = class extends Chip {
23316
23329
  });
23317
23330
  }
23318
23331
  _addConnectorFootprintFromCircuitJson(standard, circuitJson) {
23319
- const rewrittenCircuitJson = standard === "usb_c" ? rewriteToStandardUsbCPortHints(circuitJson) : circuitJson;
23320
23332
  const props = this._getConnectorProps();
23333
+ const standardizedCircuitJson = standard === "usb_c" ? convertCircuitJsonToUsbCStandardCircuitJson(circuitJson) : circuitJson;
23321
23334
  const fpComponents = createComponentsFromCircuitJson(
23322
23335
  {
23323
23336
  componentName: this.name,
@@ -23326,7 +23339,7 @@ var Connector = class extends Chip {
23326
23339
  pinLabels: props.pinLabels,
23327
23340
  pcbPinLabels: props.pcbPinLabels
23328
23341
  },
23329
- rewrittenCircuitJson
23342
+ standardizedCircuitJson
23330
23343
  );
23331
23344
  this.addAll(fpComponents);
23332
23345
  this._markDirty("InitializePortsFromChildren");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1156",
4
+ "version": "0.0.1158",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",