@tscircuit/core 0.0.157 → 0.0.158
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 +102 -13
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3427,14 +3427,48 @@ import "@tscircuit/math-utils";
|
|
|
3427
3427
|
|
|
3428
3428
|
// lib/components/primitive-components/Trace/push-edges-of-schematic-trace-to-prevent-overlap.ts
|
|
3429
3429
|
import { doesLineIntersectLine } from "@tscircuit/math-utils";
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3430
|
+
|
|
3431
|
+
// lib/components/primitive-components/Trace/get-other-schematic-traces.ts
|
|
3432
|
+
var getOtherSchematicTraces = ({
|
|
3433
|
+
db,
|
|
3434
|
+
source_trace_id,
|
|
3435
|
+
sameNetOnly,
|
|
3436
|
+
differentNetOnly
|
|
3433
3437
|
}) => {
|
|
3434
|
-
|
|
3438
|
+
if (!sameNetOnly && !differentNetOnly) {
|
|
3439
|
+
differentNetOnly = true;
|
|
3440
|
+
}
|
|
3441
|
+
const mySourceTrace = db.source_trace.get(source_trace_id);
|
|
3442
|
+
const traces = [];
|
|
3435
3443
|
for (const otherSchematicTrace of db.schematic_trace.list()) {
|
|
3436
|
-
|
|
3444
|
+
if (otherSchematicTrace.source_trace_id === source_trace_id) continue;
|
|
3445
|
+
const otherSourceTrace = db.source_trace.get(
|
|
3446
|
+
otherSchematicTrace.source_trace_id
|
|
3447
|
+
);
|
|
3448
|
+
const isSameNet = otherSourceTrace?.subcircuit_connectivity_map_key === mySourceTrace.subcircuit_connectivity_map_key;
|
|
3449
|
+
if (differentNetOnly && isSameNet) {
|
|
3450
|
+
continue;
|
|
3451
|
+
}
|
|
3452
|
+
if (sameNetOnly && !isSameNet) {
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
traces.push(otherSchematicTrace);
|
|
3437
3456
|
}
|
|
3457
|
+
return traces;
|
|
3458
|
+
};
|
|
3459
|
+
|
|
3460
|
+
// lib/components/primitive-components/Trace/push-edges-of-schematic-trace-to-prevent-overlap.ts
|
|
3461
|
+
var pushEdgesOfSchematicTraceToPreventOverlap = ({
|
|
3462
|
+
edges,
|
|
3463
|
+
db,
|
|
3464
|
+
source_trace_id
|
|
3465
|
+
}) => {
|
|
3466
|
+
const mySourceTrace = db.source_trace.get(source_trace_id);
|
|
3467
|
+
const otherEdges = getOtherSchematicTraces({
|
|
3468
|
+
db,
|
|
3469
|
+
source_trace_id,
|
|
3470
|
+
differentNetOnly: true
|
|
3471
|
+
}).flatMap((t) => t.edges);
|
|
3438
3472
|
const edgeOrientation = (edge) => {
|
|
3439
3473
|
const { from, to } = edge;
|
|
3440
3474
|
return from.x === to.x ? "vertical" : "horizontal";
|
|
@@ -3468,12 +3502,14 @@ var pushEdgesOfSchematicTraceToPreventOverlap = ({
|
|
|
3468
3502
|
import { doesLineIntersectLine as doesLineIntersectLine2 } from "@tscircuit/math-utils";
|
|
3469
3503
|
var createSchematicTraceCrossingSegments = ({
|
|
3470
3504
|
edges,
|
|
3471
|
-
db
|
|
3505
|
+
db,
|
|
3506
|
+
source_trace_id
|
|
3472
3507
|
}) => {
|
|
3473
|
-
const otherEdges =
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3508
|
+
const otherEdges = getOtherSchematicTraces({
|
|
3509
|
+
db,
|
|
3510
|
+
source_trace_id,
|
|
3511
|
+
differentNetOnly: true
|
|
3512
|
+
}).flatMap((t) => t.edges);
|
|
3477
3513
|
for (let i = 0; i < edges.length; i++) {
|
|
3478
3514
|
const edge = edges[i];
|
|
3479
3515
|
const edgeOrientation = edge.from.x === edge.to.x ? "vertical" : "horizontal";
|
|
@@ -3510,6 +3546,53 @@ var createSchematicTraceCrossingSegments = ({
|
|
|
3510
3546
|
}
|
|
3511
3547
|
};
|
|
3512
3548
|
|
|
3549
|
+
// lib/components/primitive-components/Trace/create-schematic-trace-junctions.ts
|
|
3550
|
+
var isOrthogonal = (edge1, edge2) => {
|
|
3551
|
+
const isVertical1 = edge1.from.x === edge1.to.x;
|
|
3552
|
+
const isVertical2 = edge2.from.x === edge2.to.x;
|
|
3553
|
+
return isVertical1 !== isVertical2;
|
|
3554
|
+
};
|
|
3555
|
+
var getIntersectionPoint = (edge1, edge2) => {
|
|
3556
|
+
if (!isOrthogonal(edge1, edge2)) return null;
|
|
3557
|
+
const isVertical1 = edge1.from.x === edge1.to.x;
|
|
3558
|
+
const vertical = isVertical1 ? edge1 : edge2;
|
|
3559
|
+
const horizontal = isVertical1 ? edge2 : edge1;
|
|
3560
|
+
const minX = Math.min(horizontal.from.x, horizontal.to.x);
|
|
3561
|
+
const maxX = Math.max(horizontal.from.x, horizontal.to.x);
|
|
3562
|
+
if (vertical.from.x < minX || vertical.from.x > maxX) return null;
|
|
3563
|
+
const minY = Math.min(vertical.from.y, vertical.to.y);
|
|
3564
|
+
const maxY = Math.max(vertical.from.y, vertical.to.y);
|
|
3565
|
+
if (horizontal.from.y < minY || horizontal.from.y > maxY) return null;
|
|
3566
|
+
return {
|
|
3567
|
+
x: vertical.from.x,
|
|
3568
|
+
y: horizontal.from.y
|
|
3569
|
+
};
|
|
3570
|
+
};
|
|
3571
|
+
var createSchematicTraceJunctions = ({
|
|
3572
|
+
edges: myEdges,
|
|
3573
|
+
db,
|
|
3574
|
+
source_trace_id
|
|
3575
|
+
}) => {
|
|
3576
|
+
const otherEdges = getOtherSchematicTraces({
|
|
3577
|
+
db,
|
|
3578
|
+
source_trace_id,
|
|
3579
|
+
sameNetOnly: true
|
|
3580
|
+
}).flatMap((t) => t.edges);
|
|
3581
|
+
const junctions = /* @__PURE__ */ new Set();
|
|
3582
|
+
for (const myEdge of myEdges) {
|
|
3583
|
+
for (const otherEdge of otherEdges) {
|
|
3584
|
+
const intersection = getIntersectionPoint(myEdge, otherEdge);
|
|
3585
|
+
if (intersection) {
|
|
3586
|
+
junctions.add(`${intersection.x},${intersection.y}`);
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
return Array.from(junctions).map((key) => {
|
|
3591
|
+
const [x, y] = key.split(",").map(Number);
|
|
3592
|
+
return { x, y };
|
|
3593
|
+
});
|
|
3594
|
+
};
|
|
3595
|
+
|
|
3513
3596
|
// lib/components/primitive-components/Trace/Trace.ts
|
|
3514
3597
|
var portToObjective = (port) => {
|
|
3515
3598
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
@@ -3988,8 +4071,14 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3988
4071
|
to: route[i + 1]
|
|
3989
4072
|
});
|
|
3990
4073
|
}
|
|
3991
|
-
|
|
3992
|
-
|
|
4074
|
+
const source_trace_id = this.source_trace_id;
|
|
4075
|
+
pushEdgesOfSchematicTraceToPreventOverlap({ edges, db, source_trace_id });
|
|
4076
|
+
createSchematicTraceCrossingSegments({ edges, db, source_trace_id });
|
|
4077
|
+
const junctions = createSchematicTraceJunctions({
|
|
4078
|
+
edges,
|
|
4079
|
+
db,
|
|
4080
|
+
source_trace_id: this.source_trace_id
|
|
4081
|
+
});
|
|
3993
4082
|
const lastEdge = edges[edges.length - 1];
|
|
3994
4083
|
const lastEdgePort = portsWithPosition[portsWithPosition.length - 1];
|
|
3995
4084
|
const lastDominantDirection = getDominantDirection(lastEdge);
|
|
@@ -3999,7 +4088,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3999
4088
|
const trace = db.schematic_trace.insert({
|
|
4000
4089
|
source_trace_id: this.source_trace_id,
|
|
4001
4090
|
edges,
|
|
4002
|
-
junctions
|
|
4091
|
+
junctions
|
|
4003
4092
|
});
|
|
4004
4093
|
this.schematic_trace_id = trace.schematic_trace_id;
|
|
4005
4094
|
}
|
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.158",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@tscircuit/soup-util": "^0.0.33",
|
|
46
46
|
"circuit-json": "^0.0.98",
|
|
47
47
|
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
48
|
-
"circuit-to-svg": "^0.0.
|
|
48
|
+
"circuit-to-svg": "^0.0.65",
|
|
49
49
|
"format-si-unit": "^0.0.2",
|
|
50
50
|
"nanoid": "^5.0.7",
|
|
51
51
|
"performance-now": "^2.1.0",
|