@tscircuit/core 0.0.153 → 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.
- package/dist/index.js +93 -3
- 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,7 +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
|
|
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
|
|
3386
3474
|
var portToObjective = (port) => {
|
|
3387
3475
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
3388
3476
|
return {
|
|
@@ -3859,6 +3947,8 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3859
3947
|
to: route[i + 1]
|
|
3860
3948
|
});
|
|
3861
3949
|
}
|
|
3950
|
+
pushEdgesOfSchematicTraceToPreventOverlap({ edges, db });
|
|
3951
|
+
createSchematicTraceCrossingSegments({ edges, db });
|
|
3862
3952
|
const lastEdge = edges[edges.length - 1];
|
|
3863
3953
|
const lastEdgePort = portsWithPosition[portsWithPosition.length - 1];
|
|
3864
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.
|
|
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.
|
|
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",
|