@tscircuit/core 0.0.259 → 0.0.261

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 +37 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4178,14 +4178,9 @@ var getOtherSchematicTraces = ({
4178
4178
  import { getUnitVectorFromPointAToB } from "@tscircuit/math-utils";
4179
4179
  var createSchematicTraceCrossingSegments = ({
4180
4180
  edges,
4181
- db,
4182
- source_trace_id
4181
+ otherEdges
4183
4182
  }) => {
4184
- const otherEdges = getOtherSchematicTraces({
4185
- db,
4186
- source_trace_id,
4187
- differentNetOnly: true
4188
- }).flatMap((t) => t.edges);
4183
+ edges = [...edges];
4189
4184
  for (let i = 0; i < edges.length; i++) {
4190
4185
  if (i > 2e3) {
4191
4186
  throw new Error(
@@ -4223,6 +4218,9 @@ var createSchematicTraceCrossingSegments = ({
4223
4218
  }
4224
4219
  const crossingPoint = closestIntersection.crossingPoint;
4225
4220
  const crossingSegmentLength = 0.075;
4221
+ if (crossingPoint.x === edge.from.x && crossingPoint.y === edge.from.y) {
4222
+ continue;
4223
+ }
4226
4224
  const crossingUnitVec = getUnitVectorFromPointAToB(edge.from, crossingPoint);
4227
4225
  const beforeCrossing = {
4228
4226
  x: crossingPoint.x - crossingUnitVec.x * crossingSegmentLength / 2,
@@ -4244,6 +4242,7 @@ var createSchematicTraceCrossingSegments = ({
4244
4242
  i++;
4245
4243
  }
4246
4244
  }
4245
+ return edges;
4247
4246
  };
4248
4247
 
4249
4248
  // lib/components/primitive-components/Trace/create-schematic-trace-junctions.ts
@@ -5034,12 +5033,13 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
5034
5033
  const isFirstPortSchematicBox = firstPort.parent?.config.shouldRenderAsSchematicBox;
5035
5034
  const pinFullName = isFirstPortSchematicBox ? `${firstPort?.parent?.props.name}_${firstPort?.props.name}` : `${secondPort?.parent?.props.name}_${secondPort?.props.name}`;
5036
5035
  const netLabelText = this.props.schDisplayLabel ?? pinFullName;
5037
- if (existingFromNetLabel && existingFromNetLabel.text !== netLabelText || existingToNetLabel && existingToNetLabel?.text !== netLabelText) {
5038
- throw new Error(
5039
- `Cannot create net label "${netLabelText}" for port ${existingFromNetLabel ? fromPortName : toPortName} because it already has a net label with text "${existingFromNetLabel ? existingFromNetLabel.text : existingToNetLabel?.text}".`
5040
- );
5036
+ if (existingFromNetLabel && existingFromNetLabel.text !== netLabelText) {
5037
+ existingFromNetLabel.text = `${netLabelText} / ${existingFromNetLabel.text}`;
5038
+ }
5039
+ if (existingToNetLabel && existingToNetLabel?.text !== netLabelText) {
5040
+ existingToNetLabel.text = `${netLabelText} / ${existingToNetLabel.text}`;
5041
5041
  }
5042
- if (netLabelText?.toLocaleLowerCase().includes("gnd") || netLabelText?.toLocaleLowerCase().includes("ground")) {
5042
+ if (!existingFromNetLabel && !existingToNetLabel && (netLabelText?.toLocaleLowerCase().includes("gnd") || netLabelText?.toLocaleLowerCase().includes("ground"))) {
5043
5043
  createDownwardNetLabelGroundSymbol(
5044
5044
  {
5045
5045
  fromPort,
@@ -5053,20 +5053,24 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
5053
5053
  );
5054
5054
  return;
5055
5055
  }
5056
- db.schematic_net_label.insert({
5057
- text: this.props.schDisplayLabel ?? pinFullName,
5058
- source_net_id: toPort.source_port_id,
5059
- anchor_position: toAnchorPos,
5060
- center: toAnchorPos,
5061
- anchor_side: getEnteringEdgeFromDirection(toPort.facingDirection) ?? "bottom"
5062
- });
5063
- db.schematic_net_label.insert({
5064
- text: this.props.schDisplayLabel ?? pinFullName,
5065
- source_net_id: fromPort.source_port_id,
5066
- anchor_position: fromAnchorPos,
5067
- center: fromAnchorPos,
5068
- anchor_side: getEnteringEdgeFromDirection(fromPort.facingDirection) ?? "bottom"
5069
- });
5056
+ if (!existingToNetLabel) {
5057
+ db.schematic_net_label.insert({
5058
+ text: this.props.schDisplayLabel ?? pinFullName,
5059
+ source_net_id: toPort.source_port_id,
5060
+ anchor_position: toAnchorPos,
5061
+ center: toAnchorPos,
5062
+ anchor_side: getEnteringEdgeFromDirection(toPort.facingDirection) ?? "bottom"
5063
+ });
5064
+ }
5065
+ if (!existingFromNetLabel) {
5066
+ db.schematic_net_label.insert({
5067
+ text: this.props.schDisplayLabel ?? pinFullName,
5068
+ source_net_id: fromPort.source_port_id,
5069
+ anchor_position: fromAnchorPos,
5070
+ center: fromAnchorPos,
5071
+ anchor_side: getEnteringEdgeFromDirection(fromPort.facingDirection) ?? "bottom"
5072
+ });
5073
+ }
5070
5074
  }
5071
5075
  _isSymbolToChipConnection() {
5072
5076
  const { allPortsFound, ports } = this._findConnectedPorts();
@@ -5192,7 +5196,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
5192
5196
  skipOtherTraceInteraction = true;
5193
5197
  }
5194
5198
  const [{ route }] = results;
5195
- const edges = [];
5199
+ let edges = [];
5196
5200
  for (let i = 0; i < route.length - 1; i++) {
5197
5201
  edges.push({
5198
5202
  from: route[i],
@@ -5203,7 +5207,12 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
5203
5207
  let junctions = [];
5204
5208
  if (!skipOtherTraceInteraction) {
5205
5209
  pushEdgesOfSchematicTraceToPreventOverlap({ edges, db, source_trace_id });
5206
- createSchematicTraceCrossingSegments({ edges, db, source_trace_id });
5210
+ const otherEdges = getOtherSchematicTraces({
5211
+ db,
5212
+ source_trace_id,
5213
+ differentNetOnly: true
5214
+ }).flatMap((t) => t.edges);
5215
+ edges = createSchematicTraceCrossingSegments({ edges, otherEdges });
5207
5216
  junctions = createSchematicTraceJunctions({
5208
5217
  edges,
5209
5218
  db,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.259",
4
+ "version": "0.0.261",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",