@tscircuit/schematic-trace-solver 0.0.18 → 0.0.19
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/package.json
CHANGED
|
@@ -6,6 +6,24 @@ interface DownloadDropdownProps {
|
|
|
6
6
|
className?: string
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
const deepRemoveUnderscoreProperties = (obj: any): any => {
|
|
10
|
+
if (obj === null || typeof obj !== "object") {
|
|
11
|
+
return obj
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (Array.isArray(obj)) {
|
|
15
|
+
return obj.map(deepRemoveUnderscoreProperties)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const result: any = {}
|
|
19
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
20
|
+
if (!key.startsWith("_")) {
|
|
21
|
+
result[key] = deepRemoveUnderscoreProperties(value)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
export const DownloadDropdown = ({
|
|
10
28
|
solver,
|
|
11
29
|
className = "",
|
|
@@ -36,7 +54,9 @@ export const DownloadDropdown = ({
|
|
|
36
54
|
return
|
|
37
55
|
}
|
|
38
56
|
|
|
39
|
-
const params =
|
|
57
|
+
const params = deepRemoveUnderscoreProperties(
|
|
58
|
+
solver.getConstructorParams(),
|
|
59
|
+
)
|
|
40
60
|
const blob = new Blob([JSON.stringify(params, null, 2)], {
|
|
41
61
|
type: "application/json",
|
|
42
62
|
})
|
|
@@ -56,7 +76,9 @@ export const DownloadDropdown = ({
|
|
|
56
76
|
|
|
57
77
|
const downloadPageTsx = () => {
|
|
58
78
|
try {
|
|
59
|
-
const params =
|
|
79
|
+
const params = deepRemoveUnderscoreProperties(
|
|
80
|
+
solver.getConstructorParams(),
|
|
81
|
+
)
|
|
60
82
|
const solverName = solver.constructor.name
|
|
61
83
|
const isSchematicTracePipelineSolver =
|
|
62
84
|
solverName === "SchematicTracePipelineSolver"
|
|
@@ -104,19 +126,21 @@ export default () => {
|
|
|
104
126
|
|
|
105
127
|
const downloadTestTs = () => {
|
|
106
128
|
try {
|
|
107
|
-
const params =
|
|
129
|
+
const params = deepRemoveUnderscoreProperties(
|
|
130
|
+
solver.getConstructorParams(),
|
|
131
|
+
)
|
|
108
132
|
const solverName = solver.constructor.name
|
|
109
133
|
|
|
110
|
-
const content = `import { ${solverName} } from "lib/solvers/${solverName}/${solverName}"
|
|
134
|
+
const content = `import { ${solverName} } from "lib/solvers/${solverName}/${solverName}\nimport { test, expect } from "bun:test"
|
|
111
135
|
|
|
112
136
|
test("${solverName} should solve problem correctly", () => {
|
|
113
137
|
const input = ${JSON.stringify(params, null, 2)}
|
|
114
138
|
|
|
115
139
|
const solver = new ${solverName}(input as any)
|
|
116
|
-
|
|
140
|
+
solver.solve()
|
|
117
141
|
|
|
118
|
-
expect(result).toBeDefined()
|
|
119
142
|
// Add more specific assertions based on expected output
|
|
143
|
+
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
120
144
|
})
|
|
121
145
|
`
|
|
122
146
|
|
|
@@ -0,0 +1,135 @@
|
|
|
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: 0,
|
|
10
|
+
y: 0,
|
|
11
|
+
},
|
|
12
|
+
width: 2.8,
|
|
13
|
+
height: 1.4,
|
|
14
|
+
pins: [
|
|
15
|
+
{
|
|
16
|
+
pinId: "U3.8",
|
|
17
|
+
x: -1.4,
|
|
18
|
+
y: 0.42500000000000004,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
pinId: "U3.4",
|
|
22
|
+
x: -1.4,
|
|
23
|
+
y: -0.42500000000000004,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
pinId: "U3.1",
|
|
27
|
+
x: 1.4,
|
|
28
|
+
y: 0.5,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
pinId: "U3.6",
|
|
32
|
+
x: 1.4,
|
|
33
|
+
y: 0.30000000000000004,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
pinId: "U3.5",
|
|
37
|
+
x: 1.4,
|
|
38
|
+
y: 0.10000000000000009,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
pinId: "U3.2",
|
|
42
|
+
x: 1.4,
|
|
43
|
+
y: -0.09999999999999998,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
pinId: "U3.3",
|
|
47
|
+
x: 1.4,
|
|
48
|
+
y: -0.3,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
pinId: "U3.7",
|
|
52
|
+
x: 1.4,
|
|
53
|
+
y: -0.5,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
chipId: "schematic_component_1",
|
|
59
|
+
center: {
|
|
60
|
+
x: -2.3145833,
|
|
61
|
+
y: 0,
|
|
62
|
+
},
|
|
63
|
+
width: 0.5291665999999999,
|
|
64
|
+
height: 1.1024186000000005,
|
|
65
|
+
pins: [
|
|
66
|
+
{
|
|
67
|
+
pinId: "C20.1",
|
|
68
|
+
x: -2.3148566499999994,
|
|
69
|
+
y: 0.5512093000000002,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
pinId: "C20.2",
|
|
73
|
+
x: -2.31430995,
|
|
74
|
+
y: -0.5512093000000002,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
chipId: "schematic_component_2",
|
|
80
|
+
center: {
|
|
81
|
+
x: 1.7577928249999983,
|
|
82
|
+
y: 1.7512907000000002,
|
|
83
|
+
},
|
|
84
|
+
width: 0.3155856499999966,
|
|
85
|
+
height: 1.1025814000000005,
|
|
86
|
+
pins: [
|
|
87
|
+
{
|
|
88
|
+
pinId: "R11.1",
|
|
89
|
+
x: 1.7580660749999977,
|
|
90
|
+
y: 2.3025814000000002,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
pinId: "R11.2",
|
|
94
|
+
x: 1.757519574999999,
|
|
95
|
+
y: 1.2,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
directConnections: [
|
|
101
|
+
{
|
|
102
|
+
pinIds: ["C20.1", "U3.8"],
|
|
103
|
+
netId: "capacitor.C20 > port.pin1 to .U3 > .VDD",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
pinIds: ["C20.2", "U3.4"],
|
|
107
|
+
netId: "capacitor.C20 > port.pin2 to .U3 > .GND",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
pinIds: ["R11.2", "U3.1"],
|
|
111
|
+
netId: "resistor.R11 > port.pin2 to .U3 > .N_CS",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
netConnections: [
|
|
115
|
+
{
|
|
116
|
+
netId: "V3_3",
|
|
117
|
+
pinIds: ["U3.8", "U3.3", "U3.7", "C20.1", "R11.1"],
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
netId: "GND",
|
|
121
|
+
pinIds: ["U3.4", "C20.2"],
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
netId: "FLASH_N_CS",
|
|
125
|
+
pinIds: ["U3.1", "R11.2"],
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
availableNetLabelOrientations: {
|
|
129
|
+
V3_3: ["y+"],
|
|
130
|
+
GND: ["y-"],
|
|
131
|
+
},
|
|
132
|
+
maxMspPairDistance: 2,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export default () => <PipelineDebugger inputProblem={inputProblem} />
|
package/tests/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver_repro02.test.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
2
|
+
import { test, expect } from "bun:test"
|
|
3
|
+
|
|
4
|
+
test("SchematicTracePipelineSolver should solve problem correctly", () => {
|
|
5
|
+
const input = {
|
|
6
|
+
chips: [
|
|
7
|
+
{
|
|
8
|
+
chipId: "schematic_component_0",
|
|
9
|
+
center: {
|
|
10
|
+
x: 0,
|
|
11
|
+
y: 0,
|
|
12
|
+
},
|
|
13
|
+
width: 2.8,
|
|
14
|
+
height: 1.4,
|
|
15
|
+
pins: [
|
|
16
|
+
{
|
|
17
|
+
pinId: "U3.8",
|
|
18
|
+
x: -1.4,
|
|
19
|
+
y: 0.42500000000000004,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
pinId: "U3.4",
|
|
23
|
+
x: -1.4,
|
|
24
|
+
y: -0.42500000000000004,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
pinId: "U3.1",
|
|
28
|
+
x: 1.4,
|
|
29
|
+
y: 0.5,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
pinId: "U3.6",
|
|
33
|
+
x: 1.4,
|
|
34
|
+
y: 0.30000000000000004,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
pinId: "U3.5",
|
|
38
|
+
x: 1.4,
|
|
39
|
+
y: 0.10000000000000009,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
pinId: "U3.2",
|
|
43
|
+
x: 1.4,
|
|
44
|
+
y: -0.09999999999999998,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
pinId: "U3.3",
|
|
48
|
+
x: 1.4,
|
|
49
|
+
y: -0.3,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
pinId: "U3.7",
|
|
53
|
+
x: 1.4,
|
|
54
|
+
y: -0.5,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
chipId: "schematic_component_1",
|
|
60
|
+
center: {
|
|
61
|
+
x: -2.3145833,
|
|
62
|
+
y: 0,
|
|
63
|
+
},
|
|
64
|
+
width: 0.5291665999999999,
|
|
65
|
+
height: 1.1024186000000005,
|
|
66
|
+
pins: [
|
|
67
|
+
{
|
|
68
|
+
pinId: "C20.1",
|
|
69
|
+
x: -2.3148566499999994,
|
|
70
|
+
y: 0.5512093000000002,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
pinId: "C20.2",
|
|
74
|
+
x: -2.31430995,
|
|
75
|
+
y: -0.5512093000000002,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
chipId: "schematic_component_2",
|
|
81
|
+
center: {
|
|
82
|
+
x: 1.7577928249999983,
|
|
83
|
+
y: 1.7512907000000002,
|
|
84
|
+
},
|
|
85
|
+
width: 0.3155856499999966,
|
|
86
|
+
height: 1.1025814000000005,
|
|
87
|
+
pins: [
|
|
88
|
+
{
|
|
89
|
+
pinId: "R11.1",
|
|
90
|
+
x: 1.7580660749999977,
|
|
91
|
+
y: 2.3025814000000002,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
pinId: "R11.2",
|
|
95
|
+
x: 1.757519574999999,
|
|
96
|
+
y: 1.2,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
directConnections: [
|
|
102
|
+
{
|
|
103
|
+
pinIds: ["C20.1", "U3.8"],
|
|
104
|
+
netId: "capacitor.C20 > port.pin1 to .U3 > .VDD",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
pinIds: ["C20.2", "U3.4"],
|
|
108
|
+
netId: "capacitor.C20 > port.pin2 to .U3 > .GND",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
pinIds: ["R11.2", "U3.1"],
|
|
112
|
+
netId: "resistor.R11 > port.pin2 to .U3 > .N_CS",
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
netConnections: [
|
|
116
|
+
{
|
|
117
|
+
netId: "V3_3",
|
|
118
|
+
pinIds: ["U3.8", "U3.3", "U3.7", "C20.1", "R11.1"],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
netId: "GND",
|
|
122
|
+
pinIds: ["U3.4", "C20.2"],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
netId: "FLASH_N_CS",
|
|
126
|
+
pinIds: ["U3.1", "R11.2"],
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
availableNetLabelOrientations: {
|
|
130
|
+
V3_3: ["y+"],
|
|
131
|
+
GND: ["y-"],
|
|
132
|
+
},
|
|
133
|
+
maxMspPairDistance: 2,
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const solver = new SchematicTracePipelineSolver(input as any)
|
|
137
|
+
solver.solve()
|
|
138
|
+
|
|
139
|
+
// console.log(solver.netLabelPlacementSolver!.netLabelPlacements)
|
|
140
|
+
})
|