@tscircuit/core 0.0.123 → 0.0.125

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 +73 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -43,6 +43,7 @@ __export(components_exports, {
43
43
  // lib/components/base-components/NormalComponent.ts
44
44
  import { fp } from "@tscircuit/footprinter";
45
45
  import { point3, rotation } from "circuit-json";
46
+ import Debug2 from "debug";
46
47
 
47
48
  // lib/fiber/create-instance-from-react-element.ts
48
49
  import ReactReconciler from "react-reconciler";
@@ -1645,12 +1646,14 @@ var Port = class extends PrimitiveComponent {
1645
1646
  const { _parsedProps: props } = this;
1646
1647
  const container = this.getPrimitiveContainer();
1647
1648
  if (!container) return;
1649
+ const containerCenter = container._getGlobalSchematicPositionBeforeLayout();
1648
1650
  let center = this._getGlobalSchematicPositionBeforeLayout();
1649
1651
  if ("schematicDimensions" in container && props.pinNumber !== void 0) {
1650
1652
  const chipDims = container.schematicDimensions;
1651
1653
  center = chipDims.getPortPositionByPinNumber(props.pinNumber);
1654
+ center.x += containerCenter.x;
1655
+ center.y += containerCenter.y;
1652
1656
  }
1653
- const containerCenter = container._getGlobalSchematicPositionBeforeLayout();
1654
1657
  this.facingDirection = getRelativeDirection(containerCenter, center);
1655
1658
  const schematic_port = db.schematic_port.insert({
1656
1659
  schematic_component_id: this.parent?.schematic_component_id,
@@ -1901,7 +1904,6 @@ var Footprint = class extends PrimitiveComponent {
1901
1904
  };
1902
1905
 
1903
1906
  // lib/components/base-components/NormalComponent.ts
1904
- import Debug2 from "debug";
1905
1907
  var debug2 = Debug2("tscircuit:core");
1906
1908
  var rotation3 = z4.object({
1907
1909
  x: rotation,
@@ -1952,6 +1954,23 @@ var NormalComponent = class extends PrimitiveComponent {
1952
1954
  }
1953
1955
  }
1954
1956
  }
1957
+ const sides = ["left", "right", "top", "bottom"];
1958
+ let pinNum = 1;
1959
+ for (const side of sides) {
1960
+ const size = schPortArrangement[`${side}Size`];
1961
+ for (let i = 0; i < size; i++) {
1962
+ portsToCreate.push(
1963
+ new Port(
1964
+ {
1965
+ pinNumber: pinNum++
1966
+ },
1967
+ {
1968
+ originDescription: `schPortArrangement:${side}`
1969
+ }
1970
+ )
1971
+ );
1972
+ }
1973
+ }
1955
1974
  }
1956
1975
  const pinLabels = this._parsedProps.pinLabels;
1957
1976
  if (pinLabels) {
@@ -2522,22 +2541,6 @@ var computeObstacleBounds = (obstacles) => {
2522
2541
  return { minX, maxX, minY, maxY };
2523
2542
  };
2524
2543
 
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
2544
  // lib/utils/autorouting/findPossibleTraceLayerCombinations.ts
2542
2545
  var LAYER_SELECTION_PREFERENCE = ["top", "bottom", "inner1", "inner2"];
2543
2546
  var findPossibleTraceLayerCombinations = (hints, layer_path = []) => {
@@ -2685,6 +2688,45 @@ function tryNow(fn) {
2685
2688
 
2686
2689
  // lib/components/primitive-components/Trace.ts
2687
2690
  import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map";
2691
+
2692
+ // lib/utils/autorouting/DirectLineRouter.ts
2693
+ var DirectLineRouter = class {
2694
+ input;
2695
+ constructor({ input }) {
2696
+ this.input = input;
2697
+ }
2698
+ solveAndMapToTraces() {
2699
+ const traces = [];
2700
+ for (const connection of this.input.connections) {
2701
+ if (connection.pointsToConnect.length !== 2) continue;
2702
+ const [start, end] = connection.pointsToConnect;
2703
+ const trace = {
2704
+ type: "pcb_trace",
2705
+ pcb_trace_id: "",
2706
+ route: [
2707
+ {
2708
+ route_type: "wire",
2709
+ x: start.x,
2710
+ y: start.y,
2711
+ layer: "top",
2712
+ width: 0.1
2713
+ },
2714
+ {
2715
+ route_type: "wire",
2716
+ x: end.x,
2717
+ y: end.y,
2718
+ layer: "top",
2719
+ width: 0.1
2720
+ }
2721
+ ]
2722
+ };
2723
+ traces.push(trace);
2724
+ }
2725
+ return traces;
2726
+ }
2727
+ };
2728
+
2729
+ // lib/components/primitive-components/Trace.ts
2688
2730
  var portToObjective = (port) => {
2689
2731
  const portPosition = port._getGlobalPcbPositionAfterLayout();
2690
2732
  return {
@@ -3110,11 +3152,12 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
3110
3152
  }
3111
3153
  for (const { port } of ports) {
3112
3154
  connection.pointsToConnect.push({
3113
- ...projectPointInDirection(
3114
- port._getGlobalSchematicPositionAfterLayout(),
3115
- port.facingDirection,
3116
- 0.1501
3117
- ),
3155
+ ...port._getGlobalSchematicPositionAfterLayout(),
3156
+ // ...projectPointInDirection(
3157
+ // port._getGlobalSchematicPositionAfterLayout(),
3158
+ // port.facingDirection!,
3159
+ // 0.1501,
3160
+ // ),
3118
3161
  layer: "top"
3119
3162
  });
3120
3163
  }
@@ -3127,7 +3170,11 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
3127
3170
  bounds,
3128
3171
  layerCount: 1
3129
3172
  };
3130
- const autorouter = new IJumpAutorouter({
3173
+ let Autorouter = IJumpAutorouter;
3174
+ if (this.getSubcircuit().props._schDirectLineRoutingEnabled) {
3175
+ Autorouter = DirectLineRouter;
3176
+ }
3177
+ const autorouter = new Autorouter({
3131
3178
  input: simpleRouteJsonInput
3132
3179
  });
3133
3180
  const results = autorouter.solveAndMapToTraces();
@@ -3507,14 +3554,14 @@ var Chip = class extends NormalComponent {
3507
3554
  doInitialSchematicComponentRender() {
3508
3555
  const { db } = this.root;
3509
3556
  const { _parsedProps: props } = this;
3510
- const ports = this.children.filter((child) => child instanceof Port);
3557
+ const pinCount = (props.schPortArrangement?.leftSize ?? 0) + (props.schPortArrangement?.rightSize ?? 0) + (props.schPortArrangement?.topSize ?? 0) + (props.schPortArrangement?.bottomSize ?? 0);
3511
3558
  const pinSpacing = props.schPinSpacing ?? 0.2;
3512
3559
  const dimensions = getAllDimensionsForSchematicBox({
3513
3560
  schWidth: props.schWidth,
3514
3561
  schHeight: props.schHeight,
3515
3562
  schPinSpacing: pinSpacing,
3516
3563
  schPinStyle: props.schPinStyle,
3517
- pinCount: ports.length,
3564
+ pinCount,
3518
3565
  // @ts-ignore there's a subtley in the definition difference with
3519
3566
  // leftSide/rightSide/topSide/bottomSide in how the direction is defined
3520
3567
  // that doesn't really matter
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.123",
4
+ "version": "0.0.125",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",