@tscircuit/core 0.0.156 → 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 +112 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2048,6 +2048,14 @@ var getAllDimensionsForSchematicBox = (params) => {
|
|
|
2048
2048
|
sideLengths.bottom + params.schPinSpacing * 2
|
|
2049
2049
|
);
|
|
2050
2050
|
}
|
|
2051
|
+
const labelWidth = params.pinLabels ? Math.max(
|
|
2052
|
+
...Object.values(params.pinLabels).map(
|
|
2053
|
+
(label) => label.length * 0.1
|
|
2054
|
+
// Estimated text width
|
|
2055
|
+
)
|
|
2056
|
+
) : 0;
|
|
2057
|
+
const LABEL_PADDING = 1.1;
|
|
2058
|
+
schWidth = Math.max(schWidth, labelWidth + LABEL_PADDING);
|
|
2051
2059
|
let schHeight = params.schHeight;
|
|
2052
2060
|
if (!schHeight) {
|
|
2053
2061
|
schHeight = Math.max(
|
|
@@ -2806,7 +2814,8 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2806
2814
|
schPinSpacing: pinSpacing,
|
|
2807
2815
|
schPinStyle: props.schPinStyle,
|
|
2808
2816
|
pinCount,
|
|
2809
|
-
schPortArrangement: this._getSchematicPortArrangement()
|
|
2817
|
+
schPortArrangement: this._getSchematicPortArrangement(),
|
|
2818
|
+
pinLabels: props.pinLabels
|
|
2810
2819
|
});
|
|
2811
2820
|
return dimensions;
|
|
2812
2821
|
}
|
|
@@ -3418,14 +3427,48 @@ import "@tscircuit/math-utils";
|
|
|
3418
3427
|
|
|
3419
3428
|
// lib/components/primitive-components/Trace/push-edges-of-schematic-trace-to-prevent-overlap.ts
|
|
3420
3429
|
import { doesLineIntersectLine } from "@tscircuit/math-utils";
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
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
|
|
3424
3437
|
}) => {
|
|
3425
|
-
|
|
3438
|
+
if (!sameNetOnly && !differentNetOnly) {
|
|
3439
|
+
differentNetOnly = true;
|
|
3440
|
+
}
|
|
3441
|
+
const mySourceTrace = db.source_trace.get(source_trace_id);
|
|
3442
|
+
const traces = [];
|
|
3426
3443
|
for (const otherSchematicTrace of db.schematic_trace.list()) {
|
|
3427
|
-
|
|
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);
|
|
3428
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);
|
|
3429
3472
|
const edgeOrientation = (edge) => {
|
|
3430
3473
|
const { from, to } = edge;
|
|
3431
3474
|
return from.x === to.x ? "vertical" : "horizontal";
|
|
@@ -3459,12 +3502,14 @@ var pushEdgesOfSchematicTraceToPreventOverlap = ({
|
|
|
3459
3502
|
import { doesLineIntersectLine as doesLineIntersectLine2 } from "@tscircuit/math-utils";
|
|
3460
3503
|
var createSchematicTraceCrossingSegments = ({
|
|
3461
3504
|
edges,
|
|
3462
|
-
db
|
|
3505
|
+
db,
|
|
3506
|
+
source_trace_id
|
|
3463
3507
|
}) => {
|
|
3464
|
-
const otherEdges =
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3508
|
+
const otherEdges = getOtherSchematicTraces({
|
|
3509
|
+
db,
|
|
3510
|
+
source_trace_id,
|
|
3511
|
+
differentNetOnly: true
|
|
3512
|
+
}).flatMap((t) => t.edges);
|
|
3468
3513
|
for (let i = 0; i < edges.length; i++) {
|
|
3469
3514
|
const edge = edges[i];
|
|
3470
3515
|
const edgeOrientation = edge.from.x === edge.to.x ? "vertical" : "horizontal";
|
|
@@ -3501,6 +3546,53 @@ var createSchematicTraceCrossingSegments = ({
|
|
|
3501
3546
|
}
|
|
3502
3547
|
};
|
|
3503
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
|
+
|
|
3504
3596
|
// lib/components/primitive-components/Trace/Trace.ts
|
|
3505
3597
|
var portToObjective = (port) => {
|
|
3506
3598
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
@@ -3979,8 +4071,14 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3979
4071
|
to: route[i + 1]
|
|
3980
4072
|
});
|
|
3981
4073
|
}
|
|
3982
|
-
|
|
3983
|
-
|
|
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
|
+
});
|
|
3984
4082
|
const lastEdge = edges[edges.length - 1];
|
|
3985
4083
|
const lastEdgePort = portsWithPosition[portsWithPosition.length - 1];
|
|
3986
4084
|
const lastDominantDirection = getDominantDirection(lastEdge);
|
|
@@ -3990,7 +4088,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3990
4088
|
const trace = db.schematic_trace.insert({
|
|
3991
4089
|
source_trace_id: this.source_trace_id,
|
|
3992
4090
|
edges,
|
|
3993
|
-
junctions
|
|
4091
|
+
junctions
|
|
3994
4092
|
});
|
|
3995
4093
|
this.schematic_trace_id = trace.schematic_trace_id;
|
|
3996
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",
|