@tscircuit/core 0.0.123 → 0.0.124
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 +53 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1645,12 +1645,14 @@ var Port = class extends PrimitiveComponent {
|
|
|
1645
1645
|
const { _parsedProps: props } = this;
|
|
1646
1646
|
const container = this.getPrimitiveContainer();
|
|
1647
1647
|
if (!container) return;
|
|
1648
|
+
const containerCenter = container._getGlobalSchematicPositionBeforeLayout();
|
|
1648
1649
|
let center = this._getGlobalSchematicPositionBeforeLayout();
|
|
1649
1650
|
if ("schematicDimensions" in container && props.pinNumber !== void 0) {
|
|
1650
1651
|
const chipDims = container.schematicDimensions;
|
|
1651
1652
|
center = chipDims.getPortPositionByPinNumber(props.pinNumber);
|
|
1653
|
+
center.x += containerCenter.x;
|
|
1654
|
+
center.y += containerCenter.y;
|
|
1652
1655
|
}
|
|
1653
|
-
const containerCenter = container._getGlobalSchematicPositionBeforeLayout();
|
|
1654
1656
|
this.facingDirection = getRelativeDirection(containerCenter, center);
|
|
1655
1657
|
const schematic_port = db.schematic_port.insert({
|
|
1656
1658
|
schematic_component_id: this.parent?.schematic_component_id,
|
|
@@ -2522,22 +2524,6 @@ var computeObstacleBounds = (obstacles) => {
|
|
|
2522
2524
|
return { minX, maxX, minY, maxY };
|
|
2523
2525
|
};
|
|
2524
2526
|
|
|
2525
|
-
// lib/utils/projectPointInDirection.ts
|
|
2526
|
-
var projectPointInDirection = (point, direction, distance) => {
|
|
2527
|
-
switch (direction) {
|
|
2528
|
-
case "up":
|
|
2529
|
-
return { x: point.x, y: point.y - distance };
|
|
2530
|
-
case "down":
|
|
2531
|
-
return { x: point.x, y: point.y + distance };
|
|
2532
|
-
case "left":
|
|
2533
|
-
return { x: point.x - distance, y: point.y };
|
|
2534
|
-
case "right":
|
|
2535
|
-
return { x: point.x + distance, y: point.y };
|
|
2536
|
-
default:
|
|
2537
|
-
throw new Error(`Unknown direction "${direction}"`);
|
|
2538
|
-
}
|
|
2539
|
-
};
|
|
2540
|
-
|
|
2541
2527
|
// lib/utils/autorouting/findPossibleTraceLayerCombinations.ts
|
|
2542
2528
|
var LAYER_SELECTION_PREFERENCE = ["top", "bottom", "inner1", "inner2"];
|
|
2543
2529
|
var findPossibleTraceLayerCombinations = (hints, layer_path = []) => {
|
|
@@ -2685,6 +2671,45 @@ function tryNow(fn) {
|
|
|
2685
2671
|
|
|
2686
2672
|
// lib/components/primitive-components/Trace.ts
|
|
2687
2673
|
import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map";
|
|
2674
|
+
|
|
2675
|
+
// lib/utils/autorouting/DirectLineRouter.ts
|
|
2676
|
+
var DirectLineRouter = class {
|
|
2677
|
+
input;
|
|
2678
|
+
constructor({ input }) {
|
|
2679
|
+
this.input = input;
|
|
2680
|
+
}
|
|
2681
|
+
solveAndMapToTraces() {
|
|
2682
|
+
const traces = [];
|
|
2683
|
+
for (const connection of this.input.connections) {
|
|
2684
|
+
if (connection.pointsToConnect.length !== 2) continue;
|
|
2685
|
+
const [start, end] = connection.pointsToConnect;
|
|
2686
|
+
const trace = {
|
|
2687
|
+
type: "pcb_trace",
|
|
2688
|
+
pcb_trace_id: "",
|
|
2689
|
+
route: [
|
|
2690
|
+
{
|
|
2691
|
+
route_type: "wire",
|
|
2692
|
+
x: start.x,
|
|
2693
|
+
y: start.y,
|
|
2694
|
+
layer: "top",
|
|
2695
|
+
width: 0.1
|
|
2696
|
+
},
|
|
2697
|
+
{
|
|
2698
|
+
route_type: "wire",
|
|
2699
|
+
x: end.x,
|
|
2700
|
+
y: end.y,
|
|
2701
|
+
layer: "top",
|
|
2702
|
+
width: 0.1
|
|
2703
|
+
}
|
|
2704
|
+
]
|
|
2705
|
+
};
|
|
2706
|
+
traces.push(trace);
|
|
2707
|
+
}
|
|
2708
|
+
return traces;
|
|
2709
|
+
}
|
|
2710
|
+
};
|
|
2711
|
+
|
|
2712
|
+
// lib/components/primitive-components/Trace.ts
|
|
2688
2713
|
var portToObjective = (port) => {
|
|
2689
2714
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
2690
2715
|
return {
|
|
@@ -3110,11 +3135,12 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3110
3135
|
}
|
|
3111
3136
|
for (const { port } of ports) {
|
|
3112
3137
|
connection.pointsToConnect.push({
|
|
3113
|
-
...
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3138
|
+
...port._getGlobalSchematicPositionAfterLayout(),
|
|
3139
|
+
// ...projectPointInDirection(
|
|
3140
|
+
// port._getGlobalSchematicPositionAfterLayout(),
|
|
3141
|
+
// port.facingDirection!,
|
|
3142
|
+
// 0.1501,
|
|
3143
|
+
// ),
|
|
3118
3144
|
layer: "top"
|
|
3119
3145
|
});
|
|
3120
3146
|
}
|
|
@@ -3127,7 +3153,11 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3127
3153
|
bounds,
|
|
3128
3154
|
layerCount: 1
|
|
3129
3155
|
};
|
|
3130
|
-
|
|
3156
|
+
let Autorouter = IJumpAutorouter;
|
|
3157
|
+
if (this.getSubcircuit().props._schDirectLineRoutingEnabled) {
|
|
3158
|
+
Autorouter = DirectLineRouter;
|
|
3159
|
+
}
|
|
3160
|
+
const autorouter = new Autorouter({
|
|
3131
3161
|
input: simpleRouteJsonInput
|
|
3132
3162
|
});
|
|
3133
3163
|
const results = autorouter.solveAndMapToTraces();
|