@tscircuit/hypergraph 0.0.28 → 0.0.30

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 +219 -31
  2. package/dist/index.js +10835 -1272
  3. package/package.json +2 -1
package/dist/index.d.ts CHANGED
@@ -292,7 +292,7 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
292
292
  _step(): void;
293
293
  }
294
294
 
295
- type Bounds$1 = {
295
+ type Bounds$2 = {
296
296
  minX: number;
297
297
  minY: number;
298
298
  maxX: number;
@@ -301,7 +301,7 @@ type Bounds$1 = {
301
301
 
302
302
  interface JRegion extends Region {
303
303
  d: {
304
- bounds: Bounds$1;
304
+ bounds: Bounds$2;
305
305
  center: {
306
306
  x: number;
307
307
  y: number;
@@ -383,7 +383,7 @@ declare class JumperGraphSolver extends HyperGraphSolver<JRegion, JPort> {
383
383
  visualize(): GraphicsObject;
384
384
  }
385
385
 
386
- declare const calculateGraphBounds: (regions: JRegion[]) => Bounds$1;
386
+ declare const calculateGraphBounds: (regions: JRegion[]) => Bounds$2;
387
387
 
388
388
  type XYConnection = {
389
389
  start: {
@@ -479,7 +479,7 @@ type SharedBoundary = {
479
479
  };
480
480
  type RegionData = {
481
481
  id: string;
482
- bounds: Bounds$1 | null;
482
+ bounds: Bounds$2 | null;
483
483
  polygon: {
484
484
  x: number;
485
485
  y: number;
@@ -520,7 +520,7 @@ declare class RegionBuilder implements RegionRef {
520
520
  private data;
521
521
  constructor(id: string);
522
522
  get id(): string;
523
- rect(b: Bounds$1): this;
523
+ rect(b: Bounds$2): this;
524
524
  polygon(points: {
525
525
  x: number;
526
526
  y: number;
@@ -549,7 +549,7 @@ declare class ConnectBuilder {
549
549
  private portIds;
550
550
  private boundary;
551
551
  private prefixWasExplicitlySet;
552
- constructor(region1Id: string, region2Id: string, bounds1: Bounds$1, bounds2: Bounds$1, addPortFn: AddPortFn$1, prefixIdFn: PrefixIdFn, opts?: {
552
+ constructor(region1Id: string, region2Id: string, bounds1: Bounds$2, bounds2: Bounds$2, addPortFn: AddPortFn$1, prefixIdFn: PrefixIdFn, opts?: {
553
553
  idPrefix?: string;
554
554
  tolerance?: number;
555
555
  });
@@ -569,7 +569,7 @@ declare class ConnectBuilder {
569
569
 
570
570
  type ResolveRegionFn = (ref: RegionRef | string) => {
571
571
  id: string;
572
- bounds: Bounds$1;
572
+ bounds: Bounds$2;
573
573
  };
574
574
  type AddPortFn = (port: PortData) => void;
575
575
  declare class PortBuilder {
@@ -625,6 +625,117 @@ declare class Topology {
625
625
  getPortIds(): string[];
626
626
  }
627
627
 
628
+ var Net6 = [
629
+ {
630
+ viaId: "4ef04070-bacf-4a8a-8ac9-ea222cf4bf2c",
631
+ diameter: 0.6,
632
+ position: {
633
+ x: 1.483834,
634
+ y: 0.582296
635
+ }
636
+ },
637
+ {
638
+ viaId: "79364d38-c966-4eff-aa4a-e3ff6cca6339",
639
+ diameter: 0.6,
640
+ position: {
641
+ x: -0.8,
642
+ y: -1.893395
643
+ }
644
+ },
645
+ {
646
+ viaId: "f1d52fd5-ddd2-4440-8772-da3d096b033f",
647
+ diameter: 0.6,
648
+ position: {
649
+ x: -0.703066,
650
+ y: 1.2
651
+ }
652
+ }
653
+ ];
654
+ var Net5 = [
655
+ {
656
+ viaId: "4e57cee8-0910-4c83-9ec1-1ed2c9d16dcc",
657
+ diameter: 0.6,
658
+ position: {
659
+ x: 1.268717,
660
+ y: -1.698536
661
+ }
662
+ },
663
+ {
664
+ viaId: "a3797f13-73f9-48c3-a448-bea3980cdd65",
665
+ diameter: 0.6,
666
+ position: {
667
+ x: -1.115754,
668
+ y: -0.799377
669
+ }
670
+ },
671
+ {
672
+ viaId: "b0c56bb1-ea80-4154-9bb7-cb0fd760de8f",
673
+ diameter: 0.6,
674
+ position: {
675
+ x: 0.397934,
676
+ y: 1.458567
677
+ }
678
+ }
679
+ ];
680
+ var Net7 = [
681
+ {
682
+ viaId: "3719876b-17c8-4ee3-9cce-5b5c073d6614",
683
+ diameter: 0.6,
684
+ position: {
685
+ x: 1.186721,
686
+ y: 1.32508
687
+ }
688
+ },
689
+ {
690
+ viaId: "4e46d759-a04a-4f7e-99cd-9e05adf5fa23",
691
+ diameter: 0.6,
692
+ position: {
693
+ x: -1.275,
694
+ y: 0
695
+ }
696
+ },
697
+ {
698
+ viaId: "63afce65-b94e-47da-ae14-51ff0ee8eb39",
699
+ diameter: 0.6,
700
+ position: {
701
+ x: 1.655408,
702
+ y: -0.998198
703
+ }
704
+ }
705
+ ];
706
+ var Net8 = [
707
+ {
708
+ viaId: "26d3bef1-a78f-4947-b551-c48f04289a98",
709
+ diameter: 0.6,
710
+ position: {
711
+ x: 1.553029,
712
+ y: -0.164505
713
+ }
714
+ },
715
+ {
716
+ viaId: "548acbca-8b68-4186-a589-681ec44fba42",
717
+ diameter: 0.6,
718
+ position: {
719
+ x: 0.222457,
720
+ y: -1.866711
721
+ }
722
+ },
723
+ {
724
+ viaId: "d6bf60bf-4b90-4967-a295-fc930b1f2549",
725
+ diameter: 0.6,
726
+ position: {
727
+ x: -1.419706,
728
+ y: 0.868747
729
+ }
730
+ }
731
+ ];
732
+ var viasByNet = {
733
+ Net6: Net6,
734
+ Net5: Net5,
735
+ Net7: Net7,
736
+ Net8: Net8
737
+ };
738
+
628
739
  declare const VIA_GRAPH_SOLVER_DEFAULTS: {
629
740
  portUsagePenalty: number;
630
741
  portUsagePenaltySq: number;
@@ -674,6 +785,98 @@ declare class ViaGraphSolver extends HyperGraphSolver<JRegion, JPort> {
674
785
  visualize(): GraphicsObject;
675
786
  }
676
787
 
788
+ type Bounds$1 = {
789
+ minX: number;
790
+ maxX: number;
791
+ minY: number;
792
+ maxY: number;
793
+ };
794
+ /**
795
+ * Generates a tiled grid of via topologies with outer frame regions.
796
+ *
797
+ * The via tiles are centered within the given bounds. If the bounds are smaller
798
+ * than one tile, no via tiles are created - only outer frame regions.
799
+ *
800
+ * The outer frame consists of rectangular regions (T, B, L, R) that fill the
801
+ * space between the tiled area and the problem bounds.
802
+ */
803
+ declare function generateViaTopologyGrid(opts: {
804
+ viasByNet: ViasByNet;
805
+ bounds: Bounds$1;
806
+ tileSize?: number;
807
+ portPitch?: number;
808
+ }): {
809
+ regions: JRegion[];
810
+ ports: JPort[];
811
+ tiledViasByNet: ViasByNet;
812
+ tileCount: {
813
+ rows: number;
814
+ cols: number;
815
+ };
816
+ };
817
+
818
+ /**
819
+ * Generates four outer topology regions (top, bottom, left, right) that wrap
820
+ * around all vias, forming a closed frame that extends to the graph boundary.
821
+ *
822
+ * Each region is a polygon whose inner edge follows the extreme via edges
823
+ * (connected by straight diagonal lines between segments), and whose outer
824
+ * edge is the graph boundary.
825
+ */
826
+ declare const generateViaTopologyRegions: (viasByNet: ViasByNet, opts?: {
827
+ graphSize?: number;
828
+ idPrefix?: string;
829
+ }) => {
830
+ regions: JRegion[];
831
+ ports: JPort[];
832
+ };
833
+
834
+ declare function generateDefaultViaTopologyRegions(opts: Parameters<typeof generateViaTopologyRegions>[1]): {
835
+ regions: JRegion[];
836
+ ports: JPort[];
837
+ };
838
+ declare function generateDefaultViaTopologyGrid(opts: Omit<Parameters<typeof generateViaTopologyGrid>[0], "viasByNet">): {
839
+ regions: JRegion[];
840
+ ports: JPort[];
841
+ tiledViasByNet: ViasByNet;
842
+ tileCount: {
843
+ rows: number;
844
+ cols: number;
845
+ };
846
+ };
847
+
848
+ type ConvexViaGraphFromXYConnectionsResult = JumperGraph & {
849
+ connections: Connection[];
850
+ tiledViasByNet: ViasByNet;
851
+ tileCount: {
852
+ rows: number;
853
+ cols: number;
854
+ };
855
+ };
856
+ /**
857
+ * Creates a complete via topology graph from XY connections using convex regions.
858
+ *
859
+ * This function uses ConvexRegionsSolver to compute convex regions around
860
+ * via region obstacles, instead of the manual T/B/L/R outer regions.
861
+ *
862
+ * It:
863
+ * 1. Calculates bounds from connection XY coordinates (no margin)
864
+ * 2. Generates per-net via region polygons on a tiled grid
865
+ * 3. Uses ConvexRegionsSolver to compute convex regions around via regions
866
+ * 4. Creates ports between adjacent convex regions and via regions
867
+ * 5. Attaches connection regions to the graph
868
+ *
869
+ * @param xyConnections - Array of connections with start/end XY coordinates
870
+ * @param viasByNet - Via positions grouped by net name (defaults to built-in vias-by-net.json)
871
+ * @param opts - Optional configuration
872
+ */
873
+ declare function createConvexViaGraphFromXYConnections(xyConnections: XYConnection[], viasByNet?: ViasByNet, opts?: {
874
+ tileSize?: number;
875
+ portPitch?: number;
876
+ clearance?: number;
877
+ concavityTolerance?: number;
878
+ }): ConvexViaGraphFromXYConnectionsResult;
879
+
677
880
  type ViaGraphFromXYConnectionsResult = JumperGraph & {
678
881
  connections: Connection[];
679
882
  tiledViasByNet: ViasByNet;
@@ -721,19 +924,20 @@ type Bounds = {
721
924
  maxY: number;
722
925
  };
723
926
  /**
724
- * Generates a tiled grid of via topologies with outer frame regions.
927
+ * Generates a via topology using convex regions computed by ConvexRegionsSolver.
725
928
  *
726
- * The via tiles are centered within the given bounds. If the bounds are smaller
727
- * than one tile, no via tiles are created - only outer frame regions.
728
- *
729
- * The outer frame consists of rectangular regions (T, B, L, R) that fill the
730
- * space between the tiled area and the problem bounds.
929
+ * 1. Via tiles are placed on a grid (5mm tiles by default)
930
+ * 2. Per-net via region polygons are created within each tile
931
+ * 3. Convex regions are computed globally with via region polygons as obstacles
932
+ * 4. Ports are created between adjacent convex regions and between convex/via regions
731
933
  */
732
- declare function generateViaTopologyGrid(opts: {
934
+ declare function generateConvexViaTopologyRegions(opts: {
733
935
  viasByNet: ViasByNet;
734
936
  bounds: Bounds;
735
937
  tileSize?: number;
736
938
  portPitch?: number;
939
+ clearance?: number;
940
+ concavityTolerance?: number;
737
941
  }): {
738
942
  regions: JRegion[];
739
943
  ports: JPort[];
@@ -744,20 +948,4 @@ declare function generateViaTopologyGrid(opts: {
744
948
  };
745
949
  };
746
950
 
747
- /**
748
- * Generates four outer topology regions (top, bottom, left, right) that wrap
749
- * around all vias, forming a closed frame that extends to the graph boundary.
750
- *
751
- * Each region is a polygon whose inner edge follows the extreme via edges
752
- * (connected by straight diagonal lines between segments), and whose outer
753
- * edge is the graph boundary.
754
- */
755
- declare const generateViaTopologyRegions: (viasByNet: ViasByNet, opts?: {
756
- graphSize?: number;
757
- idPrefix?: string;
758
- }) => {
759
- regions: JRegion[];
760
- ports: JPort[];
761
- };
762
-
763
- export { type Bounds$1 as Bounds, type BuildOpts, type Candidate, ConnectBuilder, type ConnectOpts, type Connection, type ConnectionId, type GScore, type GraphEdgeId, type HyperGraph, HyperGraphSolver, type JPort, type JRegion, JUMPER_GRAPH_SOLVER_DEFAULTS, type JumperGraph, JumperGraphSolver, type JumperGraphWithConnections, type NetworkId, type PortAssignment, PortBuilder, type PortData, type PortId, type PortSpread, type Region, RegionBuilder, type RegionData, type RegionId, type RegionPort, type RegionPortAssignment, type RegionRef, type SerializedConnection, type SerializedGraphPort, type SerializedGraphRegion, type SerializedHyperGraph, type SerializedRegionPortAssignment, type SharedBoundary, type SolvedRoute, Topology, TopologyError, VIA_GRAPH_SOLVER_DEFAULTS, type ValidateOpts, type ViaData, type ViaGraphFromXYConnectionsResult, ViaGraphSolver, type ViaGraphWithConnections, type ViasByNet, type XYConnection, applyTransformToGraph, calculateGraphBounds, convertConnectionsToSerializedConnections, convertHyperGraphToSerializedHyperGraph, createGraphWithConnectionsFromBaseGraph, createViaGraphFromXYConnections, createViaGraphWithConnections, generateJumperGrid, generateJumperX4Grid, generateViaTopologyGrid, generateViaTopologyRegions, rotateGraph90Degrees };
951
+ export { type Bounds$2 as Bounds, type BuildOpts, type Candidate, ConnectBuilder, type ConnectOpts, type Connection, type ConnectionId, type ConvexViaGraphFromXYConnectionsResult, type GScore, type GraphEdgeId, type HyperGraph, HyperGraphSolver, type JPort, type JRegion, JUMPER_GRAPH_SOLVER_DEFAULTS, type JumperGraph, JumperGraphSolver, type JumperGraphWithConnections, type NetworkId, type PortAssignment, PortBuilder, type PortData, type PortId, type PortSpread, type Region, RegionBuilder, type RegionData, type RegionId, type RegionPort, type RegionPortAssignment, type RegionRef, type SerializedConnection, type SerializedGraphPort, type SerializedGraphRegion, type SerializedHyperGraph, type SerializedRegionPortAssignment, type SharedBoundary, type SolvedRoute, Topology, TopologyError, VIA_GRAPH_SOLVER_DEFAULTS, type ValidateOpts, type ViaData, type ViaGraphFromXYConnectionsResult, ViaGraphSolver, type ViaGraphWithConnections, type ViasByNet, type XYConnection, applyTransformToGraph, calculateGraphBounds, convertConnectionsToSerializedConnections, convertHyperGraphToSerializedHyperGraph, createConvexViaGraphFromXYConnections, createGraphWithConnectionsFromBaseGraph, createViaGraphFromXYConnections, createViaGraphWithConnections, generateConvexViaTopologyRegions, generateDefaultViaTopologyGrid, generateDefaultViaTopologyRegions, generateJumperGrid, generateJumperX4Grid, generateViaTopologyGrid, generateViaTopologyRegions, rotateGraph90Degrees, viasByNet };