circuit-json-to-lbrn 0.0.29 → 0.0.31

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.
Files changed (41) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +50 -66
  3. package/lib/ConvertContext.ts +2 -2
  4. package/lib/element-handlers/addPcbCutout/addCirclePcbCutout.ts +1 -3
  5. package/lib/element-handlers/addPcbCutout/addPathPcbCutout.ts +0 -1
  6. package/lib/element-handlers/addPcbCutout/addPolygonPcbCutout.ts +1 -17
  7. package/lib/element-handlers/addPcbCutout/addRectPcbCutout.ts +2 -5
  8. package/lib/element-handlers/addPcbHole/addCirclePcbHole.ts +1 -3
  9. package/lib/element-handlers/addPcbHole/addOvalPcbHole.ts +2 -3
  10. package/lib/element-handlers/addPcbHole/addPillPcbHole.ts +2 -3
  11. package/lib/element-handlers/addPcbHole/addRectPcbHole.ts +2 -3
  12. package/lib/element-handlers/addPcbHole/addRotatedPillPcbHole.ts +2 -3
  13. package/lib/element-handlers/addPcbVia/index.ts +3 -2
  14. package/lib/element-handlers/addPlatedHole/addCirclePlatedHole.ts +5 -2
  15. package/lib/element-handlers/addPlatedHole/addCircularHoleWithRectPad.ts +9 -3
  16. package/lib/element-handlers/addPlatedHole/addHoleWithPolygonPad.ts +1 -1
  17. package/lib/element-handlers/addPlatedHole/addOvalPlatedHole.ts +4 -1
  18. package/lib/element-handlers/addPlatedHole/addPillHoleWithRectPad.ts +9 -3
  19. package/lib/element-handlers/addPlatedHole/addPillPlatedHole.ts +9 -3
  20. package/lib/element-handlers/addPlatedHole/addRotatedPillHoleWithRectPad.ts +9 -3
  21. package/lib/element-handlers/addSmtPad/addCircleSmtPad.ts +5 -2
  22. package/lib/element-handlers/addSmtPad/addPillSmtPad.ts +9 -3
  23. package/lib/element-handlers/addSmtPad/addPolygonSmtPad.ts +1 -1
  24. package/lib/element-handlers/addSmtPad/addRectSmtPad.ts +9 -3
  25. package/lib/element-handlers/addSmtPad/addRotatedPillSmtPad.ts +9 -3
  26. package/lib/element-handlers/addSmtPad/addRotatedRectSmtPad.ts +9 -3
  27. package/lib/index.ts +4 -3
  28. package/package.json +1 -1
  29. package/site/index.html +1 -1
  30. package/site/main.tsx +4 -3
  31. package/tests/basics/__snapshots__/mixed-soldermask-margins.snap.svg +8 -0
  32. package/tests/basics/addPcbCutout/__snapshots__/pcb-cutout-circle.snap.svg +1 -1
  33. package/tests/basics/addPcbCutout/pcb-cutout-circle.test.ts +1 -1
  34. package/tests/basics/addPcbHole/__snapshots__/pcb-hole-soldermask-margin.snap.svg +8 -0
  35. package/tests/basics/addPcbHole/__snapshots__/pcb-hole-with-soldermask.snap.svg +1 -1
  36. package/tests/basics/addPcbHole/pcb-hole-soldermask-margin.test.ts +63 -0
  37. package/tests/basics/addPcbHole/pcb-hole-with-soldermask.test.ts +1 -1
  38. package/tests/basics/addPcbVia/pcb-via-with-soldermask.test.ts +1 -1
  39. package/tests/basics/mixed-soldermask-margins.test.ts +111 -0
  40. package/tests/basics/soldermask-margin/negative-soldermask-margin.test.ts +1 -1
  41. package/tests/basics/soldermask-margin/positive-soldermask-margin.test.ts +1 -1
@@ -17,7 +17,7 @@ export const addCircularHoleWithRectPad = (
17
17
  origin,
18
18
  includeCopper,
19
19
  includeSoldermask,
20
- soldermaskMargin,
20
+ globalCopperSoldermaskMarginAdjustment,
21
21
  includeLayers,
22
22
  } = ctx
23
23
  const centerX = platedHole.x + origin.x
@@ -63,8 +63,14 @@ export const addCircularHoleWithRectPad = (
63
63
 
64
64
  // Add soldermask opening if drawing soldermask
65
65
  if (includeSoldermask) {
66
- const smPadWidth = padWidth + 2 * soldermaskMargin
67
- const smPadHeight = padHeight + 2 * soldermaskMargin
66
+ const smPadWidth =
67
+ padWidth +
68
+ 2 * globalCopperSoldermaskMarginAdjustment +
69
+ (platedHole.soldermask_margin ?? 0)
70
+ const smPadHeight =
71
+ padHeight +
72
+ 2 * globalCopperSoldermaskMarginAdjustment +
73
+ (platedHole.soldermask_margin ?? 0)
68
74
  const smPadPath = createRoundedRectPath({
69
75
  centerX,
70
76
  centerY,
@@ -17,7 +17,7 @@ export const addHoleWithPolygonPad = (
17
17
  origin,
18
18
  includeCopper,
19
19
  includeSoldermask,
20
- soldermaskMargin,
20
+ globalCopperSoldermaskMarginAdjustment,
21
21
  includeLayers,
22
22
  } = ctx
23
23
 
@@ -16,7 +16,7 @@ export const addOvalPlatedHole = (
16
16
  origin,
17
17
  includeCopper,
18
18
  includeSoldermask,
19
- soldermaskMargin,
19
+ globalCopperSoldermaskMarginAdjustment,
20
20
  includeLayers,
21
21
  } = ctx
22
22
 
@@ -70,6 +70,9 @@ export const addOvalPlatedHole = (
70
70
  platedHole.outer_height > 0 &&
71
71
  includeSoldermask
72
72
  ) {
73
+ const soldermaskMargin =
74
+ globalCopperSoldermaskMarginAdjustment +
75
+ (platedHole.soldermask_margin ?? 0)
73
76
  const smWidth = platedHole.outer_width + 2 * soldermaskMargin
74
77
  const smHeight = platedHole.outer_height + 2 * soldermaskMargin
75
78
  const outer = createOvalPath({
@@ -17,7 +17,7 @@ export const addPillHoleWithRectPad = (
17
17
  origin,
18
18
  includeCopper,
19
19
  includeSoldermask,
20
- soldermaskMargin,
20
+ globalCopperSoldermaskMarginAdjustment,
21
21
  includeLayers,
22
22
  } = ctx
23
23
  const centerX = platedHole.x + origin.x
@@ -63,8 +63,14 @@ export const addPillHoleWithRectPad = (
63
63
 
64
64
  // Add soldermask opening if drawing soldermask
65
65
  if (includeSoldermask) {
66
- const smPadWidth = padWidth + 2 * soldermaskMargin
67
- const smPadHeight = padHeight + 2 * soldermaskMargin
66
+ const smPadWidth =
67
+ padWidth +
68
+ 2 * globalCopperSoldermaskMarginAdjustment +
69
+ (platedHole.soldermask_margin ?? 0)
70
+ const smPadHeight =
71
+ padHeight +
72
+ 2 * globalCopperSoldermaskMarginAdjustment +
73
+ (platedHole.soldermask_margin ?? 0)
68
74
  const smPadPath = createRoundedRectPath({
69
75
  centerX,
70
76
  centerY,
@@ -16,7 +16,7 @@ export const addPcbPlatedHolePill = (
16
16
  origin,
17
17
  includeCopper,
18
18
  includeSoldermask,
19
- soldermaskMargin,
19
+ globalCopperSoldermaskMarginAdjustment,
20
20
  includeLayers,
21
21
  } = ctx
22
22
  const centerX = platedHole.x + origin.x
@@ -65,8 +65,14 @@ export const addPcbPlatedHolePill = (
65
65
  platedHole.outer_height > 0 &&
66
66
  includeSoldermask
67
67
  ) {
68
- const smWidth = platedHole.outer_width + 2 * soldermaskMargin
69
- const smHeight = platedHole.outer_height + 2 * soldermaskMargin
68
+ const smWidth =
69
+ platedHole.outer_width +
70
+ 2 * globalCopperSoldermaskMarginAdjustment +
71
+ (platedHole.soldermask_margin ?? 0)
72
+ const smHeight =
73
+ platedHole.outer_height +
74
+ 2 * globalCopperSoldermaskMarginAdjustment +
75
+ (platedHole.soldermask_margin ?? 0)
70
76
  const outer = createPillPath({
71
77
  centerX,
72
78
  centerY,
@@ -17,7 +17,7 @@ export const addRotatedPillHoleWithRectPad = (
17
17
  origin,
18
18
  includeCopper,
19
19
  includeSoldermask,
20
- soldermaskMargin,
20
+ globalCopperSoldermaskMarginAdjustment,
21
21
  includeLayers,
22
22
  } = ctx
23
23
  const centerX = platedHole.x + origin.x
@@ -66,8 +66,14 @@ export const addRotatedPillHoleWithRectPad = (
66
66
 
67
67
  // Add soldermask opening if drawing soldermask
68
68
  if (includeSoldermask) {
69
- const smPadWidth = padWidth + 2 * soldermaskMargin
70
- const smPadHeight = padHeight + 2 * soldermaskMargin
69
+ const smPadWidth =
70
+ padWidth +
71
+ 2 * globalCopperSoldermaskMarginAdjustment +
72
+ (platedHole.soldermask_margin ?? 0)
73
+ const smPadHeight =
74
+ padHeight +
75
+ 2 * globalCopperSoldermaskMarginAdjustment +
76
+ (platedHole.soldermask_margin ?? 0)
71
77
  const smPadPath = createRoundedRectPath({
72
78
  centerX,
73
79
  centerY,
@@ -20,7 +20,7 @@ export const addCircleSmtPad = (
20
20
  includeCopper,
21
21
  includeSoldermask,
22
22
  connMap,
23
- soldermaskMargin,
23
+ globalCopperSoldermaskMarginAdjustment,
24
24
  includeLayers,
25
25
  } = ctx
26
26
 
@@ -73,7 +73,10 @@ export const addCircleSmtPad = (
73
73
 
74
74
  // Add soldermask opening if drawing soldermask
75
75
  if (includeSoldermask) {
76
- const smRadius = outerRadius + soldermaskMargin
76
+ const smRadius =
77
+ outerRadius +
78
+ globalCopperSoldermaskMarginAdjustment +
79
+ (smtPad.soldermask_margin ?? 0)
77
80
  const outer = createCirclePath({
78
81
  centerX,
79
82
  centerY,
@@ -19,7 +19,7 @@ export const addPillSmtPad = (
19
19
  includeCopper,
20
20
  includeSoldermask,
21
21
  connMap,
22
- soldermaskMargin,
22
+ globalCopperSoldermaskMarginAdjustment,
23
23
  includeLayers,
24
24
  } = ctx
25
25
 
@@ -71,8 +71,14 @@ export const addPillSmtPad = (
71
71
 
72
72
  // Add soldermask opening if drawing soldermask
73
73
  if (includeSoldermask) {
74
- const smWidth = smtPad.width + 2 * soldermaskMargin
75
- const smHeight = smtPad.height + 2 * soldermaskMargin
74
+ const smWidth =
75
+ smtPad.width +
76
+ 2 * globalCopperSoldermaskMarginAdjustment +
77
+ (smtPad.soldermask_margin ?? 0)
78
+ const smHeight =
79
+ smtPad.height +
80
+ 2 * globalCopperSoldermaskMarginAdjustment +
81
+ (smtPad.soldermask_margin ?? 0)
76
82
  const smOuter = createPillPath({
77
83
  centerX,
78
84
  centerY,
@@ -20,7 +20,7 @@ export const addPolygonSmtPad = (
20
20
  includeCopper,
21
21
  includeSoldermask,
22
22
  connMap,
23
- soldermaskMargin,
23
+ globalCopperSoldermaskMarginAdjustment,
24
24
  includeLayers,
25
25
  } = ctx
26
26
 
@@ -15,7 +15,7 @@ export const addRectSmtPad = (smtPad: PcbSmtPadRect, ctx: ConvertContext) => {
15
15
  origin,
16
16
  includeCopper,
17
17
  includeSoldermask,
18
- soldermaskMargin,
18
+ globalCopperSoldermaskMarginAdjustment,
19
19
  includeLayers,
20
20
  } = ctx
21
21
 
@@ -85,8 +85,14 @@ export const addRectSmtPad = (smtPad: PcbSmtPadRect, ctx: ConvertContext) => {
85
85
 
86
86
  // Add soldermask opening if drawing soldermask
87
87
  if (includeSoldermask) {
88
- const smHalfWidth = halfWidth + soldermaskMargin
89
- const smHalfHeight = halfHeight + soldermaskMargin
88
+ const smHalfWidth =
89
+ halfWidth +
90
+ globalCopperSoldermaskMarginAdjustment +
91
+ (smtPad.soldermask_margin ?? 0)
92
+ const smHalfHeight =
93
+ halfHeight +
94
+ globalCopperSoldermaskMarginAdjustment +
95
+ (smtPad.soldermask_margin ?? 0)
90
96
 
91
97
  const verts = [
92
98
  { x: centerX - smHalfWidth, y: centerY - smHalfHeight },
@@ -19,7 +19,7 @@ export const addRotatedPillSmtPad = (
19
19
  includeCopper,
20
20
  includeSoldermask,
21
21
  connMap,
22
- soldermaskMargin,
22
+ globalCopperSoldermaskMarginAdjustment,
23
23
  includeLayers,
24
24
  } = ctx
25
25
 
@@ -72,8 +72,14 @@ export const addRotatedPillSmtPad = (
72
72
 
73
73
  // Add soldermask opening if drawing soldermask
74
74
  if (includeSoldermask) {
75
- const smWidth = smtPad.width + 2 * soldermaskMargin
76
- const smHeight = smtPad.height + 2 * soldermaskMargin
75
+ const smWidth =
76
+ smtPad.width +
77
+ 2 * globalCopperSoldermaskMarginAdjustment +
78
+ (smtPad.soldermask_margin ?? 0)
79
+ const smHeight =
80
+ smtPad.height +
81
+ 2 * globalCopperSoldermaskMarginAdjustment +
82
+ (smtPad.soldermask_margin ?? 0)
77
83
  const smOuter = createPillPath({
78
84
  centerX,
79
85
  centerY,
@@ -19,7 +19,7 @@ export const addRotatedRectSmtPad = (
19
19
  includeCopper,
20
20
  includeSoldermask,
21
21
  connMap,
22
- soldermaskMargin,
22
+ globalCopperSoldermaskMarginAdjustment,
23
23
  includeLayers,
24
24
  } = ctx
25
25
 
@@ -76,8 +76,14 @@ export const addRotatedRectSmtPad = (
76
76
 
77
77
  // Add soldermask opening if drawing soldermask
78
78
  if (includeSoldermask) {
79
- const smWidth = smtPad.width + 2 * soldermaskMargin
80
- const smHeight = smtPad.height + 2 * soldermaskMargin
79
+ const smWidth =
80
+ smtPad.width +
81
+ 2 * globalCopperSoldermaskMarginAdjustment +
82
+ (smtPad.soldermask_margin ?? 0)
83
+ const smHeight =
84
+ smtPad.height +
85
+ 2 * globalCopperSoldermaskMarginAdjustment +
86
+ (smtPad.soldermask_margin ?? 0)
81
87
  const smOuter = createRoundedRectPath({
82
88
  centerX,
83
89
  centerY,
package/lib/index.ts CHANGED
@@ -25,7 +25,7 @@ export const convertCircuitJsonToLbrn = (
25
25
  margin?: number
26
26
  includeCopper?: boolean
27
27
  includeSoldermask?: boolean
28
- soldermaskMargin?: number
28
+ globalCopperSoldermaskMarginAdjustment?: number
29
29
  includeLayers?: Array<"top" | "bottom">
30
30
  traceMargin?: number
31
31
  laserSpotSize?: number
@@ -57,7 +57,8 @@ export const convertCircuitJsonToLbrn = (
57
57
  const laserSpotSize = options.laserSpotSize ?? 0.005
58
58
  const includeCopper = options.includeCopper ?? true
59
59
  const includeSoldermask = options.includeSoldermask ?? false
60
- const soldermaskMargin = options.soldermaskMargin ?? 0
60
+ const globalCopperSoldermaskMarginAdjustment =
61
+ options.globalCopperSoldermaskMarginAdjustment ?? 0
61
62
  const laserProfile = options.laserProfile
62
63
 
63
64
  // Default laser settings from GitHub issue
@@ -190,7 +191,7 @@ export const convertCircuitJsonToLbrn = (
190
191
  origin,
191
192
  includeCopper,
192
193
  includeSoldermask,
193
- soldermaskMargin,
194
+ globalCopperSoldermaskMarginAdjustment,
194
195
  includeLayers,
195
196
  traceMargin,
196
197
  laserSpotSize,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "circuit-json-to-lbrn",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.29",
4
+ "version": "0.0.31",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "bun run site/index.html",
package/site/index.html CHANGED
@@ -104,7 +104,7 @@
104
104
  </label>
105
105
  <input
106
106
  type="number"
107
- id="soldermaskMargin"
107
+ id="globalCopperSoldermaskMarginAdjustment"
108
108
  value="0"
109
109
  step="0.001"
110
110
  class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
package/site/main.tsx CHANGED
@@ -36,8 +36,8 @@ const originYInput = document.getElementById("originY") as HTMLInputElement
36
36
  const traceMarginInput = document.getElementById(
37
37
  "traceMargin",
38
38
  ) as HTMLInputElement
39
- const soldermaskMarginInput = document.getElementById(
40
- "soldermaskMargin",
39
+ const globalCopperSoldermaskMarginAdjustmentInput = document.getElementById(
40
+ "globalCopperSoldermaskMarginAdjustment",
41
41
  ) as HTMLInputElement
42
42
  const laserSpotSizeInput = document.getElementById(
43
43
  "laserSpotSize",
@@ -162,7 +162,8 @@ function getConversionOptions() {
162
162
  },
163
163
  includeCopper: includeCopperInput.checked,
164
164
  includeSoldermask: includeSoldermaskInput.checked,
165
- soldermaskMargin: parseFloat(soldermaskMarginInput.value) || 0,
165
+ globalCopperSoldermaskMarginAdjustment:
166
+ parseFloat(globalCopperSoldermaskMarginAdjustmentInput.value) || 0,
166
167
  includeLayers: [
167
168
  ...(includeTopLayerInput.checked ? ["top" as const] : []),
168
169
  ...(includeBottomLayerInput.checked ? ["bottom" as const] : []),