@tscircuit/schematic-trace-solver 0.0.32 → 0.0.33

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 (28) hide show
  1. package/dist/index.d.ts +24 -53
  2. package/dist/index.js +492 -831
  3. package/lib/index.ts +1 -0
  4. package/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts +54 -3
  5. package/lib/solvers/MspConnectionPairSolver/doesPairCrossRestrictedCenterLines.ts +62 -0
  6. package/lib/solvers/MspConnectionPairSolver/getMspConnectionPairsFromPins.ts +7 -2
  7. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceLinesSolver.ts +3 -10
  8. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +239 -0
  9. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions.ts +57 -0
  10. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/mid.ts +97 -0
  11. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/pathOps.ts +65 -0
  12. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/rect.ts +19 -0
  13. package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +14 -14
  14. package/package.json +1 -1
  15. package/site/examples/example09.page.tsx +1 -1
  16. package/tests/examples/__snapshots__/example01.snap.svg +29 -29
  17. package/tests/examples/__snapshots__/example02.snap.svg +13 -10
  18. package/tests/examples/__snapshots__/example04.snap.svg +12 -12
  19. package/tests/examples/__snapshots__/example05.snap.svg +38 -38
  20. package/tests/examples/__snapshots__/example06.snap.svg +14 -14
  21. package/tests/examples/__snapshots__/example08.snap.svg +29 -23
  22. package/tests/examples/__snapshots__/example09.snap.svg +119 -149
  23. package/tests/examples/__snapshots__/example11.snap.svg +39 -33
  24. package/tests/examples/__snapshots__/example12.snap.svg +32 -29
  25. package/tests/examples/__snapshots__/example13.snap.svg +87 -84
  26. package/tests/examples/__snapshots__/example15.snap.svg +57 -57
  27. package/tests/examples/__snapshots__/example16.snap.svg +3 -3
  28. package/tests/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver_repro03.test.ts +1 -0
package/dist/index.d.ts CHANGED
@@ -121,64 +121,38 @@ declare class MspConnectionPairSolver extends BaseSolver {
121
121
  visualize(): GraphicsObject;
122
122
  }
123
123
 
124
- type Guideline = {
125
- orientation: "horizontal";
126
- y: number;
127
- x: undefined;
128
- } | {
129
- orientation: "vertical";
130
- y: undefined;
131
- x: number;
124
+ type ChipWithBounds = {
125
+ chipId: string;
126
+ minX: number;
127
+ minY: number;
128
+ maxX: number;
129
+ maxY: number;
132
130
  };
133
- declare class GuidelinesSolver extends BaseSolver {
134
- inputProblem: InputProblem;
135
- guidelines: Guideline[];
136
- chipPairsGenerator: Generator<readonly [InputChip, InputChip]>;
137
- usedXGuidelines: Set<number>;
138
- usedYGuidelines: Set<number>;
139
- constructor(params: {
140
- inputProblem: InputProblem;
141
- });
142
- getConstructorParams(): ConstructorParameters<typeof GuidelinesSolver>[0];
143
- _step(): void;
144
- visualize(): GraphicsObject;
145
- }
146
-
147
- interface MovableSegment {
148
- start: Point;
149
- end: Point;
150
- freedom: "x+" | "x-" | "y+" | "y-";
151
- dir: {
152
- x: number;
153
- y: number;
154
- };
155
- }
156
131
 
157
- type ChipPin = InputPin & {
158
- chipId: ChipId;
159
- };
160
- declare class SchematicTraceSingleLineSolver extends BaseSolver {
132
+ declare class SchematicTraceSingleLineSolver2 extends BaseSolver {
161
133
  pins: MspConnectionPair["pins"];
162
134
  inputProblem: InputProblem;
163
- guidelines: Guideline[];
164
135
  chipMap: Record<string, InputChip>;
165
- movableSegments: Array<MovableSegment>;
136
+ obstacles: ChipWithBounds[];
137
+ rectById: Map<string, ChipWithBounds>;
138
+ aabb: {
139
+ minX: number;
140
+ maxX: number;
141
+ minY: number;
142
+ maxY: number;
143
+ };
166
144
  baseElbow: Point[];
167
- allCandidatePaths: Array<Point[]>;
168
- queuedCandidatePaths: Array<Point[]>;
169
- chipObstacleSpatialIndex: ChipObstacleSpatialIndex;
170
- solvedTracePath: {
171
- x: number;
172
- y: number;
173
- }[] | null;
174
- pinIdMap: Map<PinId, ChipPin>;
145
+ solvedTracePath: Point[] | null;
146
+ private queue;
147
+ private visited;
175
148
  constructor(params: {
176
149
  pins: MspConnectionPair["pins"];
177
- guidelines: Guideline[];
178
150
  inputProblem: InputProblem;
179
151
  chipMap: Record<string, InputChip>;
180
152
  });
181
- getConstructorParams(): ConstructorParameters<typeof SchematicTraceSingleLineSolver>[0];
153
+ getConstructorParams(): ConstructorParameters<typeof SchematicTraceSingleLineSolver2>[0];
154
+ private axisOfSegment;
155
+ private pathLength;
182
156
  _step(): void;
183
157
  visualize(): GraphicsObject;
184
158
  }
@@ -190,7 +164,6 @@ interface SolvedTracePath extends MspConnectionPair {
190
164
  }
191
165
  declare class SchematicTraceLinesSolver extends BaseSolver {
192
166
  inputProblem: InputProblem;
193
- guidelines: Guideline[];
194
167
  mspConnectionPairs: MspConnectionPair[];
195
168
  dcConnMap: ConnectivityMap;
196
169
  globalConnMap: ConnectivityMap;
@@ -201,14 +174,13 @@ declare class SchematicTraceLinesSolver extends BaseSolver {
201
174
  failedConnectionPairs: Array<MspConnectionPair & {
202
175
  error?: string;
203
176
  }>;
204
- activeSubSolver: SchematicTraceSingleLineSolver | null;
177
+ activeSubSolver: SchematicTraceSingleLineSolver2 | null;
205
178
  constructor(params: {
206
179
  mspConnectionPairs: MspConnectionPair[];
207
180
  chipMap: Record<string, InputChip>;
208
181
  dcConnMap: ConnectivityMap;
209
182
  globalConnMap: ConnectivityMap;
210
183
  inputProblem: InputProblem;
211
- guidelines: Guideline[];
212
184
  });
213
185
  getConstructorParams(): ConstructorParameters<typeof SchematicTraceLinesSolver>[0];
214
186
  _step(): void;
@@ -419,7 +391,6 @@ type PipelineStep<T extends new (...args: any[]) => BaseSolver> = {
419
391
  };
420
392
  declare class SchematicTracePipelineSolver extends BaseSolver {
421
393
  mspConnectionPairSolver?: MspConnectionPairSolver;
422
- guidelinesSolver?: GuidelinesSolver;
423
394
  schematicTraceLinesSolver?: SchematicTraceLinesSolver;
424
395
  traceOverlapShiftSolver?: TraceOverlapShiftSolver;
425
396
  netLabelPlacementSolver?: NetLabelPlacementSolver;
@@ -428,7 +399,7 @@ declare class SchematicTracePipelineSolver extends BaseSolver {
428
399
  timeSpentOnPhase: Record<string, number>;
429
400
  firstIterationOfPhase: Record<string, number>;
430
401
  inputProblem: InputProblem;
431
- pipelineDef: (PipelineStep<typeof MspConnectionPairSolver> | PipelineStep<typeof GuidelinesSolver> | PipelineStep<typeof SchematicTraceLinesSolver> | PipelineStep<typeof TraceOverlapShiftSolver> | PipelineStep<typeof NetLabelPlacementSolver>)[];
402
+ pipelineDef: (PipelineStep<typeof MspConnectionPairSolver> | PipelineStep<typeof SchematicTraceLinesSolver> | PipelineStep<typeof TraceOverlapShiftSolver> | PipelineStep<typeof NetLabelPlacementSolver>)[];
432
403
  constructor(inputProblem: InputProblem);
433
404
  getConstructorParams(): ConstructorParameters<typeof SchematicTracePipelineSolver>[0];
434
405
  currentPipelineStepIndex: number;
@@ -444,4 +415,4 @@ declare class SchematicTracePipelineSolver extends BaseSolver {
444
415
  preview(): GraphicsObject;
445
416
  }
446
417
 
447
- export { type ChipId, type InputChip, type InputDirectConnection, type InputNetConnection, type InputPin, type InputProblem, type NetId, type PinId, SchematicTracePipelineSolver };
418
+ export { type ChipId, type InputChip, type InputDirectConnection, type InputNetConnection, type InputPin, type InputProblem, type NetId, type PinId, SchematicTracePipelineSolver, SchematicTraceSingleLineSolver2 };