@tscircuit/core 0.0.148 → 0.0.149
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 +56 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3313,6 +3313,56 @@ function tryNow(fn) {
|
|
|
3313
3313
|
|
|
3314
3314
|
// lib/components/primitive-components/Trace.ts
|
|
3315
3315
|
import "zod";
|
|
3316
|
+
|
|
3317
|
+
// lib/utils/autorouting/getDominantDirection.ts
|
|
3318
|
+
function getDominantDirection(edge) {
|
|
3319
|
+
const delta = {
|
|
3320
|
+
x: edge.to.x - edge.from.x,
|
|
3321
|
+
y: edge.to.y - edge.from.y
|
|
3322
|
+
};
|
|
3323
|
+
const absX = Math.abs(delta.x);
|
|
3324
|
+
const absY = Math.abs(delta.y);
|
|
3325
|
+
if (absX > absY) {
|
|
3326
|
+
return delta.x > 0 ? "right" : "left";
|
|
3327
|
+
}
|
|
3328
|
+
return delta.y > 0 ? "down" : "up";
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
// lib/utils/schematic/getStubEdges.ts
|
|
3332
|
+
var getStubEdges = ({
|
|
3333
|
+
lastEdge,
|
|
3334
|
+
lastEdgePort,
|
|
3335
|
+
lastDominantDirection
|
|
3336
|
+
}) => {
|
|
3337
|
+
const edges = [];
|
|
3338
|
+
if (lastEdge && lastEdgePort) {
|
|
3339
|
+
const intermediatePoint = { x: lastEdge.to.x, y: lastEdge.to.y };
|
|
3340
|
+
if (lastDominantDirection === "left" || lastDominantDirection === "right") {
|
|
3341
|
+
intermediatePoint.x = lastEdgePort.position.x;
|
|
3342
|
+
edges.push({
|
|
3343
|
+
from: lastEdge.to,
|
|
3344
|
+
to: { ...intermediatePoint }
|
|
3345
|
+
});
|
|
3346
|
+
edges.push({
|
|
3347
|
+
from: intermediatePoint,
|
|
3348
|
+
to: { ...lastEdgePort.position }
|
|
3349
|
+
});
|
|
3350
|
+
} else {
|
|
3351
|
+
intermediatePoint.y = lastEdgePort.position.y;
|
|
3352
|
+
edges.push({
|
|
3353
|
+
from: lastEdge.to,
|
|
3354
|
+
to: { ...intermediatePoint }
|
|
3355
|
+
});
|
|
3356
|
+
edges.push({
|
|
3357
|
+
from: intermediatePoint,
|
|
3358
|
+
to: { ...lastEdgePort.position }
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
return edges;
|
|
3363
|
+
};
|
|
3364
|
+
|
|
3365
|
+
// lib/components/primitive-components/Trace.ts
|
|
3316
3366
|
var portToObjective = (port) => {
|
|
3317
3367
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
3318
3368
|
return {
|
|
@@ -3789,6 +3839,12 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3789
3839
|
to: route[i + 1]
|
|
3790
3840
|
});
|
|
3791
3841
|
}
|
|
3842
|
+
const lastEdge = edges[edges.length - 1];
|
|
3843
|
+
const lastEdgePort = portsWithPosition[portsWithPosition.length - 1];
|
|
3844
|
+
const lastDominantDirection = getDominantDirection(lastEdge);
|
|
3845
|
+
edges.push(
|
|
3846
|
+
...getStubEdges({ lastEdge, lastEdgePort, lastDominantDirection })
|
|
3847
|
+
);
|
|
3792
3848
|
const trace = db.schematic_trace.insert({
|
|
3793
3849
|
source_trace_id: this.source_trace_id,
|
|
3794
3850
|
edges
|