@tscircuit/core 0.0.169 → 0.0.170

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.
Files changed (2) hide show
  1. package/dist/index.js +29 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3468,12 +3468,29 @@ function getDominantDirection(edge) {
3468
3468
  }
3469
3469
 
3470
3470
  // lib/utils/schematic/getStubEdges.ts
3471
+ import { distance } from "@tscircuit/math-utils";
3471
3472
  var getStubEdges = ({
3473
+ firstEdge,
3474
+ firstEdgePort,
3475
+ firstDominantDirection,
3472
3476
  lastEdge,
3473
3477
  lastEdgePort,
3474
3478
  lastDominantDirection
3475
3479
  }) => {
3476
- const edges = [];
3480
+ if (firstEdge && firstEdgePort) {
3481
+ return getStubEdges({
3482
+ lastEdge: {
3483
+ from: firstEdge.to,
3484
+ to: firstEdge.from
3485
+ },
3486
+ lastEdgePort: firstEdgePort,
3487
+ lastDominantDirection: firstDominantDirection
3488
+ }).reverse().map((e) => ({
3489
+ from: e.to,
3490
+ to: e.from
3491
+ }));
3492
+ }
3493
+ let edges = [];
3477
3494
  if (lastEdge && lastEdgePort) {
3478
3495
  const intermediatePoint = { x: lastEdge.to.x, y: lastEdge.to.y };
3479
3496
  if (lastDominantDirection === "left" || lastDominantDirection === "right") {
@@ -3498,6 +3515,7 @@ var getStubEdges = ({
3498
3515
  });
3499
3516
  }
3500
3517
  }
3518
+ edges = edges.filter((e) => distance(e.from, e.to) > 0.01);
3501
3519
  return edges;
3502
3520
  };
3503
3521
 
@@ -4195,6 +4213,16 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4195
4213
  edges.push(
4196
4214
  ...getStubEdges({ lastEdge, lastEdgePort, lastDominantDirection })
4197
4215
  );
4216
+ const firstEdge = edges[0];
4217
+ const firstEdgePort = portsWithPosition[0];
4218
+ const firstDominantDirection = getDominantDirection(firstEdge);
4219
+ edges.unshift(
4220
+ ...getStubEdges({
4221
+ firstEdge,
4222
+ firstEdgePort,
4223
+ firstDominantDirection
4224
+ })
4225
+ );
4198
4226
  const trace = db.schematic_trace.insert({
4199
4227
  source_trace_id: this.source_trace_id,
4200
4228
  edges,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.169",
4
+ "version": "0.0.170",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",