circuit-json-to-tscircuit 0.0.37 → 0.0.39
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/assets/empty-board.json +57 -0
- package/assets/input-circuit-json.json +248 -59
- package/dist/{chunk-7VZ63UWJ.js → chunk-G5NSFWRY.js} +136 -80
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +1 -1
- package/lib/get-board-using-template.ts +66 -0
- package/lib/index.ts +10 -0
- package/package.json +1 -1
- package/tests/__snapshots__/test19-support-board-conversion-pcb.snap.svg +1 -0
- package/tests/__snapshots__/test20-board-conversion-drops-children-pcb.snap.svg +1 -0
- package/tests/cli/cli-circuit-json-to-tsx.test.tsx +10 -2
- package/tests/test1-basic-circuit.test.tsx +12 -2
- package/tests/test19-support-board-conversion.test.tsx +33 -0
- package/tests/test2-get-component-template.test.tsx +10 -3
- package/tests/test20-board-conversion-drops-children.test.tsx +81 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"type": "source_project_metadata",
|
|
4
|
+
"source_project_metadata_id": "source_project_metadata_0",
|
|
5
|
+
"software_used_string": "@tscircuit/core@0.0.1306"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"type": "source_group",
|
|
9
|
+
"source_group_id": "source_group_0",
|
|
10
|
+
"is_subcircuit": true,
|
|
11
|
+
"was_automatically_named": true,
|
|
12
|
+
"subcircuit_id": "subcircuit_source_group_0"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"type": "source_board",
|
|
16
|
+
"source_board_id": "source_board_0",
|
|
17
|
+
"source_group_id": "source_group_0"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "schematic_group",
|
|
21
|
+
"schematic_group_id": "schematic_group_0",
|
|
22
|
+
"is_subcircuit": true,
|
|
23
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
24
|
+
"name": "unnamed_board1",
|
|
25
|
+
"center": {
|
|
26
|
+
"x": 0,
|
|
27
|
+
"y": 0
|
|
28
|
+
},
|
|
29
|
+
"width": 0,
|
|
30
|
+
"height": 0,
|
|
31
|
+
"schematic_component_ids": [],
|
|
32
|
+
"source_group_id": "source_group_0",
|
|
33
|
+
"show_as_schematic_box": false
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"type": "pcb_board",
|
|
37
|
+
"pcb_board_id": "pcb_board_0",
|
|
38
|
+
"source_board_id": "source_board_0",
|
|
39
|
+
"center": {
|
|
40
|
+
"x": 0,
|
|
41
|
+
"y": 0
|
|
42
|
+
},
|
|
43
|
+
"thickness": 1.4,
|
|
44
|
+
"num_layers": 2,
|
|
45
|
+
"width": 20,
|
|
46
|
+
"height": 10,
|
|
47
|
+
"material": "fr4",
|
|
48
|
+
"min_trace_width": 0.1,
|
|
49
|
+
"min_via_hole_diameter": 0.2,
|
|
50
|
+
"min_via_pad_diameter": 0.3,
|
|
51
|
+
"min_via_hole_edge_to_via_hole_edge_clearance": 0.1,
|
|
52
|
+
"min_trace_to_pad_edge_clearance": 0.1,
|
|
53
|
+
"min_pad_edge_to_pad_edge_clearance": 0.1,
|
|
54
|
+
"min_plated_hole_drill_edge_to_drill_edge_clearance": 0.15,
|
|
55
|
+
"min_board_edge_clearance": 0.2
|
|
56
|
+
}
|
|
57
|
+
]
|
|
@@ -1,36 +1,44 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"type": "source_project_metadata",
|
|
4
|
+
"source_project_metadata_id": "source_project_metadata_0",
|
|
5
|
+
"software_used_string": "@tscircuit/core@0.0.1358"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"type": "source_group",
|
|
9
|
+
"source_group_id": "source_group_0",
|
|
10
|
+
"is_subcircuit": true,
|
|
11
|
+
"was_automatically_named": true,
|
|
12
|
+
"subcircuit_id": "subcircuit_source_group_0"
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"type": "source_port",
|
|
4
16
|
"source_port_id": "source_port_0",
|
|
5
17
|
"name": "pin1",
|
|
6
18
|
"pin_number": 1,
|
|
7
|
-
"port_hints": ["
|
|
8
|
-
"source_component_id": "source_component_0"
|
|
19
|
+
"port_hints": ["pin1", "1"],
|
|
20
|
+
"source_component_id": "source_component_0",
|
|
21
|
+
"subcircuit_id": "subcircuit_source_group_0"
|
|
9
22
|
},
|
|
10
23
|
{
|
|
11
24
|
"type": "source_port",
|
|
12
25
|
"source_port_id": "source_port_1",
|
|
13
26
|
"name": "pin2",
|
|
14
27
|
"pin_number": 2,
|
|
15
|
-
"port_hints": ["
|
|
16
|
-
"source_component_id": "source_component_0"
|
|
28
|
+
"port_hints": ["pin2", "2"],
|
|
29
|
+
"source_component_id": "source_component_0",
|
|
30
|
+
"subcircuit_id": "subcircuit_source_group_0"
|
|
17
31
|
},
|
|
18
32
|
{
|
|
19
33
|
"type": "source_component",
|
|
20
34
|
"source_component_id": "source_component_0",
|
|
21
|
-
"ftype": "
|
|
22
|
-
"name": "
|
|
35
|
+
"ftype": "simple_chip",
|
|
36
|
+
"name": "unnamed_chip1",
|
|
37
|
+
"manufacturer_part_number": "A_0603WAF1002T5E",
|
|
23
38
|
"supplier_part_numbers": {
|
|
24
|
-
"jlcpcb": ["
|
|
39
|
+
"jlcpcb": ["C25804"]
|
|
25
40
|
},
|
|
26
|
-
"
|
|
27
|
-
"display_resistance": "1kΩ"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"type": "source_group",
|
|
31
|
-
"source_group_id": "source_group_0",
|
|
32
|
-
"is_subcircuit": true,
|
|
33
|
-
"subcircuit_id": "subcircuit_source_group_0"
|
|
41
|
+
"source_group_id": "source_group_0"
|
|
34
42
|
},
|
|
35
43
|
{
|
|
36
44
|
"type": "schematic_component",
|
|
@@ -41,40 +49,92 @@
|
|
|
41
49
|
},
|
|
42
50
|
"rotation": 0,
|
|
43
51
|
"size": {
|
|
44
|
-
"width": 1.
|
|
45
|
-
"height": 0.
|
|
52
|
+
"width": 1.2000000000000002,
|
|
53
|
+
"height": 0.4
|
|
54
|
+
},
|
|
55
|
+
"pin_spacing": 0.2,
|
|
56
|
+
"port_labels": {
|
|
57
|
+
"pin1": "pin1",
|
|
58
|
+
"pin2": "pin2"
|
|
46
59
|
},
|
|
47
60
|
"source_component_id": "source_component_0",
|
|
48
|
-
"
|
|
49
|
-
|
|
61
|
+
"schematic_group_id": "schematic_group_0"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "schematic_text",
|
|
65
|
+
"schematic_text_id": "schematic_text_0",
|
|
66
|
+
"text": "A_0603WAF1002T5E",
|
|
67
|
+
"schematic_component_id": "schematic_component_0",
|
|
68
|
+
"anchor": "left",
|
|
69
|
+
"rotation": 0,
|
|
70
|
+
"position": {
|
|
71
|
+
"x": -0.6000000000000001,
|
|
72
|
+
"y": -0.33
|
|
73
|
+
},
|
|
74
|
+
"color": "#006464",
|
|
75
|
+
"font_size": 0.18
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"type": "schematic_text",
|
|
79
|
+
"schematic_text_id": "schematic_text_1",
|
|
80
|
+
"text": "",
|
|
81
|
+
"schematic_component_id": "schematic_component_0",
|
|
82
|
+
"anchor": "left",
|
|
83
|
+
"rotation": 0,
|
|
84
|
+
"position": {
|
|
85
|
+
"x": -0.6000000000000001,
|
|
86
|
+
"y": 0.33
|
|
87
|
+
},
|
|
88
|
+
"color": "#006464",
|
|
89
|
+
"font_size": 0.18
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "schematic_group",
|
|
93
|
+
"schematic_group_id": "schematic_group_0",
|
|
94
|
+
"is_subcircuit": true,
|
|
95
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
96
|
+
"name": "unnamed_group1",
|
|
97
|
+
"center": {
|
|
98
|
+
"x": 0,
|
|
99
|
+
"y": 0
|
|
100
|
+
},
|
|
101
|
+
"width": 0,
|
|
102
|
+
"height": 0,
|
|
103
|
+
"schematic_component_ids": [],
|
|
104
|
+
"source_group_id": "source_group_0",
|
|
105
|
+
"show_as_schematic_box": false
|
|
50
106
|
},
|
|
51
107
|
{
|
|
52
108
|
"type": "schematic_port",
|
|
53
109
|
"schematic_port_id": "schematic_port_0",
|
|
54
110
|
"schematic_component_id": "schematic_component_0",
|
|
55
111
|
"center": {
|
|
56
|
-
"x": -
|
|
57
|
-
"y": 0
|
|
112
|
+
"x": -1,
|
|
113
|
+
"y": 0
|
|
58
114
|
},
|
|
59
115
|
"source_port_id": "source_port_0",
|
|
60
116
|
"facing_direction": "left",
|
|
61
117
|
"distance_from_component_edge": 0.4,
|
|
118
|
+
"side_of_component": "left",
|
|
62
119
|
"pin_number": 1,
|
|
63
|
-
"
|
|
120
|
+
"true_ccw_index": 0,
|
|
121
|
+
"is_connected": false
|
|
64
122
|
},
|
|
65
123
|
{
|
|
66
124
|
"type": "schematic_port",
|
|
67
125
|
"schematic_port_id": "schematic_port_1",
|
|
68
126
|
"schematic_component_id": "schematic_component_0",
|
|
69
127
|
"center": {
|
|
70
|
-
"x":
|
|
71
|
-
"y": 0
|
|
128
|
+
"x": 1,
|
|
129
|
+
"y": 0
|
|
72
130
|
},
|
|
73
131
|
"source_port_id": "source_port_1",
|
|
74
132
|
"facing_direction": "right",
|
|
75
133
|
"distance_from_component_edge": 0.4,
|
|
134
|
+
"side_of_component": "right",
|
|
76
135
|
"pin_number": 2,
|
|
77
|
-
"
|
|
136
|
+
"true_ccw_index": 1,
|
|
137
|
+
"is_connected": false
|
|
78
138
|
},
|
|
79
139
|
{
|
|
80
140
|
"type": "pcb_component",
|
|
@@ -83,78 +143,197 @@
|
|
|
83
143
|
"x": 0,
|
|
84
144
|
"y": 0
|
|
85
145
|
},
|
|
86
|
-
"width":
|
|
87
|
-
"height": 0.
|
|
146
|
+
"width": 2.3132034,
|
|
147
|
+
"height": 0.8640064,
|
|
88
148
|
"layer": "top",
|
|
89
149
|
"rotation": 0,
|
|
90
150
|
"source_component_id": "source_component_0",
|
|
91
|
-
"subcircuit_id": "subcircuit_source_group_0"
|
|
151
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
152
|
+
"do_not_place": false,
|
|
153
|
+
"obstructs_within_bounds": true,
|
|
154
|
+
"is_allowed_to_be_off_board": false,
|
|
155
|
+
"pcb_group_id": "pcb_group_0"
|
|
92
156
|
},
|
|
93
157
|
{
|
|
94
|
-
"type": "
|
|
95
|
-
"
|
|
158
|
+
"type": "pcb_group",
|
|
159
|
+
"pcb_group_id": "pcb_group_0",
|
|
160
|
+
"is_subcircuit": true,
|
|
161
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
162
|
+
"name": "unnamed_group1",
|
|
163
|
+
"anchor_position": {
|
|
164
|
+
"x": 0,
|
|
165
|
+
"y": 0
|
|
166
|
+
},
|
|
96
167
|
"center": {
|
|
97
168
|
"x": 0,
|
|
98
169
|
"y": 0
|
|
99
170
|
},
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
171
|
+
"width": 2.3132034,
|
|
172
|
+
"height": 0.8640064,
|
|
173
|
+
"pcb_component_ids": [],
|
|
174
|
+
"source_group_id": "source_group_0",
|
|
175
|
+
"anchor_alignment": null
|
|
104
176
|
},
|
|
105
177
|
{
|
|
106
178
|
"type": "pcb_smtpad",
|
|
107
179
|
"pcb_smtpad_id": "pcb_smtpad_0",
|
|
108
180
|
"pcb_component_id": "pcb_component_0",
|
|
109
|
-
"pcb_port_id": "
|
|
181
|
+
"pcb_port_id": "pcb_port_1",
|
|
110
182
|
"layer": "top",
|
|
111
183
|
"shape": "rect",
|
|
112
|
-
"width": 0.
|
|
113
|
-
"height": 0.
|
|
114
|
-
"port_hints": ["
|
|
115
|
-
"
|
|
184
|
+
"width": 0.8064754,
|
|
185
|
+
"height": 0.8640064,
|
|
186
|
+
"port_hints": ["pin2"],
|
|
187
|
+
"is_covered_with_solder_mask": false,
|
|
188
|
+
"x": 0.753364,
|
|
116
189
|
"y": 0,
|
|
117
|
-
"subcircuit_id": "subcircuit_source_group_0"
|
|
190
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
191
|
+
"pcb_group_id": "pcb_group_0"
|
|
118
192
|
},
|
|
119
193
|
{
|
|
120
194
|
"type": "pcb_solder_paste",
|
|
121
195
|
"pcb_solder_paste_id": "pcb_solder_paste_0",
|
|
122
196
|
"layer": "top",
|
|
123
197
|
"shape": "rect",
|
|
124
|
-
"width": 0.
|
|
125
|
-
"height": 0.
|
|
126
|
-
"x":
|
|
198
|
+
"width": 0.56453278,
|
|
199
|
+
"height": 0.60480448,
|
|
200
|
+
"x": 0.753364,
|
|
127
201
|
"y": 0,
|
|
128
202
|
"pcb_component_id": "pcb_component_0",
|
|
129
203
|
"pcb_smtpad_id": "pcb_smtpad_0",
|
|
130
|
-
"subcircuit_id": "subcircuit_source_group_0"
|
|
204
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
205
|
+
"pcb_group_id": "pcb_group_0"
|
|
131
206
|
},
|
|
132
207
|
{
|
|
133
208
|
"type": "pcb_smtpad",
|
|
134
209
|
"pcb_smtpad_id": "pcb_smtpad_1",
|
|
135
210
|
"pcb_component_id": "pcb_component_0",
|
|
136
|
-
"pcb_port_id": "
|
|
211
|
+
"pcb_port_id": "pcb_port_0",
|
|
137
212
|
"layer": "top",
|
|
138
213
|
"shape": "rect",
|
|
139
|
-
"width": 0.
|
|
140
|
-
"height": 0.
|
|
141
|
-
"port_hints": ["
|
|
142
|
-
"
|
|
214
|
+
"width": 0.8064754,
|
|
215
|
+
"height": 0.8640064,
|
|
216
|
+
"port_hints": ["pin1"],
|
|
217
|
+
"is_covered_with_solder_mask": false,
|
|
218
|
+
"x": -0.753364,
|
|
143
219
|
"y": 0,
|
|
144
|
-
"subcircuit_id": "subcircuit_source_group_0"
|
|
220
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
221
|
+
"pcb_group_id": "pcb_group_0"
|
|
145
222
|
},
|
|
146
223
|
{
|
|
147
224
|
"type": "pcb_solder_paste",
|
|
148
225
|
"pcb_solder_paste_id": "pcb_solder_paste_1",
|
|
149
226
|
"layer": "top",
|
|
150
227
|
"shape": "rect",
|
|
151
|
-
"width": 0.
|
|
152
|
-
"height": 0.
|
|
153
|
-
"x": 0.
|
|
228
|
+
"width": 0.56453278,
|
|
229
|
+
"height": 0.60480448,
|
|
230
|
+
"x": -0.753364,
|
|
154
231
|
"y": 0,
|
|
155
232
|
"pcb_component_id": "pcb_component_0",
|
|
156
233
|
"pcb_smtpad_id": "pcb_smtpad_1",
|
|
157
|
-
"subcircuit_id": "subcircuit_source_group_0"
|
|
234
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
235
|
+
"pcb_group_id": "pcb_group_0"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"type": "pcb_silkscreen_path",
|
|
239
|
+
"pcb_silkscreen_path_id": "pcb_silkscreen_path_0",
|
|
240
|
+
"pcb_component_id": "pcb_component_0",
|
|
241
|
+
"layer": "top",
|
|
242
|
+
"route": [
|
|
243
|
+
{
|
|
244
|
+
"x": 0.42621199999996406,
|
|
245
|
+
"y": -0.6606031999999686
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"x": 1.3850873999999749,
|
|
249
|
+
"y": -0.6606031999999686
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"x": 1.3850873999999749,
|
|
253
|
+
"y": 0.6606031999999686
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"x": 0.42621199999996406,
|
|
257
|
+
"y": 0.6606031999999686
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
"stroke_width": 0.1,
|
|
261
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
262
|
+
"pcb_group_id": "pcb_group_0"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"type": "pcb_silkscreen_path",
|
|
266
|
+
"pcb_silkscreen_path_id": "pcb_silkscreen_path_1",
|
|
267
|
+
"pcb_component_id": "pcb_component_0",
|
|
268
|
+
"layer": "top",
|
|
269
|
+
"route": [
|
|
270
|
+
{
|
|
271
|
+
"x": -0.42621200000007775,
|
|
272
|
+
"y": -0.6606031999999686
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"x": -1.3850874000000886,
|
|
276
|
+
"y": -0.6606031999999686
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"x": -1.3850874000000886,
|
|
280
|
+
"y": 0.6606031999999686
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"x": -0.42621200000007775,
|
|
284
|
+
"y": 0.6606031999999686
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"stroke_width": 0.1,
|
|
288
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
289
|
+
"pcb_group_id": "pcb_group_0"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"type": "pcb_silkscreen_text",
|
|
293
|
+
"pcb_silkscreen_text_id": "pcb_silkscreen_text_0",
|
|
294
|
+
"anchor_alignment": "center",
|
|
295
|
+
"anchor_position": {
|
|
296
|
+
"x": -0.0127,
|
|
297
|
+
"y": 1.6604
|
|
298
|
+
},
|
|
299
|
+
"font": "tscircuit2024",
|
|
300
|
+
"font_size": 1,
|
|
301
|
+
"layer": "top",
|
|
302
|
+
"text": "unnamed_chip1",
|
|
303
|
+
"ccw_rotation": 0,
|
|
304
|
+
"pcb_component_id": "pcb_component_0",
|
|
305
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
306
|
+
"pcb_group_id": "pcb_group_0"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"type": "pcb_courtyard_outline",
|
|
310
|
+
"pcb_courtyard_outline_id": "pcb_courtyard_outline_0",
|
|
311
|
+
"pcb_component_id": "pcb_component_0",
|
|
312
|
+
"layer": "top",
|
|
313
|
+
"outline": [
|
|
314
|
+
{
|
|
315
|
+
"x": -1.647000000000162,
|
|
316
|
+
"y": 0.9103999999999814
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"x": 1.6216000000000577,
|
|
320
|
+
"y": 0.9103999999999814
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"x": 1.6216000000000577,
|
|
324
|
+
"y": -0.9103999999998678
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"x": -1.647000000000162,
|
|
328
|
+
"y": -0.9103999999998678
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"x": -1.647000000000162,
|
|
332
|
+
"y": 0.9103999999999814
|
|
333
|
+
}
|
|
334
|
+
],
|
|
335
|
+
"subcircuit_id": "subcircuit_source_group_0",
|
|
336
|
+
"pcb_group_id": "pcb_group_0"
|
|
158
337
|
},
|
|
159
338
|
{
|
|
160
339
|
"type": "pcb_port",
|
|
@@ -162,7 +341,8 @@
|
|
|
162
341
|
"pcb_component_id": "pcb_component_0",
|
|
163
342
|
"layers": ["top"],
|
|
164
343
|
"subcircuit_id": "subcircuit_source_group_0",
|
|
165
|
-
"
|
|
344
|
+
"pcb_group_id": "pcb_group_0",
|
|
345
|
+
"x": -0.753364,
|
|
166
346
|
"y": 0,
|
|
167
347
|
"source_port_id": "source_port_0"
|
|
168
348
|
},
|
|
@@ -172,7 +352,8 @@
|
|
|
172
352
|
"pcb_component_id": "pcb_component_0",
|
|
173
353
|
"layers": ["top"],
|
|
174
354
|
"subcircuit_id": "subcircuit_source_group_0",
|
|
175
|
-
"
|
|
355
|
+
"pcb_group_id": "pcb_group_0",
|
|
356
|
+
"x": 0.753364,
|
|
176
357
|
"y": 0,
|
|
177
358
|
"source_port_id": "source_port_1"
|
|
178
359
|
},
|
|
@@ -182,15 +363,23 @@
|
|
|
182
363
|
"position": {
|
|
183
364
|
"x": 0,
|
|
184
365
|
"y": 0,
|
|
185
|
-
"z": 0
|
|
366
|
+
"z": 0
|
|
186
367
|
},
|
|
187
368
|
"rotation": {
|
|
188
369
|
"x": 0,
|
|
189
370
|
"y": 0,
|
|
190
|
-
"z":
|
|
371
|
+
"z": 90
|
|
191
372
|
},
|
|
192
373
|
"pcb_component_id": "pcb_component_0",
|
|
193
374
|
"source_component_id": "source_component_0",
|
|
194
|
-
"
|
|
375
|
+
"model_obj_url": "https://modelcdn.tscircuit.com/easyeda_models/assets/C25804.obj?uuid=6bd5cd867e9542ebae21caaf5d2d4c4d&cachebust_origin=https%3A%2F%2Ftscircuit.com",
|
|
376
|
+
"model_step_url": "https://modelcdn.tscircuit.com/easyeda_models/assets/C25804.step?uuid=6bd5cd867e9542ebae21caaf5d2d4c4d&cachebust_origin=https%3A%2F%2Ftscircuit.com",
|
|
377
|
+
"model_origin_alignment": "center_of_component_on_board_surface",
|
|
378
|
+
"anchor_alignment": "center_of_component_on_board_surface",
|
|
379
|
+
"model_origin_position": {
|
|
380
|
+
"x": -0.004999999999999977,
|
|
381
|
+
"y": 0,
|
|
382
|
+
"z": -0.01
|
|
383
|
+
}
|
|
195
384
|
}
|
|
196
385
|
]
|
|
@@ -1,13 +1,65 @@
|
|
|
1
|
-
// lib/
|
|
1
|
+
// lib/get-board-using-template.ts
|
|
2
|
+
import { mmStr } from "@tscircuit/mm";
|
|
2
3
|
import { su } from "@tscircuit/soup-util";
|
|
4
|
+
var getBoardUsingTemplate = ({ circuitJson }) => {
|
|
5
|
+
const pcbBoard = su(circuitJson).pcb_board.list()[0];
|
|
6
|
+
const boardProps = [];
|
|
7
|
+
if (pcbBoard) {
|
|
8
|
+
if (pcbBoard.width !== void 0) {
|
|
9
|
+
boardProps.push(`width="${mmStr(pcbBoard.width)}"`);
|
|
10
|
+
}
|
|
11
|
+
if (pcbBoard.height !== void 0) {
|
|
12
|
+
boardProps.push(`height="${mmStr(pcbBoard.height)}"`);
|
|
13
|
+
}
|
|
14
|
+
if (pcbBoard.outline && pcbBoard.outline.length > 0) {
|
|
15
|
+
const points = pcbBoard.outline.map((p) => `{ x: ${p.x}, y: ${p.y} }`).join(", ");
|
|
16
|
+
boardProps.push(`outline={[${points}]}`);
|
|
17
|
+
}
|
|
18
|
+
if (pcbBoard.thickness !== void 0) {
|
|
19
|
+
boardProps.push(`thickness="${mmStr(pcbBoard.thickness)}"`);
|
|
20
|
+
}
|
|
21
|
+
if (pcbBoard.num_layers !== void 0) {
|
|
22
|
+
boardProps.push(`layers={${pcbBoard.num_layers}}`);
|
|
23
|
+
}
|
|
24
|
+
if (pcbBoard.material !== void 0) {
|
|
25
|
+
boardProps.push(`material="${pcbBoard.material}"`);
|
|
26
|
+
}
|
|
27
|
+
if (pcbBoard.solder_mask_color !== void 0) {
|
|
28
|
+
boardProps.push(`solderMaskColor="${pcbBoard.solder_mask_color}"`);
|
|
29
|
+
}
|
|
30
|
+
if (pcbBoard.silkscreen_color !== void 0) {
|
|
31
|
+
boardProps.push(`silkscreenColor="${pcbBoard.silkscreen_color}"`);
|
|
32
|
+
}
|
|
33
|
+
if (pcbBoard.anchor_position !== void 0) {
|
|
34
|
+
boardProps.push(
|
|
35
|
+
`boardAnchorPosition={{ x: ${pcbBoard.anchor_position.x}, y: ${pcbBoard.anchor_position.y} }}`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (pcbBoard.anchor_alignment !== void 0) {
|
|
39
|
+
boardProps.push(`boardAnchorAlignment="${pcbBoard.anchor_alignment}"`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const boardPropsStr = boardProps.join(" ");
|
|
43
|
+
const children = "";
|
|
44
|
+
return `
|
|
45
|
+
export default () => (
|
|
46
|
+
<board${boardPropsStr ? ` ${boardPropsStr}` : ""}>
|
|
47
|
+
${children}
|
|
48
|
+
</board>
|
|
49
|
+
)
|
|
50
|
+
`.replace(/\n\s*\n/g, "\n").trim();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// lib/generate-footprint-tsx/convert-copper-text.ts
|
|
54
|
+
import { su as su2 } from "@tscircuit/soup-util";
|
|
3
55
|
|
|
4
56
|
// lib/generate-footprint-tsx/helpers.ts
|
|
5
|
-
import { mmStr } from "@tscircuit/mm";
|
|
57
|
+
import { mmStr as mmStr2 } from "@tscircuit/mm";
|
|
6
58
|
var escapeJsxText = (value) => String(value ?? "").replace(/"/g, '\\"');
|
|
7
|
-
var formatMm = (value) =>
|
|
59
|
+
var formatMm = (value) => mmStr2(value ?? 0);
|
|
8
60
|
var formatOptionalMmAttr = (attrName, value) => {
|
|
9
61
|
if (value === void 0) return "";
|
|
10
|
-
return ` ${attrName}="${
|
|
62
|
+
return ` ${attrName}="${mmStr2(value)}"`;
|
|
11
63
|
};
|
|
12
64
|
var formatSolderMaskAttrs = (platedHole) => `${platedHole.is_covered_with_solder_mask === void 0 ? "" : ` coveredWithSolderMask={${platedHole.is_covered_with_solder_mask}}`}${formatOptionalMmAttr("solderMaskMargin", platedHole.soldermask_margin)}`;
|
|
13
65
|
var formatPcbRotationAttr = (rotation, attrName = "pcbRotation") => {
|
|
@@ -18,7 +70,7 @@ var formatPcbRotationAttr = (rotation, attrName = "pcbRotation") => {
|
|
|
18
70
|
|
|
19
71
|
// lib/generate-footprint-tsx/convert-copper-text.ts
|
|
20
72
|
var convertCopperText = (circuitJson) => {
|
|
21
|
-
const copperTexts =
|
|
73
|
+
const copperTexts = su2(circuitJson).pcb_copper_text.list();
|
|
22
74
|
const elementStrings = [];
|
|
23
75
|
for (const copperText of copperTexts) {
|
|
24
76
|
const anchorPosition = copperText.anchor_position ?? { x: 0, y: 0 };
|
|
@@ -52,11 +104,11 @@ var convertCopperText = (circuitJson) => {
|
|
|
52
104
|
};
|
|
53
105
|
|
|
54
106
|
// lib/generate-footprint-tsx/convert-courtyard.ts
|
|
55
|
-
import { su as
|
|
107
|
+
import { su as su3 } from "@tscircuit/soup-util";
|
|
56
108
|
var convertCourtyard = (circuitJson) => {
|
|
57
|
-
const courtyardOutlines =
|
|
58
|
-
const courtyardRects =
|
|
59
|
-
const courtyardCircles =
|
|
109
|
+
const courtyardOutlines = su3(circuitJson).pcb_courtyard_outline.list();
|
|
110
|
+
const courtyardRects = su3(circuitJson).pcb_courtyard_rect.list();
|
|
111
|
+
const courtyardCircles = su3(circuitJson).pcb_courtyard_circle.list();
|
|
60
112
|
const elementStrings = [];
|
|
61
113
|
for (const courtyardOutline of courtyardOutlines) {
|
|
62
114
|
const attrs = [
|
|
@@ -94,9 +146,9 @@ var convertCourtyard = (circuitJson) => {
|
|
|
94
146
|
};
|
|
95
147
|
|
|
96
148
|
// lib/generate-footprint-tsx/convert-cutouts.ts
|
|
97
|
-
import { su as
|
|
149
|
+
import { su as su4 } from "@tscircuit/soup-util";
|
|
98
150
|
var convertCutouts = (circuitJson) => {
|
|
99
|
-
const pcbCutouts =
|
|
151
|
+
const pcbCutouts = su4(circuitJson).pcb_cutout.list();
|
|
100
152
|
const elementStrings = [];
|
|
101
153
|
for (const cutout of pcbCutouts) {
|
|
102
154
|
if (cutout.shape === "rect") {
|
|
@@ -120,12 +172,12 @@ var convertCutouts = (circuitJson) => {
|
|
|
120
172
|
};
|
|
121
173
|
|
|
122
174
|
// lib/generate-footprint-tsx/convert-fabrication.ts
|
|
123
|
-
import { su as
|
|
175
|
+
import { su as su5 } from "@tscircuit/soup-util";
|
|
124
176
|
var convertFabrication = (circuitJson) => {
|
|
125
|
-
const fabricationNotePaths =
|
|
126
|
-
const fabricationNoteTexts =
|
|
127
|
-
const fabricationNoteRects =
|
|
128
|
-
const fabricationNoteDimensions =
|
|
177
|
+
const fabricationNotePaths = su5(circuitJson).pcb_fabrication_note_path.list();
|
|
178
|
+
const fabricationNoteTexts = su5(circuitJson).pcb_fabrication_note_text.list();
|
|
179
|
+
const fabricationNoteRects = su5(circuitJson).pcb_fabrication_note_rect.list();
|
|
180
|
+
const fabricationNoteDimensions = su5(circuitJson).pcb_fabrication_note_dimension.list();
|
|
129
181
|
const elementStrings = [];
|
|
130
182
|
for (const fabPath of fabricationNotePaths) {
|
|
131
183
|
const attrs = [`route={${JSON.stringify(fabPath.route)}}`];
|
|
@@ -229,27 +281,27 @@ var convertFabrication = (circuitJson) => {
|
|
|
229
281
|
};
|
|
230
282
|
|
|
231
283
|
// lib/generate-footprint-tsx/convert-holes.ts
|
|
232
|
-
import { su as
|
|
233
|
-
import { mmStr as
|
|
284
|
+
import { su as su6 } from "@tscircuit/soup-util";
|
|
285
|
+
import { mmStr as mmStr3 } from "@tscircuit/mm";
|
|
234
286
|
var convertHoles = (circuitJson) => {
|
|
235
|
-
const holes =
|
|
287
|
+
const holes = su6(circuitJson).pcb_hole.list();
|
|
236
288
|
const elementStrings = [];
|
|
237
289
|
for (const hole of holes) {
|
|
238
290
|
if (hole.hole_shape === "circle") {
|
|
239
291
|
elementStrings.push(
|
|
240
|
-
`<hole pcbX="${
|
|
292
|
+
`<hole pcbX="${mmStr3(hole.x)}" pcbY="${mmStr3(hole.y)}" diameter="${mmStr3(hole.hole_diameter)}" />`
|
|
241
293
|
);
|
|
242
294
|
} else if (hole.hole_shape === "rect") {
|
|
243
295
|
elementStrings.push(
|
|
244
|
-
`<hole pcbX="${
|
|
296
|
+
`<hole pcbX="${mmStr3(hole.x)}" pcbY="${mmStr3(hole.y)}" width="${mmStr3(hole.hole_width)}" height="${mmStr3(hole.hole_height)}" shape="rect" />`
|
|
245
297
|
);
|
|
246
298
|
} else if (hole.hole_shape === "oval") {
|
|
247
299
|
elementStrings.push(
|
|
248
|
-
`<hole pcbX="${
|
|
300
|
+
`<hole pcbX="${mmStr3(hole.x)}" pcbY="${mmStr3(hole.y)}" width="${mmStr3(hole.hole_width)}" height="${mmStr3(hole.hole_height)}" shape="oval" />`
|
|
249
301
|
);
|
|
250
302
|
} else if (hole.hole_shape === "pill" || hole.hole_shape === "rotated_pill") {
|
|
251
303
|
elementStrings.push(
|
|
252
|
-
`<hole pcbX="${
|
|
304
|
+
`<hole pcbX="${mmStr3(hole.x)}" pcbY="${mmStr3(hole.y)}" width="${mmStr3(hole.hole_width)}" height="${mmStr3(hole.hole_height)}" shape="pill"${formatPcbRotationAttr("ccw_rotation" in hole ? hole.ccw_rotation : void 0)} />`
|
|
253
305
|
);
|
|
254
306
|
}
|
|
255
307
|
}
|
|
@@ -257,9 +309,9 @@ var convertHoles = (circuitJson) => {
|
|
|
257
309
|
};
|
|
258
310
|
|
|
259
311
|
// lib/generate-footprint-tsx/convert-keepouts.ts
|
|
260
|
-
import { su as
|
|
312
|
+
import { su as su7 } from "@tscircuit/soup-util";
|
|
261
313
|
var convertKeepouts = (circuitJson) => {
|
|
262
|
-
const pcbKeepouts =
|
|
314
|
+
const pcbKeepouts = su7(circuitJson).pcb_keepout.list();
|
|
263
315
|
const elementStrings = [];
|
|
264
316
|
for (const keepout of pcbKeepouts) {
|
|
265
317
|
if (keepout.shape === "rect") {
|
|
@@ -278,13 +330,13 @@ var convertKeepouts = (circuitJson) => {
|
|
|
278
330
|
};
|
|
279
331
|
|
|
280
332
|
// lib/generate-footprint-tsx/convert-notes.ts
|
|
281
|
-
import { su as
|
|
333
|
+
import { su as su8 } from "@tscircuit/soup-util";
|
|
282
334
|
var convertNotes = (circuitJson) => {
|
|
283
|
-
const noteTexts =
|
|
284
|
-
const noteRects =
|
|
285
|
-
const notePaths =
|
|
286
|
-
const noteLines =
|
|
287
|
-
const noteDimensions =
|
|
335
|
+
const noteTexts = su8(circuitJson).pcb_note_text.list();
|
|
336
|
+
const noteRects = su8(circuitJson).pcb_note_rect.list();
|
|
337
|
+
const notePaths = su8(circuitJson).pcb_note_path.list();
|
|
338
|
+
const noteLines = su8(circuitJson).pcb_note_line.list();
|
|
339
|
+
const noteDimensions = su8(circuitJson).pcb_note_dimension.list();
|
|
288
340
|
const elementStrings = [];
|
|
289
341
|
for (const noteText of noteTexts) {
|
|
290
342
|
const anchorPosition = noteText.anchor_position ?? { x: 0, y: 0 };
|
|
@@ -374,34 +426,34 @@ var convertNotes = (circuitJson) => {
|
|
|
374
426
|
};
|
|
375
427
|
|
|
376
428
|
// lib/generate-footprint-tsx/convert-plated-holes.ts
|
|
377
|
-
import { su as
|
|
378
|
-
import { mmStr as
|
|
429
|
+
import { su as su9 } from "@tscircuit/soup-util";
|
|
430
|
+
import { mmStr as mmStr4 } from "@tscircuit/mm";
|
|
379
431
|
var convertPlatedHoles = (circuitJson) => {
|
|
380
|
-
const platedHoles =
|
|
432
|
+
const platedHoles = su9(circuitJson).pcb_plated_hole.list();
|
|
381
433
|
const elementStrings = [];
|
|
382
434
|
for (const platedHole of platedHoles) {
|
|
383
435
|
if (platedHole.shape === "oval" || platedHole.shape === "pill") {
|
|
384
436
|
elementStrings.push(
|
|
385
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
437
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${formatSolderMaskAttrs(platedHole)} outerHeight="${mmStr4(platedHole.outer_height)}" outerWidth="${mmStr4(platedHole.outer_width)}" holeHeight="${mmStr4(platedHole.hole_height)}" holeWidth="${mmStr4(platedHole.hole_width)}" height="${mmStr4(platedHole.hole_height)}" shape="${platedHole.shape}"${formatPcbRotationAttr("ccw_rotation" in platedHole ? platedHole.ccw_rotation : void 0)} />`
|
|
386
438
|
);
|
|
387
439
|
} else if (platedHole.shape === "circle") {
|
|
388
440
|
elementStrings.push(
|
|
389
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
441
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${formatSolderMaskAttrs(platedHole)} outerDiameter="${mmStr4(platedHole.outer_diameter)}" holeDiameter="${mmStr4(platedHole.hole_diameter)}" shape="circle" />`
|
|
390
442
|
);
|
|
391
443
|
} else if (platedHole.shape === "circular_hole_with_rect_pad") {
|
|
392
444
|
elementStrings.push(
|
|
393
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
445
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${platedHole.hole_shape === void 0 ? "" : ` holeShape="${platedHole.hole_shape}"`}${platedHole.pad_shape === void 0 ? "" : ` padShape="${platedHole.pad_shape}"`}${formatSolderMaskAttrs(platedHole)} holeDiameter="${mmStr4(platedHole.hole_diameter)}" rectPadWidth="${mmStr4(platedHole.rect_pad_width)}" rectPadHeight="${mmStr4(platedHole.rect_pad_height)}"${formatOptionalMmAttr("rectBorderRadius", platedHole.rect_border_radius)}${formatOptionalMmAttr("holeOffsetX", platedHole.hole_offset_x)}${formatOptionalMmAttr("holeOffsetY", platedHole.hole_offset_y)}${formatPcbRotationAttr(platedHole.rect_ccw_rotation)} shape="circular_hole_with_rect_pad" />`
|
|
394
446
|
);
|
|
395
447
|
} else if (platedHole.shape === "pill_hole_with_rect_pad" || platedHole.shape === "rotated_pill_hole_with_rect_pad") {
|
|
396
448
|
const holeShape = platedHole.shape === "rotated_pill_hole_with_rect_pad" ? "pill" : platedHole.hole_shape;
|
|
397
449
|
const rotation = platedHole.shape === "rotated_pill_hole_with_rect_pad" ? platedHole.hole_ccw_rotation : void 0;
|
|
398
450
|
elementStrings.push(
|
|
399
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
451
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${holeShape === void 0 ? "" : ` holeShape="${holeShape}"`}${platedHole.pad_shape === void 0 ? "" : ` padShape="${platedHole.pad_shape}"`}${formatSolderMaskAttrs(platedHole)} holeWidth="${mmStr4(platedHole.hole_width)}" holeHeight="${mmStr4(platedHole.hole_height)}" rectPadWidth="${mmStr4(platedHole.rect_pad_width)}" rectPadHeight="${mmStr4(platedHole.rect_pad_height)}"${formatOptionalMmAttr("rectBorderRadius", platedHole.rect_border_radius)}${formatOptionalMmAttr("holeOffsetX", platedHole.hole_offset_x)}${formatOptionalMmAttr("holeOffsetY", platedHole.hole_offset_y)}${formatPcbRotationAttr(rotation)} shape="pill_hole_with_rect_pad" />`
|
|
400
452
|
);
|
|
401
453
|
} else if (platedHole.shape === "hole_with_polygon_pad") {
|
|
402
|
-
const holeSizeAttrs = platedHole.hole_shape === "circle" ? ` holeDiameter="${
|
|
454
|
+
const holeSizeAttrs = platedHole.hole_shape === "circle" ? ` holeDiameter="${mmStr4(platedHole.hole_diameter ?? 0)}"` : `${formatOptionalMmAttr("holeWidth", platedHole.hole_width)}${formatOptionalMmAttr("holeHeight", platedHole.hole_height)}`;
|
|
403
455
|
elementStrings.push(
|
|
404
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
456
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${platedHole.hole_shape === void 0 ? "" : ` holeShape="${platedHole.hole_shape}"`}${formatSolderMaskAttrs(platedHole)}${holeSizeAttrs} padOutline={${JSON.stringify(platedHole.pad_outline)}} holeOffsetX="${mmStr4(platedHole.hole_offset_x ?? 0)}" holeOffsetY="${mmStr4(platedHole.hole_offset_y ?? 0)}" shape="hole_with_polygon_pad" />`
|
|
405
457
|
);
|
|
406
458
|
}
|
|
407
459
|
}
|
|
@@ -409,12 +461,12 @@ var convertPlatedHoles = (circuitJson) => {
|
|
|
409
461
|
};
|
|
410
462
|
|
|
411
463
|
// lib/generate-footprint-tsx/convert-silkscreen.ts
|
|
412
|
-
import { su as
|
|
464
|
+
import { su as su10 } from "@tscircuit/soup-util";
|
|
413
465
|
var convertSilkscreen = (circuitJson) => {
|
|
414
|
-
const silkscreenLines =
|
|
415
|
-
const silkscreenPaths =
|
|
416
|
-
const silkscreenRects =
|
|
417
|
-
const silkscreenCircles =
|
|
466
|
+
const silkscreenLines = su10(circuitJson).pcb_silkscreen_line.list();
|
|
467
|
+
const silkscreenPaths = su10(circuitJson).pcb_silkscreen_path.list();
|
|
468
|
+
const silkscreenRects = su10(circuitJson).pcb_silkscreen_rect.list();
|
|
469
|
+
const silkscreenCircles = su10(circuitJson).pcb_silkscreen_circle.list();
|
|
418
470
|
const elementStrings = [];
|
|
419
471
|
for (const silkscreenPath of silkscreenPaths) {
|
|
420
472
|
elementStrings.push(
|
|
@@ -476,10 +528,10 @@ var convertSilkscreen = (circuitJson) => {
|
|
|
476
528
|
};
|
|
477
529
|
|
|
478
530
|
// lib/generate-footprint-tsx/convert-silkscreen-text.ts
|
|
479
|
-
import { su as
|
|
480
|
-
import { mmStr as
|
|
531
|
+
import { su as su11 } from "@tscircuit/soup-util";
|
|
532
|
+
import { mmStr as mmStr5 } from "@tscircuit/mm";
|
|
481
533
|
var convertSilkscreenText = (circuitJson) => {
|
|
482
|
-
const silkscreenTexts =
|
|
534
|
+
const silkscreenTexts = su11(circuitJson).pcb_silkscreen_text.list();
|
|
483
535
|
const elementStrings = [];
|
|
484
536
|
for (const silkscreenText of silkscreenTexts) {
|
|
485
537
|
const pcbX = silkscreenText.anchor_position?.x ?? 0;
|
|
@@ -487,17 +539,17 @@ var convertSilkscreenText = (circuitJson) => {
|
|
|
487
539
|
const knockoutPadding = silkscreenText.knockout_padding;
|
|
488
540
|
const hasUniformKnockoutPadding = knockoutPadding && knockoutPadding.left === knockoutPadding.top && knockoutPadding.top === knockoutPadding.right && knockoutPadding.right === knockoutPadding.bottom;
|
|
489
541
|
elementStrings.push(
|
|
490
|
-
`<silkscreentext pcbX={${pcbX}} pcbY={${pcbY}} anchorAlignment="${silkscreenText.anchor_alignment}" fontSize={${silkscreenText.font_size}}${silkscreenText.font !== void 0 ? ` font="${silkscreenText.font}"` : ""}${silkscreenText.ccw_rotation !== void 0 ? ` pcbRotation="${typeof silkscreenText.ccw_rotation === "number" ? `${silkscreenText.ccw_rotation}deg` : silkscreenText.ccw_rotation}"` : ""}${silkscreenText.is_knockout !== void 0 ? ` isKnockout={${silkscreenText.is_knockout}}` : ""}${knockoutPadding ? hasUniformKnockoutPadding ? ` knockoutPadding="${
|
|
542
|
+
`<silkscreentext pcbX={${pcbX}} pcbY={${pcbY}} anchorAlignment="${silkscreenText.anchor_alignment}" fontSize={${silkscreenText.font_size}}${silkscreenText.font !== void 0 ? ` font="${silkscreenText.font}"` : ""}${silkscreenText.ccw_rotation !== void 0 ? ` pcbRotation="${typeof silkscreenText.ccw_rotation === "number" ? `${silkscreenText.ccw_rotation}deg` : silkscreenText.ccw_rotation}"` : ""}${silkscreenText.is_knockout !== void 0 ? ` isKnockout={${silkscreenText.is_knockout}}` : ""}${knockoutPadding ? hasUniformKnockoutPadding ? ` knockoutPadding="${mmStr5(knockoutPadding.left)}"` : ` knockoutPaddingLeft="${mmStr5(knockoutPadding.left)}" knockoutPaddingTop="${mmStr5(knockoutPadding.top)}" knockoutPaddingRight="${mmStr5(knockoutPadding.right)}" knockoutPaddingBottom="${mmStr5(knockoutPadding.bottom)}"` : ""}${silkscreenText.is_mirrored !== void 0 ? ` mirrored={${silkscreenText.is_mirrored}}` : ""}${silkscreenText.layer !== void 0 ? ` layer="${silkscreenText.layer}"` : ""} text="${escapeJsxText(silkscreenText.text)}" />`
|
|
491
543
|
);
|
|
492
544
|
}
|
|
493
545
|
return elementStrings;
|
|
494
546
|
};
|
|
495
547
|
|
|
496
548
|
// lib/generate-footprint-tsx/convert-smt-pads.ts
|
|
497
|
-
import { su as
|
|
498
|
-
import { mmStr as
|
|
549
|
+
import { su as su12 } from "@tscircuit/soup-util";
|
|
550
|
+
import { mmStr as mmStr6 } from "@tscircuit/mm";
|
|
499
551
|
var convertSmtPads = (circuitJson) => {
|
|
500
|
-
const smtPads =
|
|
552
|
+
const smtPads = su12(circuitJson).pcb_smtpad.list();
|
|
501
553
|
const elementStrings = [];
|
|
502
554
|
for (const smtPad of smtPads) {
|
|
503
555
|
const commonAttrs = [];
|
|
@@ -505,10 +557,10 @@ var convertSmtPads = (circuitJson) => {
|
|
|
505
557
|
commonAttrs.push(`portHints={${JSON.stringify(smtPad.port_hints)}}`);
|
|
506
558
|
}
|
|
507
559
|
if ("x" in smtPad && smtPad.x !== void 0) {
|
|
508
|
-
commonAttrs.push(`pcbX="${
|
|
560
|
+
commonAttrs.push(`pcbX="${mmStr6(smtPad.x)}"`);
|
|
509
561
|
}
|
|
510
562
|
if ("y" in smtPad && smtPad.y !== void 0) {
|
|
511
|
-
commonAttrs.push(`pcbY="${
|
|
563
|
+
commonAttrs.push(`pcbY="${mmStr6(smtPad.y)}"`);
|
|
512
564
|
}
|
|
513
565
|
if (smtPad.layer !== void 0) {
|
|
514
566
|
commonAttrs.push(`layer="${smtPad.layer}"`);
|
|
@@ -519,47 +571,47 @@ var convertSmtPads = (circuitJson) => {
|
|
|
519
571
|
);
|
|
520
572
|
}
|
|
521
573
|
if (smtPad.soldermask_margin !== void 0) {
|
|
522
|
-
commonAttrs.push(`solderMaskMargin="${
|
|
574
|
+
commonAttrs.push(`solderMaskMargin="${mmStr6(smtPad.soldermask_margin)}"`);
|
|
523
575
|
}
|
|
524
576
|
if (smtPad.shape === "circle") {
|
|
525
577
|
elementStrings.push(
|
|
526
|
-
`<smtpad ${commonAttrs.join(" ")} radius="${
|
|
578
|
+
`<smtpad ${commonAttrs.join(" ")} radius="${mmStr6(smtPad.radius ?? 0)}" shape="circle" />`
|
|
527
579
|
);
|
|
528
580
|
} else if (smtPad.shape === "rect") {
|
|
529
581
|
if (smtPad.rect_border_radius !== void 0) {
|
|
530
582
|
commonAttrs.push(
|
|
531
|
-
`rectBorderRadius="${
|
|
583
|
+
`rectBorderRadius="${mmStr6(smtPad.rect_border_radius)}"`
|
|
532
584
|
);
|
|
533
585
|
}
|
|
534
586
|
if (smtPad.corner_radius !== void 0) {
|
|
535
|
-
commonAttrs.push(`cornerRadius="${
|
|
587
|
+
commonAttrs.push(`cornerRadius="${mmStr6(smtPad.corner_radius)}"`);
|
|
536
588
|
}
|
|
537
589
|
if (smtPad.soldermask_margin_left !== void 0) {
|
|
538
590
|
commonAttrs.push(
|
|
539
|
-
`solderMaskMarginLeft="${
|
|
591
|
+
`solderMaskMarginLeft="${mmStr6(smtPad.soldermask_margin_left)}"`
|
|
540
592
|
);
|
|
541
593
|
}
|
|
542
594
|
if (smtPad.soldermask_margin_top !== void 0) {
|
|
543
595
|
commonAttrs.push(
|
|
544
|
-
`solderMaskMarginTop="${
|
|
596
|
+
`solderMaskMarginTop="${mmStr6(smtPad.soldermask_margin_top)}"`
|
|
545
597
|
);
|
|
546
598
|
}
|
|
547
599
|
if (smtPad.soldermask_margin_right !== void 0) {
|
|
548
600
|
commonAttrs.push(
|
|
549
|
-
`solderMaskMarginRight="${
|
|
601
|
+
`solderMaskMarginRight="${mmStr6(smtPad.soldermask_margin_right)}"`
|
|
550
602
|
);
|
|
551
603
|
}
|
|
552
604
|
if (smtPad.soldermask_margin_bottom !== void 0) {
|
|
553
605
|
commonAttrs.push(
|
|
554
|
-
`solderMaskMarginBottom="${
|
|
606
|
+
`solderMaskMarginBottom="${mmStr6(smtPad.soldermask_margin_bottom)}"`
|
|
555
607
|
);
|
|
556
608
|
}
|
|
557
609
|
elementStrings.push(
|
|
558
|
-
`<smtpad ${commonAttrs.join(" ")} width="${
|
|
610
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr6(smtPad.width ?? 0)}" height="${mmStr6(smtPad.height ?? 0)}" shape="rect" />`
|
|
559
611
|
);
|
|
560
612
|
} else if (smtPad.shape === "pill") {
|
|
561
613
|
elementStrings.push(
|
|
562
|
-
`<smtpad ${commonAttrs.join(" ")} width="${
|
|
614
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr6(smtPad.width ?? 0)}" height="${mmStr6(smtPad.height ?? 0)}" radius="${mmStr6(smtPad.radius ?? 0)}" shape="pill" />`
|
|
563
615
|
);
|
|
564
616
|
} else if (smtPad.shape === "polygon") {
|
|
565
617
|
elementStrings.push(
|
|
@@ -568,30 +620,30 @@ var convertSmtPads = (circuitJson) => {
|
|
|
568
620
|
} else if (smtPad.shape === "rotated_rect") {
|
|
569
621
|
const cornerRadius = smtPad.corner_radius ?? smtPad.rect_border_radius ?? void 0;
|
|
570
622
|
if (cornerRadius !== void 0) {
|
|
571
|
-
commonAttrs.push(`cornerRadius="${
|
|
623
|
+
commonAttrs.push(`cornerRadius="${mmStr6(cornerRadius)}"`);
|
|
572
624
|
}
|
|
573
625
|
if (smtPad.soldermask_margin_left !== void 0) {
|
|
574
626
|
commonAttrs.push(
|
|
575
|
-
`solderMaskMarginLeft="${
|
|
627
|
+
`solderMaskMarginLeft="${mmStr6(smtPad.soldermask_margin_left)}"`
|
|
576
628
|
);
|
|
577
629
|
}
|
|
578
630
|
if (smtPad.soldermask_margin_top !== void 0) {
|
|
579
631
|
commonAttrs.push(
|
|
580
|
-
`solderMaskMarginTop="${
|
|
632
|
+
`solderMaskMarginTop="${mmStr6(smtPad.soldermask_margin_top)}"`
|
|
581
633
|
);
|
|
582
634
|
}
|
|
583
635
|
if (smtPad.soldermask_margin_right !== void 0) {
|
|
584
636
|
commonAttrs.push(
|
|
585
|
-
`solderMaskMarginRight="${
|
|
637
|
+
`solderMaskMarginRight="${mmStr6(smtPad.soldermask_margin_right)}"`
|
|
586
638
|
);
|
|
587
639
|
}
|
|
588
640
|
if (smtPad.soldermask_margin_bottom !== void 0) {
|
|
589
641
|
commonAttrs.push(
|
|
590
|
-
`solderMaskMarginBottom="${
|
|
642
|
+
`solderMaskMarginBottom="${mmStr6(smtPad.soldermask_margin_bottom)}"`
|
|
591
643
|
);
|
|
592
644
|
}
|
|
593
645
|
elementStrings.push(
|
|
594
|
-
`<smtpad ${commonAttrs.join(" ")} width="${
|
|
646
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr6(smtPad.width ?? 0)}" height="${mmStr6(smtPad.height ?? 0)}"${formatPcbRotationAttr(smtPad.ccw_rotation)} shape="rotated_rect" />`
|
|
595
647
|
);
|
|
596
648
|
}
|
|
597
649
|
}
|
|
@@ -625,18 +677,18 @@ var generateFootprintTsx = (circuitJson) => {
|
|
|
625
677
|
};
|
|
626
678
|
|
|
627
679
|
// lib/generate-symbol-tsx.ts
|
|
628
|
-
import { su as
|
|
680
|
+
import { su as su13 } from "@tscircuit/soup-util";
|
|
629
681
|
var escapeJsxText2 = (text) => text.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
630
682
|
var generateSymbolTsx = (circuitJson) => {
|
|
631
|
-
const schematicArcs =
|
|
632
|
-
const schematicLines =
|
|
633
|
-
const schematicPaths =
|
|
634
|
-
const schematicTexts =
|
|
635
|
-
const schematicCircles =
|
|
636
|
-
const schematicBoxes =
|
|
637
|
-
const schematicRects =
|
|
638
|
-
const schematicTables =
|
|
639
|
-
const schematicTableCells =
|
|
683
|
+
const schematicArcs = su13(circuitJson).schematic_arc.list();
|
|
684
|
+
const schematicLines = su13(circuitJson).schematic_line.list();
|
|
685
|
+
const schematicPaths = su13(circuitJson).schematic_path.list();
|
|
686
|
+
const schematicTexts = su13(circuitJson).schematic_text.list();
|
|
687
|
+
const schematicCircles = su13(circuitJson).schematic_circle.list();
|
|
688
|
+
const schematicBoxes = su13(circuitJson).schematic_box.list();
|
|
689
|
+
const schematicRects = su13(circuitJson).schematic_rect.list();
|
|
690
|
+
const schematicTables = su13(circuitJson).schematic_table.list();
|
|
691
|
+
const schematicTableCells = su13(circuitJson).schematic_table_cell.list();
|
|
640
692
|
const elementStrings = [];
|
|
641
693
|
for (const arc of schematicArcs) {
|
|
642
694
|
const center = arc.center ?? { x: 0, y: 0 };
|
|
@@ -873,6 +925,10 @@ ${pinLabels ? `const pinLabels = ${JSON.stringify(pinLabels, null, " ")} as con
|
|
|
873
925
|
|
|
874
926
|
// lib/index.ts
|
|
875
927
|
var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
928
|
+
const hasBoard = circuitJson.some((el) => el.type === "pcb_board");
|
|
929
|
+
if (hasBoard) {
|
|
930
|
+
return getBoardUsingTemplate({ circuitJson });
|
|
931
|
+
}
|
|
876
932
|
return getComponentUsingTemplate({
|
|
877
933
|
circuitJson,
|
|
878
934
|
...opts
|
package/dist/cli/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
convertCircuitJsonToTscircuit
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-G5NSFWRY.js";
|
|
5
5
|
|
|
6
6
|
// cli/main.ts
|
|
7
7
|
import { Command } from "commander";
|
|
@@ -16,7 +16,7 @@ var package_default = {
|
|
|
16
16
|
"./cli": "./dist/cli/main.js"
|
|
17
17
|
},
|
|
18
18
|
type: "module",
|
|
19
|
-
version: "0.0.
|
|
19
|
+
version: "0.0.38",
|
|
20
20
|
scripts: {
|
|
21
21
|
build: "tsup-node lib/index.ts cli/main.ts --format esm --dts",
|
|
22
22
|
test: "bun test",
|
package/dist/lib/index.js
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { mmStr } from "@tscircuit/mm"
|
|
2
|
+
import { su } from "@tscircuit/soup-util"
|
|
3
|
+
import type { AnyCircuitElement } from "circuit-json"
|
|
4
|
+
|
|
5
|
+
export interface BoardTemplateParams {
|
|
6
|
+
circuitJson: AnyCircuitElement[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const getBoardUsingTemplate = ({ circuitJson }: BoardTemplateParams) => {
|
|
10
|
+
const pcbBoard = su(circuitJson).pcb_board.list()[0]
|
|
11
|
+
|
|
12
|
+
const boardProps: string[] = []
|
|
13
|
+
|
|
14
|
+
if (pcbBoard) {
|
|
15
|
+
if (pcbBoard.width !== undefined) {
|
|
16
|
+
boardProps.push(`width="${mmStr(pcbBoard.width)}"`)
|
|
17
|
+
}
|
|
18
|
+
if (pcbBoard.height !== undefined) {
|
|
19
|
+
boardProps.push(`height="${mmStr(pcbBoard.height)}"`)
|
|
20
|
+
}
|
|
21
|
+
if (pcbBoard.outline && pcbBoard.outline.length > 0) {
|
|
22
|
+
const points = pcbBoard.outline
|
|
23
|
+
.map((p) => `{ x: ${p.x}, y: ${p.y} }`)
|
|
24
|
+
.join(", ")
|
|
25
|
+
boardProps.push(`outline={[${points}]}`)
|
|
26
|
+
}
|
|
27
|
+
if (pcbBoard.thickness !== undefined) {
|
|
28
|
+
boardProps.push(`thickness="${mmStr(pcbBoard.thickness)}"`)
|
|
29
|
+
}
|
|
30
|
+
if (pcbBoard.num_layers !== undefined) {
|
|
31
|
+
boardProps.push(`layers={${pcbBoard.num_layers}}`)
|
|
32
|
+
}
|
|
33
|
+
if (pcbBoard.material !== undefined) {
|
|
34
|
+
boardProps.push(`material="${pcbBoard.material}"`)
|
|
35
|
+
}
|
|
36
|
+
if (pcbBoard.solder_mask_color !== undefined) {
|
|
37
|
+
boardProps.push(`solderMaskColor="${pcbBoard.solder_mask_color}"`)
|
|
38
|
+
}
|
|
39
|
+
if (pcbBoard.silkscreen_color !== undefined) {
|
|
40
|
+
boardProps.push(`silkscreenColor="${pcbBoard.silkscreen_color}"`)
|
|
41
|
+
}
|
|
42
|
+
if (pcbBoard.anchor_position !== undefined) {
|
|
43
|
+
boardProps.push(
|
|
44
|
+
`boardAnchorPosition={{ x: ${pcbBoard.anchor_position.x}, y: ${pcbBoard.anchor_position.y} }}`,
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
if (pcbBoard.anchor_alignment !== undefined) {
|
|
48
|
+
boardProps.push(`boardAnchorAlignment="${pcbBoard.anchor_alignment}"`)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const boardPropsStr = boardProps.join(" ")
|
|
53
|
+
|
|
54
|
+
// Children slot - components and connections are added in later stages
|
|
55
|
+
const children = ""
|
|
56
|
+
|
|
57
|
+
return `
|
|
58
|
+
export default () => (
|
|
59
|
+
<board${boardPropsStr ? ` ${boardPropsStr}` : ""}>
|
|
60
|
+
${children}
|
|
61
|
+
</board>
|
|
62
|
+
)
|
|
63
|
+
`
|
|
64
|
+
.replace(/\n\s*\n/g, "\n")
|
|
65
|
+
.trim()
|
|
66
|
+
}
|
package/lib/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CircuitJson } from "circuit-json"
|
|
2
|
+
import { getBoardUsingTemplate } from "./get-board-using-template"
|
|
2
3
|
import {
|
|
3
4
|
getComponentUsingTemplate,
|
|
4
5
|
type ComponentTemplateParams,
|
|
@@ -8,6 +9,15 @@ export const convertCircuitJsonToTscircuit = (
|
|
|
8
9
|
circuitJson: CircuitJson,
|
|
9
10
|
opts: Omit<ComponentTemplateParams, "circuitJson">,
|
|
10
11
|
) => {
|
|
12
|
+
// A pcb_board is only present when the circuit json was authored as a
|
|
13
|
+
// board, so it routes to the board converter. A footprint/component import
|
|
14
|
+
// (the chip use case) has no pcb_board and falls through to the chip path.
|
|
15
|
+
const hasBoard = circuitJson.some((el) => el.type === "pcb_board")
|
|
16
|
+
|
|
17
|
+
if (hasBoard) {
|
|
18
|
+
return getBoardUsingTemplate({ circuitJson })
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
return getComponentUsingTemplate({
|
|
12
22
|
circuitJson,
|
|
13
23
|
...opts,
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" data-software-used-string="@tscircuit/core@0.0.1306"><style></style><rect class="boundary" x="0" y="0" fill="#000" width="800" height="600" data-type="pcb_background" data-pcb-layer="global"/><rect class="pcb-boundary" fill="none" stroke="#fff" stroke-width="0.3" x="36.36363636363632" y="118.18181818181816" width="727.2727272727275" height="363.63636363636374" data-type="pcb_boundary" data-pcb-layer="global"/><path class="pcb-board" d="M 36.36363636363632 481.81818181818187 L 763.6363636363637 481.81818181818187 L 763.6363636363637 118.18181818181816 L 36.36363636363632 118.18181818181816 Z" fill="none" stroke="rgba(255, 255, 255, 0.5)" stroke-width="3.6363636363636367" data-type="pcb_board" data-pcb-layer="board"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" data-software-used-string="@tscircuit/core@0.0.1322"><style></style><rect class="boundary" x="0" y="0" fill="#000" width="800" height="600" data-type="pcb_background" data-pcb-layer="global"/><rect class="pcb-boundary" fill="none" stroke="#fff" stroke-width="0.3" x="57.14285714285717" y="71.42857142857147" width="685.7142857142858" height="457.1428571428572" data-type="pcb_boundary" data-pcb-layer="global"/><path class="pcb-board" d="M 57.14285714285717 528.5714285714287 L 742.8571428571429 528.5714285714287 L 742.8571428571429 71.42857142857147 L 57.14285714285717 71.42857142857147 Z" fill="none" stroke="rgba(255, 255, 255, 0.5)" stroke-width="5.714285714285715" data-type="pcb_board" data-pcb-layer="board"/></svg>
|
|
@@ -22,9 +22,17 @@ test("should convert sample circuit.json to TSX", async () => {
|
|
|
22
22
|
export const Circuit = (props: ChipProps) => (
|
|
23
23
|
<chip
|
|
24
24
|
footprint={<footprint>
|
|
25
|
-
<smtpad portHints={["
|
|
26
|
-
<smtpad portHints={["
|
|
25
|
+
<smtpad portHints={["pin2"]} pcbX="0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
|
|
26
|
+
<smtpad portHints={["pin1"]} pcbX="-0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
|
|
27
|
+
<silkscreenpath route={[{"x":0.42621199999996406,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":0.6606031999999686},{"x":0.42621199999996406,"y":0.6606031999999686}]} />
|
|
28
|
+
<silkscreenpath route={[{"x":-0.42621200000007775,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":0.6606031999999686},{"x":-0.42621200000007775,"y":0.6606031999999686}]} />
|
|
29
|
+
<silkscreentext pcbX={-0.0127} pcbY={1.6604} anchorAlignment="center" fontSize={1} font="tscircuit2024" pcbRotation="0deg" layer="top" text="unnamed_chip1" />
|
|
30
|
+
<courtyardoutline outline={[{"x":-1.647000000000162,"y":0.9103999999999814},{"x":1.6216000000000577,"y":0.9103999999999814},{"x":1.6216000000000577,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":0.9103999999999814}]} layer="top" />
|
|
27
31
|
</footprint>}
|
|
32
|
+
symbol={<symbol>
|
|
33
|
+
<schematictext text="A_0603WAF1002T5E" x={-0.6000000000000001} y={-0.33} anchorAlignment="left" fontSize={0.18} color="#006464" rotation={0} />
|
|
34
|
+
<schematictext text="" x={-0.6000000000000001} y={0.33} anchorAlignment="left" fontSize={0.18} color="#006464" rotation={0} />
|
|
35
|
+
</symbol>}
|
|
28
36
|
{...props}
|
|
29
37
|
/>
|
|
30
38
|
)"
|
|
@@ -17,6 +17,8 @@ test("test1 basic circuit", async () => {
|
|
|
17
17
|
),
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
+
// A circuit json with no pcb_board is a footprint/component import, so it
|
|
21
|
+
// routes to the chip converter rather than the board converter
|
|
20
22
|
const tscircuit = convertCircuitJsonToTscircuit(circuitJson, {
|
|
21
23
|
componentName: "MyResistor",
|
|
22
24
|
})
|
|
@@ -26,9 +28,17 @@ test("test1 basic circuit", async () => {
|
|
|
26
28
|
export const MyResistor = (props: ChipProps) => (
|
|
27
29
|
<chip
|
|
28
30
|
footprint={<footprint>
|
|
29
|
-
<smtpad portHints={["
|
|
30
|
-
<smtpad portHints={["
|
|
31
|
+
<smtpad portHints={["pin2"]} pcbX="0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
|
|
32
|
+
<smtpad portHints={["pin1"]} pcbX="-0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
|
|
33
|
+
<silkscreenpath route={[{"x":0.42621199999996406,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":0.6606031999999686},{"x":0.42621199999996406,"y":0.6606031999999686}]} />
|
|
34
|
+
<silkscreenpath route={[{"x":-0.42621200000007775,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":0.6606031999999686},{"x":-0.42621200000007775,"y":0.6606031999999686}]} />
|
|
35
|
+
<silkscreentext pcbX={-0.0127} pcbY={1.6604} anchorAlignment="center" fontSize={1} font="tscircuit2024" pcbRotation="0deg" layer="top" text="unnamed_chip1" />
|
|
36
|
+
<courtyardoutline outline={[{"x":-1.647000000000162,"y":0.9103999999999814},{"x":1.6216000000000577,"y":0.9103999999999814},{"x":1.6216000000000577,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":0.9103999999999814}]} layer="top" />
|
|
31
37
|
</footprint>}
|
|
38
|
+
symbol={<symbol>
|
|
39
|
+
<schematictext text="A_0603WAF1002T5E" x={-0.6000000000000001} y={-0.33} anchorAlignment="left" fontSize={0.18} color="#006464" rotation={0} />
|
|
40
|
+
<schematictext text="" x={-0.6000000000000001} y={0.33} anchorAlignment="left" fontSize={0.18} color="#006464" rotation={0} />
|
|
41
|
+
</symbol>}
|
|
32
42
|
{...props}
|
|
33
43
|
/>
|
|
34
44
|
)"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { test, expect } from "bun:test"
|
|
2
|
+
import type { AnyCircuitElement } from "circuit-json"
|
|
3
|
+
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
|
|
4
|
+
import { convertCircuitJsonToTscircuit } from "lib/index"
|
|
5
|
+
import { readFile } from "node:fs/promises"
|
|
6
|
+
import { join } from "node:path"
|
|
7
|
+
import { runTscircuitCode } from "tscircuit"
|
|
8
|
+
|
|
9
|
+
test("test19 board conversion", async () => {
|
|
10
|
+
const circuitJson = JSON.parse(
|
|
11
|
+
await readFile(join(__dirname, "../assets/empty-board.json"), "utf-8"),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
// A circuit json containing a pcb_board routes to the board converter
|
|
15
|
+
const tscircuitCode = convertCircuitJsonToTscircuit(circuitJson, {
|
|
16
|
+
componentName: "MyBoard",
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
expect(tscircuitCode).toMatchInlineSnapshot(`
|
|
20
|
+
"export default () => (
|
|
21
|
+
<board width="20mm" height="10mm" thickness="1.4mm" layers={2} material="fr4">
|
|
22
|
+
</board>
|
|
23
|
+
)"
|
|
24
|
+
`)
|
|
25
|
+
|
|
26
|
+
// The generated board code should render back to an equivalent board
|
|
27
|
+
const renderedCircuitJson = (await runTscircuitCode(
|
|
28
|
+
tscircuitCode,
|
|
29
|
+
)) as AnyCircuitElement[]
|
|
30
|
+
|
|
31
|
+
const pcbSvg = convertCircuitJsonToPcbSvg(renderedCircuitJson)
|
|
32
|
+
await expect(pcbSvg).toMatchSvgSnapshot(import.meta.path, "pcb")
|
|
33
|
+
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { test, expect } from "bun:test"
|
|
2
|
-
import { convertCircuitJsonToTscircuit } from "lib/index"
|
|
3
2
|
import { readFile } from "node:fs/promises"
|
|
4
3
|
import { join } from "node:path"
|
|
5
4
|
import { getComponentUsingTemplate } from "lib/get-component-using-template"
|
|
@@ -37,9 +36,17 @@ test("test2 getComponentUsingTemplate", async () => {
|
|
|
37
36
|
export const MyResistor = (props: ChipProps<typeof pinLabels>) => (
|
|
38
37
|
<chip
|
|
39
38
|
footprint={<footprint>
|
|
40
|
-
<smtpad portHints={["
|
|
41
|
-
<smtpad portHints={["
|
|
39
|
+
<smtpad portHints={["pin2"]} pcbX="0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
|
|
40
|
+
<smtpad portHints={["pin1"]} pcbX="-0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
|
|
41
|
+
<silkscreenpath route={[{"x":0.42621199999996406,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":0.6606031999999686},{"x":0.42621199999996406,"y":0.6606031999999686}]} />
|
|
42
|
+
<silkscreenpath route={[{"x":-0.42621200000007775,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":0.6606031999999686},{"x":-0.42621200000007775,"y":0.6606031999999686}]} />
|
|
43
|
+
<silkscreentext pcbX={-0.0127} pcbY={1.6604} anchorAlignment="center" fontSize={1} font="tscircuit2024" pcbRotation="0deg" layer="top" text="unnamed_chip1" />
|
|
44
|
+
<courtyardoutline outline={[{"x":-1.647000000000162,"y":0.9103999999999814},{"x":1.6216000000000577,"y":0.9103999999999814},{"x":1.6216000000000577,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":0.9103999999999814}]} layer="top" />
|
|
42
45
|
</footprint>}
|
|
46
|
+
symbol={<symbol>
|
|
47
|
+
<schematictext text="A_0603WAF1002T5E" x={-0.6000000000000001} y={-0.33} anchorAlignment="left" fontSize={0.18} color="#006464" rotation={0} />
|
|
48
|
+
<schematictext text="" x={-0.6000000000000001} y={0.33} anchorAlignment="left" fontSize={0.18} color="#006464" rotation={0} />
|
|
49
|
+
</symbol>}
|
|
43
50
|
pinLabels={pinLabels}
|
|
44
51
|
cadModel={{
|
|
45
52
|
objUrl: "...",
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import type { AnyCircuitElement, PcbSmtPad } from "circuit-json"
|
|
3
|
+
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
|
|
4
|
+
import { convertCircuitJsonToTscircuit } from "lib/index"
|
|
5
|
+
import { runTscircuitCode } from "tscircuit"
|
|
6
|
+
|
|
7
|
+
const sourceTscircuit = `
|
|
8
|
+
const BoardChildChip = (props) => (
|
|
9
|
+
<chip
|
|
10
|
+
footprint={<footprint>
|
|
11
|
+
<smtpad
|
|
12
|
+
portHints={["1"]}
|
|
13
|
+
pcbX="-1mm"
|
|
14
|
+
pcbY="0mm"
|
|
15
|
+
width="1mm"
|
|
16
|
+
height="0.8mm"
|
|
17
|
+
shape="rect"
|
|
18
|
+
layer="top"
|
|
19
|
+
/>
|
|
20
|
+
<smtpad
|
|
21
|
+
portHints={["2"]}
|
|
22
|
+
pcbX="1mm"
|
|
23
|
+
pcbY="0mm"
|
|
24
|
+
width="1mm"
|
|
25
|
+
height="0.8mm"
|
|
26
|
+
shape="rect"
|
|
27
|
+
layer="top"
|
|
28
|
+
/>
|
|
29
|
+
</footprint>}
|
|
30
|
+
{...props}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
export default () => (
|
|
35
|
+
<board width="12mm" height="8mm">
|
|
36
|
+
<BoardChildChip name="U1" />
|
|
37
|
+
</board>
|
|
38
|
+
)
|
|
39
|
+
`
|
|
40
|
+
|
|
41
|
+
test.failing(
|
|
42
|
+
"test20 board conversion drops child component geometry",
|
|
43
|
+
async () => {
|
|
44
|
+
const sourceCircuitJson = (await runTscircuitCode(
|
|
45
|
+
sourceTscircuit,
|
|
46
|
+
)) as AnyCircuitElement[]
|
|
47
|
+
|
|
48
|
+
const sourcePads = sourceCircuitJson.filter(
|
|
49
|
+
(elm): elm is PcbSmtPad => elm.type === "pcb_smtpad",
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
expect(sourcePads).toHaveLength(2)
|
|
53
|
+
|
|
54
|
+
const convertedTscircuit = convertCircuitJsonToTscircuit(
|
|
55
|
+
sourceCircuitJson,
|
|
56
|
+
{
|
|
57
|
+
componentName: "ConvertedBoard",
|
|
58
|
+
},
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
expect(convertedTscircuit).toMatchInlineSnapshot(`
|
|
62
|
+
"export default () => (
|
|
63
|
+
<board width="12mm" height="8mm" thickness="1.4mm" layers={2} material="fr4">
|
|
64
|
+
</board>
|
|
65
|
+
)"
|
|
66
|
+
`)
|
|
67
|
+
|
|
68
|
+
const convertedCircuitJson = (await runTscircuitCode(
|
|
69
|
+
convertedTscircuit,
|
|
70
|
+
)) as AnyCircuitElement[]
|
|
71
|
+
|
|
72
|
+
const convertedPads = convertedCircuitJson.filter(
|
|
73
|
+
(elm): elm is PcbSmtPad => elm.type === "pcb_smtpad",
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
const pcbSvg = convertCircuitJsonToPcbSvg(convertedCircuitJson)
|
|
77
|
+
await expect(pcbSvg).toMatchSvgSnapshot(import.meta.path, "pcb")
|
|
78
|
+
|
|
79
|
+
expect(convertedPads).toHaveLength(2)
|
|
80
|
+
},
|
|
81
|
+
)
|