@tscircuit/schematic-trace-solver 0.0.19 → 0.0.21

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
@@ -343,6 +343,7 @@ type OverlappingSameNetTraceGroup = {
343
343
  netId?: string;
344
344
  overlappingTraces?: SolvedTracePath;
345
345
  portOnlyPinId?: string;
346
+ mspConnectionPairIds?: MspConnectionPairId[];
346
347
  };
347
348
  interface NetLabelPlacement {
348
349
  globalConnNetId: string;
package/dist/index.js CHANGED
@@ -7311,13 +7311,25 @@ function lengthOfTrace(path) {
7311
7311
  return sum;
7312
7312
  }
7313
7313
  function chooseHostTraceForGroup(params) {
7314
- const { inputProblem, inputTraceMap, globalConnNetId, fallbackTrace } = params;
7314
+ const {
7315
+ inputProblem,
7316
+ inputTraceMap,
7317
+ globalConnNetId,
7318
+ fallbackTrace,
7319
+ mspConnectionPairIds
7320
+ } = params;
7315
7321
  const chipsById = Object.fromEntries(
7316
7322
  inputProblem.chips.map((c) => [c.chipId, c])
7317
7323
  );
7318
- const groupTraces = Object.values(inputTraceMap).filter(
7324
+ let groupTraces = Object.values(inputTraceMap).filter(
7319
7325
  (t) => t.globalConnNetId === globalConnNetId
7320
7326
  );
7327
+ if (mspConnectionPairIds && mspConnectionPairIds.length > 0) {
7328
+ const idSet = new Set(mspConnectionPairIds);
7329
+ groupTraces = groupTraces.filter(
7330
+ (t) => t.mspConnectionPairIds.some((id) => idSet.has(id))
7331
+ );
7332
+ }
7321
7333
  const chipIdsInGroup = /* @__PURE__ */ new Set();
7322
7334
  for (const t of groupTraces) {
7323
7335
  chipIdsInGroup.add(t.pins[0].chipId);
@@ -7566,15 +7578,19 @@ var SingleNetLabelPlacementSolver = class extends BaseSolver {
7566
7578
  inputProblem: this.inputProblem,
7567
7579
  inputTraceMap: this.inputTraceMap,
7568
7580
  globalConnNetId: groupId,
7569
- fallbackTrace: this.overlappingSameNetTraceGroup.overlappingTraces
7581
+ fallbackTrace: this.overlappingSameNetTraceGroup.overlappingTraces,
7582
+ mspConnectionPairIds: this.overlappingSameNetTraceGroup.mspConnectionPairIds
7570
7583
  });
7571
7584
  if (!host) {
7572
7585
  this.failed = true;
7573
7586
  this.error = "No host trace found for net label placement";
7574
7587
  return;
7575
7588
  }
7589
+ const traceIdSet = new Set(
7590
+ this.overlappingSameNetTraceGroup.mspConnectionPairIds ?? []
7591
+ );
7576
7592
  const tracesToScanBase = Object.values(this.inputTraceMap).filter(
7577
- (t) => t.globalConnNetId === groupId
7593
+ (t) => t.globalConnNetId === groupId && (traceIdSet.size === 0 || t.mspConnectionPairIds.some((id) => traceIdSet.has(id)))
7578
7594
  );
7579
7595
  const tracesToScan = this.availableOrientations.length === 1 ? [
7580
7596
  host,
@@ -7831,10 +7847,18 @@ var NetLabelPlacementSolver = class extends BaseSolver {
7831
7847
  }
7832
7848
  }
7833
7849
  }
7850
+ const mspConnectionPairIds = Array.from(
7851
+ new Set(
7852
+ compTraces.flatMap(
7853
+ (t) => t.mspConnectionPairIds ?? [t.mspPairId]
7854
+ )
7855
+ )
7856
+ );
7834
7857
  groups.push({
7835
7858
  globalConnNetId,
7836
7859
  netId: userNetId,
7837
- overlappingTraces: rep
7860
+ overlappingTraces: rep,
7861
+ mspConnectionPairIds
7838
7862
  });
7839
7863
  } else {
7840
7864
  for (const p of component) {
@@ -19,6 +19,7 @@ export type OverlappingSameNetTraceGroup = {
19
19
  netId?: string
20
20
  overlappingTraces?: SolvedTracePath
21
21
  portOnlyPinId?: string
22
+ mspConnectionPairIds?: MspConnectionPairId[]
22
23
  }
23
24
 
24
25
  export interface NetLabelPlacement {
@@ -196,11 +197,19 @@ export class NetLabelPlacementSolver extends BaseSolver {
196
197
  }
197
198
  }
198
199
  }
200
+ const mspConnectionPairIds = Array.from(
201
+ new Set(
202
+ compTraces.flatMap(
203
+ (t) => t.mspConnectionPairIds ?? [t.mspPairId],
204
+ ),
205
+ ),
206
+ )
199
207
 
200
208
  groups.push({
201
209
  globalConnNetId,
202
210
  netId: userNetId,
203
211
  overlappingTraces: rep,
212
+ mspConnectionPairIds,
204
213
  })
205
214
  } else {
206
215
  // No traces in this component: place label at each pin that has a user net id
@@ -121,6 +121,8 @@ export class SingleNetLabelPlacementSolver extends BaseSolver {
121
121
  inputTraceMap: this.inputTraceMap,
122
122
  globalConnNetId: groupId,
123
123
  fallbackTrace: this.overlappingSameNetTraceGroup.overlappingTraces,
124
+ mspConnectionPairIds:
125
+ this.overlappingSameNetTraceGroup.mspConnectionPairIds,
124
126
  })
125
127
 
126
128
  if (!host) {
@@ -130,8 +132,14 @@ export class SingleNetLabelPlacementSolver extends BaseSolver {
130
132
  }
131
133
 
132
134
  // Ensure we traverse the host path starting at the segment attached to the largest chip's pin
135
+ const traceIdSet = new Set(
136
+ this.overlappingSameNetTraceGroup.mspConnectionPairIds ?? [],
137
+ )
133
138
  const tracesToScanBase = Object.values(this.inputTraceMap).filter(
134
- (t) => t.globalConnNetId === groupId,
139
+ (t) =>
140
+ t.globalConnNetId === groupId &&
141
+ (traceIdSet.size === 0 ||
142
+ t.mspConnectionPairIds.some((id) => traceIdSet.has(id))),
135
143
  )
136
144
  const tracesToScan =
137
145
  this.availableOrientations.length === 1
@@ -17,17 +17,29 @@ export function chooseHostTraceForGroup(params: {
17
17
  inputTraceMap: Record<MspConnectionPairId, SolvedTracePath>
18
18
  globalConnNetId: string
19
19
  fallbackTrace?: SolvedTracePath
20
+ mspConnectionPairIds?: MspConnectionPairId[]
20
21
  }): SolvedTracePath | undefined {
21
- const { inputProblem, inputTraceMap, globalConnNetId, fallbackTrace } = params
22
-
22
+ const {
23
+ inputProblem,
24
+ inputTraceMap,
25
+ globalConnNetId,
26
+ fallbackTrace,
27
+ mspConnectionPairIds,
28
+ } = params
23
29
  const chipsById: Record<string, InputChip> = Object.fromEntries(
24
30
  inputProblem.chips.map((c) => [c.chipId, c]),
25
31
  )
26
32
 
27
- const groupTraces = Object.values(inputTraceMap).filter(
33
+ let groupTraces = Object.values(inputTraceMap).filter(
28
34
  (t) => t.globalConnNetId === globalConnNetId,
29
35
  )
30
36
 
37
+ if (mspConnectionPairIds && mspConnectionPairIds.length > 0) {
38
+ const idSet = new Set(mspConnectionPairIds)
39
+ groupTraces = groupTraces.filter((t) =>
40
+ t.mspConnectionPairIds.some((id) => idSet.has(id)),
41
+ )
42
+ }
31
43
  const chipIdsInGroup = new Set<string>()
32
44
  for (const t of groupTraces) {
33
45
  chipIdsInGroup.add(t.pins[0].chipId)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/schematic-trace-solver",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.19",
4
+ "version": "0.0.21",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "cosmos",
@@ -0,0 +1,94 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import type { InputProblem } from "lib/types/InputProblem"
3
+
4
+ const inputProblem: InputProblem = {
5
+ chips: [
6
+ {
7
+ chipId: "schematic_component_0",
8
+ center: {
9
+ x: 4,
10
+ y: 0,
11
+ },
12
+ width: 1.1025814,
13
+ height: 0.388910699999999,
14
+ pins: [
15
+ {
16
+ pinId: "R1.1",
17
+ x: 3.4487093,
18
+ y: 0.0002732499999993365,
19
+ },
20
+ {
21
+ pinId: "R1.2",
22
+ x: 4.5512907,
23
+ y: -0.0002732499999993365,
24
+ },
25
+ ],
26
+ },
27
+ {
28
+ chipId: "schematic_component_1",
29
+ center: {
30
+ x: 0,
31
+ y: 0,
32
+ },
33
+ width: 1.2000000000000002,
34
+ height: 1,
35
+ pins: [
36
+ {
37
+ pinId: "U1.1",
38
+ x: -0.6000000000000001,
39
+ y: 0.30000000000000004,
40
+ },
41
+ {
42
+ pinId: "U1.2",
43
+ x: -0.6000000000000001,
44
+ y: 0.10000000000000003,
45
+ },
46
+ {
47
+ pinId: "U1.3",
48
+ x: -0.6000000000000001,
49
+ y: -0.09999999999999998,
50
+ },
51
+ {
52
+ pinId: "U1.4",
53
+ x: -0.6000000000000001,
54
+ y: -0.30000000000000004,
55
+ },
56
+ {
57
+ pinId: "U1.5",
58
+ x: 0.6000000000000001,
59
+ y: -0.30000000000000004,
60
+ },
61
+ {
62
+ pinId: "U1.6",
63
+ x: 0.6000000000000001,
64
+ y: -0.10000000000000003,
65
+ },
66
+ {
67
+ pinId: "U1.7",
68
+ x: 0.6000000000000001,
69
+ y: 0.09999999999999998,
70
+ },
71
+ {
72
+ pinId: "U1.8",
73
+ x: 0.6000000000000001,
74
+ y: 0.30000000000000004,
75
+ },
76
+ ],
77
+ },
78
+ ],
79
+ directConnections: [
80
+ {
81
+ pinIds: ["U1.1", "R1.1"],
82
+ netId: "chip.U1 > port.pin1 to R1.1",
83
+ },
84
+ {
85
+ pinIds: ["U1.6", "R1.2"],
86
+ netId: "chip.U1 > port.pin6 to R1.2",
87
+ },
88
+ ],
89
+ netConnections: [],
90
+ availableNetLabelOrientations: {},
91
+ maxMspPairDistance: 2,
92
+ }
93
+
94
+ export default () => <PipelineDebugger inputProblem={inputProblem} />