circuit-json-to-tscircuit 0.0.38 → 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/dist/cli/main.js
CHANGED
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.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>
|
|
@@ -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
|
+
)
|