@tscircuit/core 0.0.154 → 0.0.155

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 (2) hide show
  1. package/dist/index.js +92 -34
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -3135,7 +3135,7 @@ var stringProxy = new Proxy(
3135
3135
  );
3136
3136
  var FTYPE = stringProxy;
3137
3137
 
3138
- // lib/components/primitive-components/Trace.ts
3138
+ // lib/components/primitive-components/Trace/Trace.ts
3139
3139
  import {
3140
3140
  MultilayerIjump,
3141
3141
  getObstaclesFromSoup as getObstaclesFromSoup2
@@ -3331,7 +3331,7 @@ function tryNow(fn) {
3331
3331
  }
3332
3332
  }
3333
3333
 
3334
- // lib/components/primitive-components/Trace.ts
3334
+ // lib/components/primitive-components/Trace/Trace.ts
3335
3335
  import "zod";
3336
3336
 
3337
3337
  // lib/utils/autorouting/getDominantDirection.ts
@@ -3382,8 +3382,95 @@ var getStubEdges = ({
3382
3382
  return edges;
3383
3383
  };
3384
3384
 
3385
- // lib/components/primitive-components/Trace.ts
3385
+ // lib/components/primitive-components/Trace/Trace.ts
3386
+ import "@tscircuit/math-utils";
3387
+
3388
+ // lib/components/primitive-components/Trace/push-edges-of-schematic-trace-to-prevent-overlap.ts
3386
3389
  import { doesLineIntersectLine } from "@tscircuit/math-utils";
3390
+ var pushEdgesOfSchematicTraceToPreventOverlap = ({
3391
+ edges,
3392
+ db
3393
+ }) => {
3394
+ const otherEdges = [];
3395
+ for (const otherSchematicTrace of db.schematic_trace.list()) {
3396
+ otherEdges.push(...otherSchematicTrace.edges);
3397
+ }
3398
+ const edgeOrientation = (edge) => {
3399
+ const { from, to } = edge;
3400
+ return from.x === to.x ? "vertical" : "horizontal";
3401
+ };
3402
+ for (const mySegment of edges) {
3403
+ const mySegmentOrientation = edgeOrientation(mySegment);
3404
+ const findOverlappingParallelSegment = () => otherEdges.find(
3405
+ (otherEdge) => edgeOrientation(otherEdge) === mySegmentOrientation && doesLineIntersectLine(
3406
+ [mySegment.from, mySegment.to],
3407
+ [otherEdge.from, otherEdge.to],
3408
+ {
3409
+ lineThickness: 0.01
3410
+ }
3411
+ )
3412
+ );
3413
+ let overlappingParallelSegmentFromOtherTrace = findOverlappingParallelSegment();
3414
+ while (overlappingParallelSegmentFromOtherTrace) {
3415
+ if (mySegmentOrientation === "horizontal") {
3416
+ mySegment.from.y += 0.1;
3417
+ mySegment.to.y += 0.1;
3418
+ } else {
3419
+ mySegment.from.x += 0.1;
3420
+ mySegment.to.x += 0.1;
3421
+ }
3422
+ overlappingParallelSegmentFromOtherTrace = findOverlappingParallelSegment();
3423
+ }
3424
+ }
3425
+ };
3426
+
3427
+ // lib/components/primitive-components/Trace/create-schematic-trace-crossing-segments.ts
3428
+ import { doesLineIntersectLine as doesLineIntersectLine2 } from "@tscircuit/math-utils";
3429
+ var createSchematicTraceCrossingSegments = ({
3430
+ edges,
3431
+ db
3432
+ }) => {
3433
+ const otherEdges = [];
3434
+ for (const otherSchematicTrace of db.schematic_trace.list()) {
3435
+ otherEdges.push(...otherSchematicTrace.edges);
3436
+ }
3437
+ for (let i = 0; i < edges.length; i++) {
3438
+ const edge = edges[i];
3439
+ const edgeOrientation = edge.from.x === edge.to.x ? "vertical" : "horizontal";
3440
+ for (const otherEdge of otherEdges) {
3441
+ const otherOrientation = otherEdge.from.x === otherEdge.to.x ? "vertical" : "horizontal";
3442
+ if (edgeOrientation === otherOrientation) continue;
3443
+ const intersection = doesLineIntersectLine2(
3444
+ [edge.from, edge.to],
3445
+ [otherEdge.from, otherEdge.to],
3446
+ { lineThickness: 0.01 }
3447
+ );
3448
+ if (intersection) {
3449
+ const intersectX = edgeOrientation === "vertical" ? edge.from.x : otherEdge.from.x;
3450
+ const intersectY = edgeOrientation === "vertical" ? otherEdge.from.y : edge.from.y;
3451
+ const crossingSegmentLength = 0.1;
3452
+ const crossingPoint = { x: intersectX, y: intersectY };
3453
+ const beforeCrossing = {
3454
+ x: edgeOrientation === "vertical" ? crossingPoint.x : crossingPoint.x - crossingSegmentLength / 2,
3455
+ y: edgeOrientation === "vertical" ? crossingPoint.y - crossingSegmentLength / 2 : crossingPoint.y
3456
+ };
3457
+ const afterCrossing = {
3458
+ x: edgeOrientation === "vertical" ? crossingPoint.x : crossingPoint.x + crossingSegmentLength / 2,
3459
+ y: edgeOrientation === "vertical" ? crossingPoint.y + crossingSegmentLength / 2 : crossingPoint.y
3460
+ };
3461
+ const newEdges = [
3462
+ { from: edge.from, to: beforeCrossing },
3463
+ { from: beforeCrossing, to: afterCrossing, is_crossing: true },
3464
+ { from: afterCrossing, to: edge.to }
3465
+ ];
3466
+ edges.splice(i, 1, ...newEdges);
3467
+ i += 2;
3468
+ }
3469
+ }
3470
+ }
3471
+ };
3472
+
3473
+ // lib/components/primitive-components/Trace/Trace.ts
3387
3474
  var portToObjective = (port) => {
3388
3475
  const portPosition = port._getGlobalPcbPositionAfterLayout();
3389
3476
  return {
@@ -3860,37 +3947,8 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
3860
3947
  to: route[i + 1]
3861
3948
  });
3862
3949
  }
3863
- const otherEdges = [];
3864
- for (const otherSchematicTrace of db.schematic_trace.list()) {
3865
- otherEdges.push(...otherSchematicTrace.edges);
3866
- }
3867
- const edgeOrientation = (edge) => {
3868
- const { from, to } = edge;
3869
- return from.x === to.x ? "vertical" : "horizontal";
3870
- };
3871
- for (const mySegment of edges) {
3872
- const mySegmentOrientation = edgeOrientation(mySegment);
3873
- const findOverlappingParallelSegment = () => otherEdges.find(
3874
- (otherEdge) => edgeOrientation(otherEdge) === mySegmentOrientation && doesLineIntersectLine(
3875
- [mySegment.from, mySegment.to],
3876
- [otherEdge.from, otherEdge.to],
3877
- {
3878
- lineThickness: 0.01
3879
- }
3880
- )
3881
- );
3882
- let overlappingParallelSegmentFromOtherTrace = findOverlappingParallelSegment();
3883
- while (overlappingParallelSegmentFromOtherTrace) {
3884
- if (mySegmentOrientation === "horizontal") {
3885
- mySegment.from.y += 0.1;
3886
- mySegment.to.y += 0.1;
3887
- } else {
3888
- mySegment.from.x += 0.1;
3889
- mySegment.to.x += 0.1;
3890
- }
3891
- overlappingParallelSegmentFromOtherTrace = findOverlappingParallelSegment();
3892
- }
3893
- }
3950
+ pushEdgesOfSchematicTraceToPreventOverlap({ edges, db });
3951
+ createSchematicTraceCrossingSegments({ edges, db });
3894
3952
  const lastEdge = edges[edges.length - 1];
3895
3953
  const lastEdgePort = portsWithPosition[portsWithPosition.length - 1];
3896
3954
  const lastDominantDirection = getDominantDirection(lastEdge);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.154",
4
+ "version": "0.0.155",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -43,7 +43,7 @@
43
43
  "@tscircuit/props": "^0.0.86",
44
44
  "@tscircuit/schematic-autolayout": "^0.0.5",
45
45
  "@tscircuit/soup-util": "^0.0.33",
46
- "circuit-json": "^0.0.96",
46
+ "circuit-json": "^0.0.97",
47
47
  "circuit-json-to-connectivity-map": "^0.0.17",
48
48
  "circuit-to-svg": "^0.0.62",
49
49
  "format-si-unit": "^0.0.2",