@tscircuit/schematic-trace-solver 0.0.33 → 0.0.34
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.js +22 -4
- package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +25 -4
- package/package.json +1 -1
- package/site/examples/example15-rp2040-caps.page.tsx +623 -0
- package/site/examples/example16-core-repro51.page.tsx +107 -0
- package/site/examples/example17-straight-line-trace.page.tsx +165 -0
- package/site/examples/example18.page.tsx +181 -0
- package/site/examples/example19.page.tsx +169 -0
- package/tests/examples/__snapshots__/example15.snap.svg +800 -71
- package/tests/examples/__snapshots__/example16.snap.svg +40 -86
- package/tests/examples/__snapshots__/example17.snap.svg +190 -0
- package/tests/examples/__snapshots__/example18.snap.svg +235 -0
- package/tests/examples/__snapshots__/example19.snap.svg +195 -0
- package/tests/examples/example15.test.tsx +524 -82
- package/tests/examples/example16.test.tsx +56 -118
- package/tests/examples/example17.test.tsx +171 -0
- package/tests/examples/example18.test.tsx +187 -0
- package/tests/examples/example19.test.tsx +175 -0
package/dist/index.js
CHANGED
|
@@ -1927,6 +1927,12 @@ var NetLabelPlacementSolver = class extends BaseSolver {
|
|
|
1927
1927
|
const { netConnMap } = getConnectivityMapsFromInputProblem(
|
|
1928
1928
|
this.inputProblem
|
|
1929
1929
|
);
|
|
1930
|
+
const pinIdToPinMap = /* @__PURE__ */ new Map();
|
|
1931
|
+
for (const chip of this.inputProblem.chips) {
|
|
1932
|
+
for (const pin of chip.pins) {
|
|
1933
|
+
pinIdToPinMap.set(pin.pinId, pin);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1930
1936
|
const userNetIdByPinId = {};
|
|
1931
1937
|
for (const dc of this.inputProblem.directConnections) {
|
|
1932
1938
|
if (dc.netId) {
|
|
@@ -1941,10 +1947,21 @@ var NetLabelPlacementSolver = class extends BaseSolver {
|
|
|
1941
1947
|
}
|
|
1942
1948
|
}
|
|
1943
1949
|
const groups = [];
|
|
1944
|
-
|
|
1945
|
-
|
|
1950
|
+
const allPinIds = this.inputProblem.chips.flatMap(
|
|
1951
|
+
(c) => c.pins.map((p) => p.pinId)
|
|
1952
|
+
);
|
|
1953
|
+
const allGlobalConnNetIds = /* @__PURE__ */ new Set();
|
|
1954
|
+
for (const pinId of allPinIds) {
|
|
1955
|
+
const netId = netConnMap.getNetConnectedToId(pinId);
|
|
1956
|
+
if (netId) {
|
|
1957
|
+
allGlobalConnNetIds.add(netId);
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
for (const globalConnNetId of allGlobalConnNetIds) {
|
|
1961
|
+
const allIdsInNet = netConnMap.getIdsConnectedToNet(
|
|
1946
1962
|
globalConnNetId
|
|
1947
1963
|
);
|
|
1964
|
+
const pinsInNet = allIdsInNet.filter((id) => pinIdToPinMap.has(id));
|
|
1948
1965
|
const adj = {};
|
|
1949
1966
|
for (const pid of pinsInNet) adj[pid] = /* @__PURE__ */ new Set();
|
|
1950
1967
|
for (const t of byGlobal[globalConnNetId] ?? []) {
|
|
@@ -2008,12 +2025,13 @@ var NetLabelPlacementSolver = class extends BaseSolver {
|
|
|
2008
2025
|
)
|
|
2009
2026
|
)
|
|
2010
2027
|
);
|
|
2011
|
-
|
|
2028
|
+
const group = {
|
|
2012
2029
|
globalConnNetId,
|
|
2013
2030
|
netId: userNetId,
|
|
2014
2031
|
overlappingTraces: rep,
|
|
2015
2032
|
mspConnectionPairIds
|
|
2016
|
-
}
|
|
2033
|
+
};
|
|
2034
|
+
groups.push(group);
|
|
2017
2035
|
} else {
|
|
2018
2036
|
for (const p of component) {
|
|
2019
2037
|
const userNetId = userNetIdByPinId[p];
|
|
@@ -107,6 +107,13 @@ export class NetLabelPlacementSolver extends BaseSolver {
|
|
|
107
107
|
this.inputProblem,
|
|
108
108
|
)
|
|
109
109
|
|
|
110
|
+
const pinIdToPinMap = new Map<string, unknown>()
|
|
111
|
+
for (const chip of this.inputProblem.chips) {
|
|
112
|
+
for (const pin of chip.pins) {
|
|
113
|
+
pinIdToPinMap.set(pin.pinId, pin)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
110
117
|
// Map pins to user-provided netIds (if any)
|
|
111
118
|
const userNetIdByPinId: Record<string, string | undefined> = {}
|
|
112
119
|
for (const dc of this.inputProblem.directConnections) {
|
|
@@ -124,11 +131,24 @@ export class NetLabelPlacementSolver extends BaseSolver {
|
|
|
124
131
|
|
|
125
132
|
const groups: Array<OverlappingSameNetTraceGroup> = []
|
|
126
133
|
|
|
134
|
+
const allPinIds = this.inputProblem.chips.flatMap((c) =>
|
|
135
|
+
c.pins.map((p) => p.pinId),
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
const allGlobalConnNetIds = new Set<string>()
|
|
139
|
+
for (const pinId of allPinIds) {
|
|
140
|
+
const netId = netConnMap.getNetConnectedToId(pinId)
|
|
141
|
+
if (netId) {
|
|
142
|
+
allGlobalConnNetIds.add(netId)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
127
146
|
// Consider every global connectivity net id
|
|
128
|
-
for (const globalConnNetId of
|
|
129
|
-
const
|
|
147
|
+
for (const globalConnNetId of allGlobalConnNetIds) {
|
|
148
|
+
const allIdsInNet = netConnMap.getIdsConnectedToNet(
|
|
130
149
|
globalConnNetId,
|
|
131
150
|
) as string[]
|
|
151
|
+
const pinsInNet = allIdsInNet.filter((id) => pinIdToPinMap.has(id))
|
|
132
152
|
|
|
133
153
|
// Build adjacency from solved traces (edges)
|
|
134
154
|
const adj: Record<string, Set<string>> = {}
|
|
@@ -205,12 +225,13 @@ export class NetLabelPlacementSolver extends BaseSolver {
|
|
|
205
225
|
),
|
|
206
226
|
)
|
|
207
227
|
|
|
208
|
-
|
|
228
|
+
const group = {
|
|
209
229
|
globalConnNetId,
|
|
210
230
|
netId: userNetId,
|
|
211
231
|
overlappingTraces: rep,
|
|
212
232
|
mspConnectionPairIds,
|
|
213
|
-
}
|
|
233
|
+
}
|
|
234
|
+
groups.push(group)
|
|
214
235
|
} else {
|
|
215
236
|
// No traces in this component: place label at each pin that has a user net id
|
|
216
237
|
for (const p of component) {
|