circuit-json-to-gerber 0.0.63 → 0.0.66

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.
@@ -1417,6 +1417,29 @@ var getApertureConfigFromPcbSmtpad = (elm) => {
1417
1417
  y_size: elm.height
1418
1418
  };
1419
1419
  }
1420
+ if (elm.shape === "pill") {
1421
+ if (!("width" in elm && "height" in elm)) {
1422
+ throw new Error(
1423
+ "Invalid pill shape in getApertureConfigFromPcbSmtpad: missing dimensions"
1424
+ );
1425
+ }
1426
+ if (elm.width >= elm.height) {
1427
+ return {
1428
+ macro_name: "HORZPILL",
1429
+ x_size: elm.width,
1430
+ y_size: elm.height,
1431
+ circle_diameter: Math.min(elm.width, elm.height),
1432
+ circle_center_offset: elm.width / 2
1433
+ };
1434
+ }
1435
+ return {
1436
+ macro_name: "VERTPILL",
1437
+ x_size: elm.width,
1438
+ y_size: elm.height,
1439
+ circle_diameter: Math.min(elm.width, elm.height),
1440
+ circle_center_offset: elm.height / 2
1441
+ };
1442
+ }
1420
1443
  if (elm.shape === "polygon") {
1421
1444
  throw new Error("Polygon SMT pads are drawn as regions, not apertures");
1422
1445
  }
@@ -1447,6 +1470,31 @@ var getApertureConfigFromPcbSmtpadSoldermask = (elm) => {
1447
1470
  y_size: elm.height + soldermaskMargin * 2
1448
1471
  };
1449
1472
  }
1473
+ if (elm.shape === "pill") {
1474
+ if (!("width" in elm && "height" in elm)) {
1475
+ throw new Error(
1476
+ "Invalid pill shape in getApertureConfigFromPcbSmtpadSoldermask: missing dimensions"
1477
+ );
1478
+ }
1479
+ const width = elm.width + soldermaskMargin * 2;
1480
+ const height = elm.height + soldermaskMargin * 2;
1481
+ if (width >= height) {
1482
+ return {
1483
+ macro_name: "HORZPILL",
1484
+ x_size: width,
1485
+ y_size: height,
1486
+ circle_diameter: Math.min(width, height),
1487
+ circle_center_offset: width / 2
1488
+ };
1489
+ }
1490
+ return {
1491
+ macro_name: "VERTPILL",
1492
+ x_size: width,
1493
+ y_size: height,
1494
+ circle_diameter: Math.min(width, height),
1495
+ circle_center_offset: height / 2
1496
+ };
1497
+ }
1450
1498
  if (elm.shape === "polygon") {
1451
1499
  throw new Error("Polygon SMT pads are drawn as regions, not apertures");
1452
1500
  }
@@ -1579,6 +1627,64 @@ var getApertureConfigFromPcbPlatedHole = (elm) => {
1579
1627
  `Unsupported shape in getApertureConfigFromPcbPlatedHole: ${elm.shape}`
1580
1628
  );
1581
1629
  };
1630
+ var getApertureConfigFromPcbPlatedHoleSoldermask = (elm) => {
1631
+ let soldermaskMargin = 0;
1632
+ if ("soldermask_margin" in elm && typeof elm.soldermask_margin === "number") {
1633
+ soldermaskMargin = elm.soldermask_margin;
1634
+ }
1635
+ if (elm.shape === "circle") {
1636
+ if (!("outer_diameter" in elm && "hole_diameter" in elm)) {
1637
+ throw new Error(
1638
+ "Invalid circle shape in getApertureConfigFromPcbPlatedHoleSoldermask: missing diameters"
1639
+ );
1640
+ }
1641
+ return {
1642
+ standard_template_code: "C",
1643
+ diameter: elm.outer_diameter + soldermaskMargin * 2
1644
+ };
1645
+ }
1646
+ if (elm.shape === "pill") {
1647
+ if (!("outer_width" in elm && "outer_height" in elm)) {
1648
+ throw new Error(
1649
+ "Invalid pill shape in getApertureConfigFromPcbPlatedHoleSoldermask: missing dimensions"
1650
+ );
1651
+ }
1652
+ const outerWidth = elm.outer_width + soldermaskMargin * 2;
1653
+ const outerHeight = elm.outer_height + soldermaskMargin * 2;
1654
+ if (outerWidth > outerHeight) {
1655
+ return {
1656
+ macro_name: "HORZPILL",
1657
+ x_size: outerWidth,
1658
+ y_size: outerHeight,
1659
+ circle_diameter: Math.min(outerWidth, outerHeight),
1660
+ circle_center_offset: outerWidth / 2
1661
+ };
1662
+ }
1663
+ return {
1664
+ macro_name: "VERTPILL",
1665
+ x_size: outerWidth,
1666
+ y_size: outerHeight,
1667
+ circle_diameter: Math.min(outerWidth, outerHeight),
1668
+ circle_center_offset: outerHeight / 2
1669
+ };
1670
+ }
1671
+ const shape = elm.shape;
1672
+ if (shape === "circular_hole_with_rect_pad" || shape === "pill_hole_with_rect_pad" || shape === "rotated_pill_hole_with_rect_pad") {
1673
+ if (!("rect_pad_width" in elm && "rect_pad_height" in elm)) {
1674
+ throw new Error(
1675
+ `Invalid ${shape} shape in getApertureConfigFromPcbPlatedHoleSoldermask: missing dimensions`
1676
+ );
1677
+ }
1678
+ return {
1679
+ standard_template_code: "R",
1680
+ x_size: elm.rect_pad_width + soldermaskMargin * 2,
1681
+ y_size: elm.rect_pad_height + soldermaskMargin * 2
1682
+ };
1683
+ }
1684
+ throw new Error(
1685
+ `Unsupported shape in getApertureConfigFromPcbPlatedHoleSoldermask: ${elm.shape}`
1686
+ );
1687
+ };
1582
1688
  var getApertureConfigFromCirclePcbHole = (elm) => {
1583
1689
  if (!("hole_diameter" in elm)) {
1584
1690
  throw new Error(
@@ -1590,6 +1696,21 @@ var getApertureConfigFromCirclePcbHole = (elm) => {
1590
1696
  diameter: elm.hole_diameter
1591
1697
  };
1592
1698
  };
1699
+ var getApertureConfigFromCirclePcbHoleSoldermask = (elm) => {
1700
+ if (!("hole_diameter" in elm)) {
1701
+ throw new Error(
1702
+ `Invalid shape called in getApertureConfigFromCirclePcbHoleSoldermask: ${elm.hole_shape}`
1703
+ );
1704
+ }
1705
+ let soldermaskMargin = 0;
1706
+ if ("soldermask_margin" in elm && typeof elm.soldermask_margin === "number") {
1707
+ soldermaskMargin = elm.soldermask_margin;
1708
+ }
1709
+ return {
1710
+ standard_template_code: "C",
1711
+ diameter: elm.hole_diameter + soldermaskMargin * 2
1712
+ };
1713
+ };
1593
1714
  var getApertureConfigFromOuterDiameter = (elm) => {
1594
1715
  if (typeof elm.outer_diameter !== "number") {
1595
1716
  throw new Error(
@@ -1643,15 +1764,24 @@ function getAllApertureTemplateConfigsForLayer({
1643
1764
  if (glayer_name.endsWith("_Mask") && elm.is_covered_with_solder_mask === true) {
1644
1765
  continue;
1645
1766
  }
1646
- addConfigIfNew(getApertureConfigFromPcbPlatedHole(elm));
1767
+ if (isSoldermaskLayer) {
1768
+ addConfigIfNew(getApertureConfigFromPcbPlatedHoleSoldermask(elm));
1769
+ } else {
1770
+ addConfigIfNew(getApertureConfigFromPcbPlatedHole(elm));
1771
+ }
1647
1772
  }
1648
1773
  } else if (elm.type === "pcb_hole") {
1649
1774
  if (glayer_name.endsWith("_Mask") && elm.is_covered_with_solder_mask === true) {
1650
1775
  continue;
1651
1776
  }
1652
- if (elm.hole_shape === "circle")
1653
- addConfigIfNew(getApertureConfigFromCirclePcbHole(elm));
1654
- else console.warn("NOT IMPLEMENTED: drawing gerber for non circle holes");
1777
+ if (elm.hole_shape === "circle") {
1778
+ if (isSoldermaskLayer) {
1779
+ addConfigIfNew(getApertureConfigFromCirclePcbHoleSoldermask(elm));
1780
+ } else {
1781
+ addConfigIfNew(getApertureConfigFromCirclePcbHole(elm));
1782
+ }
1783
+ } else
1784
+ console.warn("NOT IMPLEMENTED: drawing gerber for non circle holes");
1655
1785
  } else if (elm.type === "pcb_via") {
1656
1786
  addConfigIfNew(getApertureConfigFromOuterDiameter(elm));
1657
1787
  } else if (elm.type === "pcb_trace") {
@@ -1698,7 +1828,7 @@ var findApertureNumber = (glayer, search_params) => {
1698
1828
  // package.json
1699
1829
  var package_default = {
1700
1830
  name: "circuit-json-to-gerber",
1701
- version: "0.0.62",
1831
+ version: "0.0.64",
1702
1832
  main: "dist/index.js",
1703
1833
  type: "module",
1704
1834
  scripts: {
@@ -2534,10 +2664,17 @@ var convertSoupToGerberCommands = (circuitJson, opts = {}) => {
2534
2664
  }
2535
2665
  glayer.push(...gb.build());
2536
2666
  } else {
2537
- const apertureConfig = getApertureConfigFromPcbPlatedHole({
2667
+ const soldermaskGlayer = glayers[getGerberLayerName(layer, "soldermask")];
2668
+ let apertureConfig = getApertureConfigFromPcbPlatedHole({
2538
2669
  ...element,
2539
2670
  ...element.shape !== "circle" ? { outer_width: padW, outer_height: padH } : {}
2540
2671
  });
2672
+ if (glayer === soldermaskGlayer) {
2673
+ apertureConfig = getApertureConfigFromPcbPlatedHoleSoldermask({
2674
+ ...element,
2675
+ ...element.shape !== "circle" ? { outer_width: padW, outer_height: padH } : {}
2676
+ });
2677
+ }
2541
2678
  const rotation = "rect_ccw_rotation" in element && typeof element.rect_ccw_rotation === "number" && Math.abs(padW - padH) > 1e-9 ? element.rect_ccw_rotation : void 0;
2542
2679
  const gb = gerberBuilder().add("select_aperture", {
2543
2680
  aperture_number: findApertureNumber(glayer, apertureConfig)
@@ -2565,7 +2702,7 @@ var convertSoupToGerberCommands = (circuitJson, opts = {}) => {
2565
2702
  ...gerberBuilder().add("select_aperture", {
2566
2703
  aperture_number: findApertureNumber(
2567
2704
  glayer,
2568
- getApertureConfigFromCirclePcbHole(element)
2705
+ getApertureConfigFromCirclePcbHoleSoldermask(element)
2569
2706
  )
2570
2707
  }).add("flash_operation", { x: element.x, y: mfy(element.y) }).build()
2571
2708
  );
@@ -2819,4 +2956,4 @@ export {
2819
2956
  stringifyGerberCommands,
2820
2957
  convertSoupToGerberCommands
2821
2958
  };
2822
- //# sourceMappingURL=chunk-VGLNFU2D.js.map
2959
+ //# sourceMappingURL=chunk-PJZ4H5LY.js.map