circuit-json-to-lbrn 0.0.40 → 0.0.41
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.d.ts +1 -0
- package/dist/index.js +143 -23
- package/lib/ConvertContext.ts +3 -0
- package/lib/element-handlers/addPcbVia/index.ts +11 -2
- package/lib/element-handlers/addPlatedHole/addCirclePlatedHole.ts +9 -3
- package/lib/element-handlers/addPlatedHole/addCircularHoleWithRectPad.ts +20 -8
- package/lib/element-handlers/addPlatedHole/addOvalPlatedHole.ts +20 -4
- package/lib/element-handlers/addPlatedHole/addPillHoleWithRectPad.ts +19 -8
- package/lib/element-handlers/addPlatedHole/addPillPlatedHole.ts +21 -8
- package/lib/element-handlers/addPlatedHole/addRotatedPillHoleWithRectPad.ts +19 -8
- package/lib/element-handlers/addSmtPad/addCircleSmtPad.ts +20 -3
- package/lib/element-handlers/addSmtPad/addPillSmtPad.ts +19 -8
- package/lib/element-handlers/addSmtPad/addPolygonSmtPad.ts +1 -0
- package/lib/element-handlers/addSmtPad/addRectSmtPad.ts +17 -6
- package/lib/element-handlers/addSmtPad/addRotatedPillSmtPad.ts +19 -8
- package/lib/element-handlers/addSmtPad/addRotatedRectSmtPad.ts +19 -8
- package/lib/index.ts +3 -0
- package/package.json +1 -1
- package/tests/basics/soldermask-margin/__snapshots__/negative-soldermask-margin.snap.svg +1 -1
- package/tests/basics/soldermask-margin/__snapshots__/percent-soldermask-margin.snap.svg +8 -0
- package/tests/basics/soldermask-margin/percent-soldermask-margin.test.ts +90 -0
|
@@ -0,0 +1,90 @@
|
|
|
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: "pcb_board",
|
|
11
|
+
pcb_board_id: "board",
|
|
12
|
+
width: 200,
|
|
13
|
+
height: 200,
|
|
14
|
+
center: { x: 0, y: 0 },
|
|
15
|
+
thickness: 6,
|
|
16
|
+
num_layers: 2,
|
|
17
|
+
material: "fr4",
|
|
18
|
+
},
|
|
19
|
+
// Rect pad: 24mm x 12mm @ -10% → 21.6 x 10.8
|
|
20
|
+
{
|
|
21
|
+
type: "pcb_smtpad",
|
|
22
|
+
x: -70,
|
|
23
|
+
y: 50,
|
|
24
|
+
layer: "top",
|
|
25
|
+
shape: "rect",
|
|
26
|
+
pcb_smtpad_id: "rect_pad_narrow",
|
|
27
|
+
width: 24,
|
|
28
|
+
height: 12,
|
|
29
|
+
},
|
|
30
|
+
// Square rect pad: 30mm x 30mm @ -10% → 27 x 27
|
|
31
|
+
{
|
|
32
|
+
type: "pcb_smtpad",
|
|
33
|
+
x: -30,
|
|
34
|
+
y: 50,
|
|
35
|
+
layer: "top",
|
|
36
|
+
shape: "rect",
|
|
37
|
+
pcb_smtpad_id: "rect_pad_square",
|
|
38
|
+
width: 30,
|
|
39
|
+
height: 30,
|
|
40
|
+
},
|
|
41
|
+
// Pill pad: 36mm x 18mm @ -10% → 32.4 x 16.2
|
|
42
|
+
{
|
|
43
|
+
type: "pcb_smtpad",
|
|
44
|
+
x: 10,
|
|
45
|
+
y: 50,
|
|
46
|
+
layer: "top",
|
|
47
|
+
shape: "pill",
|
|
48
|
+
pcb_smtpad_id: "pill_pad",
|
|
49
|
+
width: 36,
|
|
50
|
+
height: 18,
|
|
51
|
+
radius: 9,
|
|
52
|
+
},
|
|
53
|
+
// Circle pad: radius 15mm → diameter 30mm @ -10% → 27mm
|
|
54
|
+
{
|
|
55
|
+
type: "pcb_smtpad",
|
|
56
|
+
x: 50,
|
|
57
|
+
y: 50,
|
|
58
|
+
layer: "top",
|
|
59
|
+
shape: "circle",
|
|
60
|
+
pcb_smtpad_id: "circle_pad",
|
|
61
|
+
radius: 15,
|
|
62
|
+
},
|
|
63
|
+
// Via: outer_diameter 30mm @ -10% → 27mm
|
|
64
|
+
{
|
|
65
|
+
type: "pcb_via",
|
|
66
|
+
pcb_via_id: "via",
|
|
67
|
+
x: -50,
|
|
68
|
+
y: -30,
|
|
69
|
+
outer_diameter: 30,
|
|
70
|
+
hole_diameter: 15,
|
|
71
|
+
layers: ["top", "bottom"],
|
|
72
|
+
},
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
test("soldermask renders with correct percent margin", async () => {
|
|
76
|
+
const pcbSvg = await convertCircuitJsonToPcbSvg(circuitJson)
|
|
77
|
+
|
|
78
|
+
const project = convertCircuitJsonToLbrn(circuitJson, {
|
|
79
|
+
includeSoldermask: true,
|
|
80
|
+
includeCopper: true,
|
|
81
|
+
solderMaskMarginPercent: -20, // negative shrink
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const lbrnSvg = await generateLightBurnSvg(project)
|
|
85
|
+
|
|
86
|
+
// Compare stacked SVGs visually to ensure soldermask scaling matches percent margin
|
|
87
|
+
expect(stackSvgsVertically([pcbSvg, lbrnSvg])).toMatchSvgSnapshot(
|
|
88
|
+
import.meta.filename,
|
|
89
|
+
)
|
|
90
|
+
})
|