circuit-json-to-lbrn 0.0.6 → 0.0.8
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 +636 -16
- package/lib/ConvertContext.ts +1 -0
- package/lib/element-handlers/addPcbBoard/index.ts +50 -0
- package/lib/element-handlers/addPlatedHole/addCirclePlatedHole.ts +30 -72
- package/lib/element-handlers/addPlatedHole/addCircularHoleWithRectPad.ts +44 -3
- package/lib/element-handlers/addPlatedHole/addHoleWithPolygonPad.ts +55 -4
- package/lib/element-handlers/addPlatedHole/addOvalPlatedHole.ts +49 -4
- package/lib/element-handlers/addPlatedHole/addPillHoleWithRectPad.ts +52 -4
- package/lib/element-handlers/addPlatedHole/addPillPlatedHole.ts +52 -0
- package/lib/element-handlers/addPlatedHole/addRotatedPillHoleWithRectPad.ts +57 -4
- package/lib/element-handlers/addPlatedHole/index.ts +4 -1
- package/lib/helpers/circleShape.ts +42 -0
- package/lib/helpers/ovalShape.ts +51 -0
- package/lib/helpers/pathPointUtils.ts +45 -0
- package/lib/helpers/pillShape.ts +99 -0
- package/lib/helpers/polygonShape.ts +38 -0
- package/lib/helpers/roundedRectShape.ts +121 -0
- package/lib/index.ts +17 -3
- package/package.json +1 -1
- package/tests/examples/__snapshots__/board-outline.snap.svg +8 -0
- package/tests/examples/__snapshots__/lga-interconnect.snap.svg +2 -2
- package/tests/examples/__snapshots__/single-trace.snap.svg +2 -2
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-circle.snap.svg +8 -0
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-circular-hole-with-rect-pad.snap.svg +8 -0
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-oval.snap.svg +8 -0
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-pill-with-rect-pad.snap.svg +8 -0
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-pill.snap.svg +8 -0
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-polygon.snap.svg +8 -0
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-rotated-pill-with-rect-pad.snap.svg +8 -0
- package/tests/examples/addPlatedHole/pcb-plated-hole-circle.test.ts +62 -0
- package/tests/examples/addPlatedHole/pcb-plated-hole-circular-hole-with-rect-pad.test.ts +54 -0
- package/tests/examples/addPlatedHole/pcb-plated-hole-oval.test.ts +101 -0
- package/tests/examples/addPlatedHole/pcb-plated-hole-pill-with-rect-pad.test.ts +54 -0
- package/tests/examples/addPlatedHole/pcb-plated-hole-pill.test.ts +101 -0
- package/tests/examples/addPlatedHole/pcb-plated-hole-polygon.test.ts +59 -0
- package/tests/examples/addPlatedHole/pcb-plated-hole-rotated-pill-with-rect-pad.test.ts +56 -0
- package/tests/examples/board-outline.test.ts +102 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { test, expect } from "bun:test"
|
|
2
|
+
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
|
|
3
|
+
import { generateLightBurnSvg } from "lbrnts"
|
|
4
|
+
import { convertCircuitJsonToLbrn } from "../../lib"
|
|
5
|
+
import { stackSvgsVertically } from "stack-svgs"
|
|
6
|
+
import type { CircuitJson } from "circuit-json"
|
|
7
|
+
|
|
8
|
+
const circuitJson: CircuitJson = [
|
|
9
|
+
{
|
|
10
|
+
type: "source_port",
|
|
11
|
+
name: "port1",
|
|
12
|
+
source_port_id: "sp1",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: "source_port",
|
|
16
|
+
name: "port2",
|
|
17
|
+
source_port_id: "sp2",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: "source_trace",
|
|
21
|
+
source_trace_id: "st1",
|
|
22
|
+
connected_source_port_ids: ["sp1", "sp2"],
|
|
23
|
+
connected_source_net_ids: [],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "pcb_board",
|
|
27
|
+
pcb_board_id: "board1",
|
|
28
|
+
center: { x: 5, y: 5 },
|
|
29
|
+
thickness: 1.6,
|
|
30
|
+
num_layers: 2,
|
|
31
|
+
material: "fr4",
|
|
32
|
+
outline: [
|
|
33
|
+
{ x: 0, y: 0 },
|
|
34
|
+
{ x: 40, y: 0 },
|
|
35
|
+
{ x: 40, y: 15 },
|
|
36
|
+
{ x: 5, y: 15 },
|
|
37
|
+
{ x: 0, y: 10 },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "pcb_port",
|
|
42
|
+
pcb_port_id: "pp1",
|
|
43
|
+
source_port_id: "sp1",
|
|
44
|
+
x: 10,
|
|
45
|
+
y: 5,
|
|
46
|
+
layers: ["top"],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: "pcb_port",
|
|
50
|
+
pcb_port_id: "pp2",
|
|
51
|
+
source_port_id: "sp2",
|
|
52
|
+
x: 30,
|
|
53
|
+
y: 5,
|
|
54
|
+
layers: ["top"],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "pcb_smtpad",
|
|
58
|
+
pcb_smtpad_id: "pad1",
|
|
59
|
+
pcb_port_id: "pp1",
|
|
60
|
+
shape: "rect",
|
|
61
|
+
x: 10,
|
|
62
|
+
y: 5,
|
|
63
|
+
width: 2,
|
|
64
|
+
height: 3,
|
|
65
|
+
layer: "top",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: "pcb_trace",
|
|
69
|
+
pcb_trace_id: "trace1",
|
|
70
|
+
source_trace_id: "st1",
|
|
71
|
+
route: [
|
|
72
|
+
{
|
|
73
|
+
x: 10,
|
|
74
|
+
y: 5,
|
|
75
|
+
width: 0.5,
|
|
76
|
+
layer: "top",
|
|
77
|
+
route_type: "wire",
|
|
78
|
+
start_pcb_port_id: "pp1",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
x: 30,
|
|
82
|
+
y: 5,
|
|
83
|
+
width: 0.5,
|
|
84
|
+
layer: "top",
|
|
85
|
+
route_type: "wire",
|
|
86
|
+
end_pcb_port_id: "pp2",
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
test("creates board outline cut with through-board setting", async () => {
|
|
93
|
+
const pcbSvg = await convertCircuitJsonToPcbSvg(circuitJson)
|
|
94
|
+
|
|
95
|
+
const project = convertCircuitJsonToLbrn(circuitJson)
|
|
96
|
+
|
|
97
|
+
const lbrnSvg = await generateLightBurnSvg(project)
|
|
98
|
+
|
|
99
|
+
expect(stackSvgsVertically([pcbSvg, lbrnSvg])).toMatchSvgSnapshot(
|
|
100
|
+
import.meta.filename,
|
|
101
|
+
)
|
|
102
|
+
})
|