@tscircuit/core 0.0.158 → 0.0.159

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.d.ts CHANGED
@@ -4650,7 +4650,6 @@ declare class NetAlias extends PrimitiveComponent<typeof netAliasProps> {
4650
4650
  net?: string | undefined;
4651
4651
  }>;
4652
4652
  };
4653
- initPorts(): void;
4654
4653
  doInitialSchematicComponentRender(): void;
4655
4654
  }
4656
4655
 
package/dist/index.js CHANGED
@@ -3593,6 +3593,16 @@ var createSchematicTraceJunctions = ({
3593
3593
  });
3594
3594
  };
3595
3595
 
3596
+ // lib/utils/schematic/getEnteringEdgeFromDirection.ts
3597
+ var getEnteringEdgeFromDirection = (direction) => {
3598
+ return {
3599
+ up: "bottom",
3600
+ down: "top",
3601
+ left: "right",
3602
+ right: "left"
3603
+ }[direction] ?? null;
3604
+ };
3605
+
3596
3606
  // lib/components/primitive-components/Trace/Trace.ts
3597
3607
  var portToObjective = (port) => {
3598
3608
  const portPosition = port._getGlobalPcbPositionAfterLayout();
@@ -4003,6 +4013,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4003
4013
  const { _parsedProps: props, parent } = this;
4004
4014
  if (!parent) throw new Error("Trace has no parent");
4005
4015
  const { allPortsFound, portsWithSelectors: connectedPorts } = this._findConnectedPorts();
4016
+ const { netsWithSelectors } = this._findConnectedNets();
4006
4017
  if (!allPortsFound) return;
4007
4018
  const obstacles = [];
4008
4019
  const connection = {
@@ -4037,6 +4048,20 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4037
4048
  schematic_port_id: port.schematic_port_id ?? void 0,
4038
4049
  facingDirection: port.facingDirection
4039
4050
  }));
4051
+ const isPortAndNetConnection = portsWithPosition.length === 1 && netsWithSelectors.length === 1;
4052
+ if (isPortAndNetConnection) {
4053
+ const net = netsWithSelectors[0].net;
4054
+ const { port, position: anchorPos } = portsWithPosition[0];
4055
+ const netLabel = db.schematic_net_label.insert({
4056
+ text: net._parsedProps.name,
4057
+ source_net_id: net.source_net_id,
4058
+ anchor_position: anchorPos,
4059
+ // TODO compute the center based on the text size
4060
+ center: anchorPos,
4061
+ anchor_side: getEnteringEdgeFromDirection(port.facingDirection) ?? "bottom"
4062
+ });
4063
+ return;
4064
+ }
4040
4065
  if (portsWithPosition.length < 2) {
4041
4066
  return;
4042
4067
  }
@@ -4545,22 +4570,16 @@ var NetAlias = class extends PrimitiveComponent {
4545
4570
  zodProps: netAliasProps
4546
4571
  };
4547
4572
  }
4548
- initPorts() {
4549
- this.add(
4550
- new Port({
4551
- name: "pin1",
4552
- pinNumber: 1,
4553
- aliases: ["anode", "pos", "left"]
4554
- })
4555
- );
4556
- }
4557
4573
  doInitialSchematicComponentRender() {
4558
4574
  const { db } = this.root;
4559
4575
  const { _parsedProps: props } = this;
4576
+ const anchorPos = { x: props.schX ?? 0, y: props.schY ?? 0 };
4560
4577
  const netAlias = db.schematic_net_label.insert({
4561
4578
  text: props.net,
4562
4579
  source_net_id: props.net,
4563
- center: { x: props.schX ?? 0, y: props.schY ?? 0 },
4580
+ anchor_position: anchorPos,
4581
+ // TODO compute the center based on the text size
4582
+ center: anchorPos,
4564
4583
  anchor_side: "bottom"
4565
4584
  });
4566
4585
  this.source_net_alias_id = netAlias.source_net_id;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.158",
4
+ "version": "0.0.159",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -43,9 +43,9 @@
43
43
  "@tscircuit/props": "^0.0.86",
44
44
  "@tscircuit/schematic-autolayout": "^0.0.5",
45
45
  "@tscircuit/soup-util": "^0.0.33",
46
- "circuit-json": "^0.0.98",
46
+ "circuit-json": "^0.0.99",
47
47
  "circuit-json-to-connectivity-map": "^0.0.17",
48
- "circuit-to-svg": "^0.0.65",
48
+ "circuit-to-svg": "^0.0.67",
49
49
  "format-si-unit": "^0.0.2",
50
50
  "nanoid": "^5.0.7",
51
51
  "performance-now": "^2.1.0",