@tscircuit/schematic-trace-solver 0.0.151 → 0.0.153

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
@@ -59,6 +59,11 @@ type NetId = string;
59
59
  type SectionId = string;
60
60
  interface InputPin {
61
61
  pinId: PinId;
62
+ /**
63
+ * User-facing label for this schematic port. `pinId` remains the stable,
64
+ * opaque routing identity and must not be shown in schematic output.
65
+ */
66
+ displayName?: string;
62
67
  x: number;
63
68
  y: number;
64
69
  _facingDirection?: "x+" | "x-" | "y+" | "y-";
@@ -103,11 +108,11 @@ interface InputDirectConnection {
103
108
  netLabelText?: string;
104
109
  netLabelWidth?: number;
105
110
  /**
106
- * Width of the conventional anchored label to use only when an inline label
107
- * cannot be placed. Unlike `netLabelWidth`, this does not affect whether or
108
- * how the point-to-point connection is routed.
111
+ * Width of the conventional label anchored to a trace endpoint. Unlike
112
+ * `netLabelWidth`, this does not affect whether or how the point-to-point
113
+ * connection is routed.
109
114
  */
110
- fallbackNetLabelWidth?: number;
115
+ anchoredNetLabelWidth?: number;
111
116
  /**
112
117
  * When true, this point-to-point connection may be labeled with an "inline
113
118
  * net label": the net name is drawn parallel to (and offset from) the routed
@@ -144,7 +149,7 @@ interface InputNetConnection {
144
149
  */
145
150
  netLabelText?: string;
146
151
  netLabelWidth?: number;
147
- fallbackNetLabelWidth?: number;
152
+ anchoredNetLabelWidth?: number;
148
153
  netLabelHeight?: number;
149
154
  /**
150
155
  * When true, a named one- or two-pin net may use inline labels. A single-pin
package/dist/index.js CHANGED
@@ -168,7 +168,7 @@ var visualizeInputProblem = (inputProblem, opts = {}) => {
168
168
  });
169
169
  for (const pin of chip.pins) {
170
170
  graphics.points.push({
171
- label: `${pin.pinId}
171
+ label: `${pin.displayName ?? pin.pinId}
172
172
  ${pin._facingDirection ?? getPinDirection(pin, chip)}`,
173
173
  x: pin.x,
174
174
  y: pin.y,
@@ -679,21 +679,20 @@ import "graphics-debug";
679
679
  import { calculateElbow as calculateElbow2 } from "calculate-elbow";
680
680
 
681
681
  // lib/utils/getNetLabelWidthForConnection.ts
682
- var getConfiguredWidth = (connections, includeFallbackNetLabelWidth) => {
683
- const explicitWidth = connections.find(
682
+ var getConfiguredWidth = (connections, isPortOnlyLabel2) => {
683
+ const width = connections.find(
684
684
  (connection) => connection?.netLabelWidth !== void 0
685
685
  )?.netLabelWidth;
686
- if (explicitWidth !== void 0) return explicitWidth;
687
- if (!includeFallbackNetLabelWidth) return void 0;
686
+ if (width !== void 0 || !isPortOnlyLabel2) return width;
688
687
  return connections.find(
689
- (connection) => connection?.fallbackNetLabelWidth !== void 0
690
- )?.fallbackNetLabelWidth;
688
+ (connection) => connection?.anchoredNetLabelWidth !== void 0
689
+ )?.anchoredNetLabelWidth;
691
690
  };
692
691
  var getNetLabelWidthForConnection = ({
693
692
  inputProblem,
694
693
  netId,
695
694
  pinIds,
696
- includeFallbackNetLabelWidth = true
695
+ isPortOnlyLabel: isPortOnlyLabel2
697
696
  }) => {
698
697
  if (netId) {
699
698
  const widthByNetId = getConfiguredWidth(
@@ -705,7 +704,7 @@ var getNetLabelWidthForConnection = ({
705
704
  (connection) => connection.netId === netId
706
705
  )
707
706
  ],
708
- includeFallbackNetLabelWidth
707
+ isPortOnlyLabel2
709
708
  );
710
709
  if (widthByNetId !== void 0) return widthByNetId;
711
710
  }
@@ -718,7 +717,7 @@ var getNetLabelWidthForConnection = ({
718
717
  (connection) => connection.pinIds.some((pinId) => pinIds.includes(pinId))
719
718
  )
720
719
  ],
721
- includeFallbackNetLabelWidth
720
+ isPortOnlyLabel2
722
721
  );
723
722
  };
724
723
 
@@ -1329,7 +1328,7 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver {
1329
1328
  inputProblem: this.inputProblem,
1330
1329
  netId,
1331
1330
  pinIds: this.pins.map((pin) => pin.pinId),
1332
- includeFallbackNetLabelWidth: false
1331
+ isPortOnlyLabel: false
1333
1332
  });
1334
1333
  const netLabelHeight = this.getNetLabelHeightForConnectionPair(netId);
1335
1334
  const padding = {
@@ -3270,7 +3269,8 @@ var NetLabelPlacementSolver = class extends BaseSolver {
3270
3269
  return getNetLabelWidthForConnection({
3271
3270
  inputProblem: this.inputProblem,
3272
3271
  netId: group.netId,
3273
- pinIds
3272
+ pinIds,
3273
+ isPortOnlyLabel: group.portOnlyPinId !== void 0
3274
3274
  });
3275
3275
  }
3276
3276
  getNetLabelHeightForGroup(group) {
@@ -8620,7 +8620,8 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
8620
8620
  const blockedLabelWidth = getNetLabelWidthForConnection({
8621
8621
  inputProblem: this.inputProblem,
8622
8622
  netId: blockedLabel.netId,
8623
- pinIds: blockedLabel.pinIds
8623
+ pinIds: blockedLabel.pinIds,
8624
+ isPortOnlyLabel: this.isPortOnlyLabel(blockedLabel)
8624
8625
  });
8625
8626
  let columnLabelIndex;
8626
8627
  if (blockedLabelWidth !== void 0) {
@@ -8630,7 +8631,8 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
8630
8631
  return getNetLabelWidthForConnection({
8631
8632
  inputProblem: this.inputProblem,
8632
8633
  netId: label.netId,
8633
- pinIds: label.pinIds
8634
+ pinIds: label.pinIds,
8635
+ isPortOnlyLabel: this.isPortOnlyLabel(label)
8634
8636
  }) === blockedLabelWidth;
8635
8637
  });
8636
8638
  }
@@ -8855,7 +8857,8 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
8855
8857
  netLabelWidth: getNetLabelWidthForConnection({
8856
8858
  inputProblem: this.inputProblem,
8857
8859
  netId: label.netId,
8858
- pinIds: label.pinIds
8860
+ pinIds: label.pinIds,
8861
+ isPortOnlyLabel: this.isPortOnlyLabel(label)
8859
8862
  }),
8860
8863
  netLabelHeight: this.getNetLabelHeight(label)
8861
8864
  });
@@ -9293,7 +9296,8 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
9293
9296
  netLabelWidth: getNetLabelWidthForConnection({
9294
9297
  inputProblem: this.inputProblem,
9295
9298
  netId: label.netId,
9296
- pinIds: label.pinIds
9299
+ pinIds: label.pinIds,
9300
+ isPortOnlyLabel: this.isPortOnlyLabel(label)
9297
9301
  }),
9298
9302
  netLabelHeight: this.getNetLabelHeight(label)
9299
9303
  });
@@ -9315,7 +9319,8 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
9315
9319
  netLabelWidth: getNetLabelWidthForConnection({
9316
9320
  inputProblem: this.inputProblem,
9317
9321
  netId: label.netId,
9318
- pinIds: label.pinIds
9322
+ pinIds: label.pinIds,
9323
+ isPortOnlyLabel: this.isPortOnlyLabel(label)
9319
9324
  }),
9320
9325
  netLabelHeight: this.getNetLabelHeight(label)
9321
9326
  });
@@ -9374,7 +9379,8 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
9374
9379
  netLabelWidth: getNetLabelWidthForConnection({
9375
9380
  inputProblem: this.inputProblem,
9376
9381
  netId: label.netId,
9377
- pinIds: label.pinIds
9382
+ pinIds: label.pinIds,
9383
+ isPortOnlyLabel: this.isPortOnlyLabel(label)
9378
9384
  }),
9379
9385
  netLabelHeight: this.getNetLabelHeight(label)
9380
9386
  });
@@ -9429,7 +9435,8 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
9429
9435
  netLabelWidth: getNetLabelWidthForConnection({
9430
9436
  inputProblem: this.inputProblem,
9431
9437
  netId: label.netId,
9432
- pinIds: label.pinIds
9438
+ pinIds: label.pinIds,
9439
+ isPortOnlyLabel: this.isPortOnlyLabel(label)
9433
9440
  }),
9434
9441
  netLabelHeight: this.getNetLabelHeight(label)
9435
9442
  });
@@ -10643,7 +10650,8 @@ var getNetLabelWidth = (inputProblem, label) => {
10643
10650
  const configuredWidth = getNetLabelWidthForConnection({
10644
10651
  inputProblem,
10645
10652
  netId: label.netId,
10646
- pinIds: label.pinIds
10653
+ pinIds: label.pinIds,
10654
+ isPortOnlyLabel: label.mspConnectionPairIds.length === 0
10647
10655
  });
10648
10656
  if (configuredWidth !== void 0) return configuredWidth;
10649
10657
  if (label.orientation === "y+" || label.orientation === "y-") {
@@ -185,6 +185,7 @@ export class AvailableNetOrientationSolver extends BaseSolver {
185
185
  inputProblem: this.inputProblem,
186
186
  netId: blockedLabel.netId,
187
187
  pinIds: blockedLabel.pinIds,
188
+ isPortOnlyLabel: this.isPortOnlyLabel(blockedLabel),
188
189
  })
189
190
  let columnLabelIndex: number | undefined
190
191
  if (blockedLabelWidth !== undefined) {
@@ -196,6 +197,7 @@ export class AvailableNetOrientationSolver extends BaseSolver {
196
197
  inputProblem: this.inputProblem,
197
198
  netId: label.netId,
198
199
  pinIds: label.pinIds,
200
+ isPortOnlyLabel: this.isPortOnlyLabel(label),
199
201
  }) === blockedLabelWidth
200
202
  )
201
203
  })
@@ -496,6 +498,7 @@ export class AvailableNetOrientationSolver extends BaseSolver {
496
498
  inputProblem: this.inputProblem,
497
499
  netId: label.netId,
498
500
  pinIds: label.pinIds,
501
+ isPortOnlyLabel: this.isPortOnlyLabel(label),
499
502
  }),
500
503
  netLabelHeight: this.getNetLabelHeight(label),
501
504
  })
@@ -1113,6 +1116,7 @@ export class AvailableNetOrientationSolver extends BaseSolver {
1113
1116
  inputProblem: this.inputProblem,
1114
1117
  netId: label.netId,
1115
1118
  pinIds: label.pinIds,
1119
+ isPortOnlyLabel: this.isPortOnlyLabel(label),
1116
1120
  }),
1117
1121
  netLabelHeight: this.getNetLabelHeight(label),
1118
1122
  })
@@ -1141,6 +1145,7 @@ export class AvailableNetOrientationSolver extends BaseSolver {
1141
1145
  inputProblem: this.inputProblem,
1142
1146
  netId: label.netId,
1143
1147
  pinIds: label.pinIds,
1148
+ isPortOnlyLabel: this.isPortOnlyLabel(label),
1144
1149
  }),
1145
1150
  netLabelHeight: this.getNetLabelHeight(label),
1146
1151
  })
@@ -1224,6 +1229,7 @@ export class AvailableNetOrientationSolver extends BaseSolver {
1224
1229
  inputProblem: this.inputProblem,
1225
1230
  netId: label.netId,
1226
1231
  pinIds: label.pinIds,
1232
+ isPortOnlyLabel: this.isPortOnlyLabel(label),
1227
1233
  }),
1228
1234
  netLabelHeight: this.getNetLabelHeight(label),
1229
1235
  })
@@ -1309,6 +1315,7 @@ export class AvailableNetOrientationSolver extends BaseSolver {
1309
1315
  inputProblem: this.inputProblem,
1310
1316
  netId: label.netId,
1311
1317
  pinIds: label.pinIds,
1318
+ isPortOnlyLabel: this.isPortOnlyLabel(label),
1312
1319
  }),
1313
1320
  netLabelHeight: this.getNetLabelHeight(label),
1314
1321
  })
@@ -286,6 +286,7 @@ export class NetLabelPlacementSolver extends BaseSolver {
286
286
  inputProblem: this.inputProblem,
287
287
  netId: group.netId,
288
288
  pinIds,
289
+ isPortOnlyLabel: group.portOnlyPinId !== undefined,
289
290
  })
290
291
  }
291
292
 
@@ -206,7 +206,7 @@ export class SchematicTraceSingleLineSolver2 extends BaseSolver {
206
206
  inputProblem: this.inputProblem,
207
207
  netId,
208
208
  pinIds: this.pins.map((pin) => pin.pinId),
209
- includeFallbackNetLabelWidth: false,
209
+ isPortOnlyLabel: false,
210
210
  })
211
211
  const netLabelHeight = this.getNetLabelHeightForConnectionPair(netId)
212
212
  const padding: Required<RectPadding> = {
@@ -44,7 +44,7 @@ export const visualizeInputProblem = (
44
44
 
45
45
  for (const pin of chip.pins) {
46
46
  graphics.points.push({
47
- label: `${pin.pinId}\n${pin._facingDirection ?? getPinDirection(pin, chip)}`,
47
+ label: `${pin.displayName ?? pin.pinId}\n${pin._facingDirection ?? getPinDirection(pin, chip)}`,
48
48
  x: pin.x,
49
49
  y: pin.y,
50
50
  color: getColorFromString(pin.pinId, 0.8),
@@ -315,6 +315,7 @@ const getNetLabelWidth = (
315
315
  inputProblem,
316
316
  netId: label.netId,
317
317
  pinIds: label.pinIds,
318
+ isPortOnlyLabel: label.mspConnectionPairIds.length === 0,
318
319
  })
319
320
  if (configuredWidth !== undefined) return configuredWidth
320
321
 
@@ -8,6 +8,13 @@ export type SectionId = string
8
8
 
9
9
  export interface InputPin {
10
10
  pinId: PinId
11
+
12
+ /**
13
+ * User-facing label for this schematic port. `pinId` remains the stable,
14
+ * opaque routing identity and must not be shown in schematic output.
15
+ */
16
+ displayName?: string
17
+
11
18
  x: number
12
19
  y: number
13
20
 
@@ -53,11 +60,11 @@ export interface InputDirectConnection {
53
60
  netLabelWidth?: number
54
61
 
55
62
  /**
56
- * Width of the conventional anchored label to use only when an inline label
57
- * cannot be placed. Unlike `netLabelWidth`, this does not affect whether or
58
- * how the point-to-point connection is routed.
63
+ * Width of the conventional label anchored to a trace endpoint. Unlike
64
+ * `netLabelWidth`, this does not affect whether or how the point-to-point
65
+ * connection is routed.
59
66
  */
60
- fallbackNetLabelWidth?: number
67
+ anchoredNetLabelWidth?: number
61
68
 
62
69
  /**
63
70
  * When true, this point-to-point connection may be labeled with an "inline
@@ -99,7 +106,7 @@ export interface InputNetConnection {
99
106
  */
100
107
  netLabelText?: string
101
108
  netLabelWidth?: number
102
- fallbackNetLabelWidth?: number
109
+ anchoredNetLabelWidth?: number
103
110
  netLabelHeight?: number
104
111
 
105
112
  /**
@@ -10,29 +10,28 @@ type ConnectionWithLabelWidth = InputDirectConnection | InputNetConnection
10
10
 
11
11
  const getConfiguredWidth = (
12
12
  connections: Array<ConnectionWithLabelWidth | undefined>,
13
- includeFallbackNetLabelWidth: boolean,
13
+ isPortOnlyLabel: boolean,
14
14
  ) => {
15
- const explicitWidth = connections.find(
15
+ const width = connections.find(
16
16
  (connection) => connection?.netLabelWidth !== undefined,
17
17
  )?.netLabelWidth
18
- if (explicitWidth !== undefined) return explicitWidth
19
- if (!includeFallbackNetLabelWidth) return undefined
18
+ if (width !== undefined || !isPortOnlyLabel) return width
20
19
 
21
20
  return connections.find(
22
- (connection) => connection?.fallbackNetLabelWidth !== undefined,
23
- )?.fallbackNetLabelWidth
21
+ (connection) => connection?.anchoredNetLabelWidth !== undefined,
22
+ )?.anchoredNetLabelWidth
24
23
  }
25
24
 
26
25
  export const getNetLabelWidthForConnection = ({
27
26
  inputProblem,
28
27
  netId,
29
28
  pinIds,
30
- includeFallbackNetLabelWidth = true,
29
+ isPortOnlyLabel,
31
30
  }: {
32
31
  inputProblem: InputProblem
33
32
  netId?: NetId
34
33
  pinIds: readonly PinId[]
35
- includeFallbackNetLabelWidth?: boolean
34
+ isPortOnlyLabel: boolean
36
35
  }): number | undefined => {
37
36
  if (netId) {
38
37
  const widthByNetId = getConfiguredWidth(
@@ -44,7 +43,7 @@ export const getNetLabelWidthForConnection = ({
44
43
  (connection) => connection.netId === netId,
45
44
  ),
46
45
  ],
47
- includeFallbackNetLabelWidth,
46
+ isPortOnlyLabel,
48
47
  )
49
48
  if (widthByNetId !== undefined) return widthByNetId
50
49
  }
@@ -58,6 +57,6 @@ export const getNetLabelWidthForConnection = ({
58
57
  connection.pinIds.some((pinId) => pinIds.includes(pinId)),
59
58
  ),
60
59
  ],
61
- includeFallbackNetLabelWidth,
60
+ isPortOnlyLabel,
62
61
  )
63
62
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "https://github.com/tscircuit/schematic-trace-solver.git"
6
6
  },
7
7
  "main": "dist/index.js",
8
- "version": "0.0.151",
8
+ "version": "0.0.153",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "start": "cosmos",