@tscircuit/footprinter 0.0.281 → 0.0.282

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 CHANGED
@@ -517,9 +517,125 @@ var led = (parameters) => {
517
517
  return { circuitJson: passive(parameters), parameters };
518
518
  };
519
519
 
520
+ // src/helpers/res0402-array2.ts
521
+ var padSpacing = 1.02;
522
+ var padWidth = 0.54;
523
+ var padHeight = 0.64;
524
+ var padPitch = 0.9;
525
+ var res0402Array2 = (params) => {
526
+ const yPositions = [padPitch / 2, -padPitch / 2];
527
+ const pads = [];
528
+ yPositions.forEach((y, index) => {
529
+ pads.push(rectpad(index + 1, -padSpacing / 2, y, padWidth, padHeight));
530
+ });
531
+ yPositions.slice().reverse().forEach((y, index) => {
532
+ pads.push(rectpad(index + 3, padSpacing / 2, y, padWidth, padHeight));
533
+ });
534
+ const top = Math.max(...yPositions) + padHeight / 2 + 0.4;
535
+ const bottom = Math.min(...yPositions) - padHeight / 2 - 0.4;
536
+ const left = -padSpacing / 2 - padWidth / 2 - 0.4;
537
+ const right = padSpacing / 2 + padWidth / 2 + 0.4;
538
+ const silkscreenLine = {
539
+ type: "pcb_silkscreen_path",
540
+ layer: "top",
541
+ pcb_component_id: "",
542
+ route: [
543
+ { x: right, y: top },
544
+ { x: left, y: top },
545
+ { x: left, y: bottom },
546
+ { x: right, y: bottom },
547
+ { x: right, y: top }
548
+ ],
549
+ stroke_width: 0.1,
550
+ pcb_silkscreen_path_id: ""
551
+ };
552
+ const textY = params.textbottom ? bottom - 0.9 : top + 0.9;
553
+ const silkscreenRefText = silkscreenRef(0, textY, 0.2);
554
+ return [...pads, silkscreenLine, silkscreenRefText];
555
+ };
556
+
557
+ // src/helpers/res0402-array4.ts
558
+ var padSpacing2 = 1.02;
559
+ var padWidth2 = 0.54;
560
+ var padHeight2 = 0.64;
561
+ var padPitch2 = 0.9;
562
+ var res0402Array4 = (params) => {
563
+ const yPositions = [
564
+ padPitch2 * 1.5,
565
+ padPitch2 * 0.5,
566
+ -padPitch2 * 0.5,
567
+ -padPitch2 * 1.5
568
+ ];
569
+ const pads = [];
570
+ yPositions.forEach((y, index) => {
571
+ pads.push(rectpad(index + 1, -padSpacing2 / 2, y, padWidth2, padHeight2));
572
+ });
573
+ yPositions.slice().reverse().forEach((y, index) => {
574
+ pads.push(rectpad(index + 5, padSpacing2 / 2, y, padWidth2, padHeight2));
575
+ });
576
+ const top = Math.max(...yPositions) + padHeight2 / 2 + 0.4;
577
+ const bottom = Math.min(...yPositions) - padHeight2 / 2 - 0.4;
578
+ const left = -padSpacing2 / 2 - padWidth2 / 2 - 0.4;
579
+ const right = padSpacing2 / 2 + padWidth2 / 2 + 0.4;
580
+ const silkscreenLine = {
581
+ type: "pcb_silkscreen_path",
582
+ layer: "top",
583
+ pcb_component_id: "",
584
+ route: [
585
+ { x: right, y: top },
586
+ { x: left, y: top },
587
+ { x: left, y: bottom },
588
+ { x: right, y: bottom },
589
+ { x: right, y: top }
590
+ ],
591
+ stroke_width: 0.1,
592
+ pcb_silkscreen_path_id: ""
593
+ };
594
+ const textY = params.textbottom ? bottom - 0.9 : top + 0.9;
595
+ const silkscreenRefText = silkscreenRef(0, textY, 0.2);
596
+ return [...pads, silkscreenLine, silkscreenRefText];
597
+ };
598
+
520
599
  // src/fn/res.ts
521
- var res = (parameters) => {
522
- return { circuitJson: passive(parameters), parameters };
600
+ var getArrayCount = (parameters) => {
601
+ const arrayValue = parameters.array ?? parameters.x;
602
+ if (typeof arrayValue === "number") {
603
+ return Number.isNaN(arrayValue) ? void 0 : arrayValue;
604
+ }
605
+ if (typeof arrayValue === "string") {
606
+ const parsed = Number.parseInt(arrayValue, 10);
607
+ return Number.isNaN(parsed) ? void 0 : parsed;
608
+ }
609
+ if (typeof parameters.imperial === "string") {
610
+ const match = parameters.imperial.match(/(?:array|x)(2|4)$/);
611
+ const count = match?.[1];
612
+ if (count) {
613
+ return Number.parseInt(count, 10);
614
+ }
615
+ }
616
+ return void 0;
617
+ };
618
+ var getImperialBase = (imperial) => {
619
+ if (!imperial) return void 0;
620
+ const imperialString = typeof imperial === "number" ? `${imperial}` : imperial;
621
+ return imperialString.split("_")[0];
622
+ };
623
+ var res = (rawParameters) => {
624
+ const arrayCount = getArrayCount(rawParameters);
625
+ const imperialBase = getImperialBase(rawParameters.imperial);
626
+ if (arrayCount === 2 && imperialBase === "0402") {
627
+ return {
628
+ circuitJson: res0402Array2(rawParameters),
629
+ parameters: rawParameters
630
+ };
631
+ }
632
+ if (arrayCount === 4 && imperialBase === "0402") {
633
+ return {
634
+ circuitJson: res0402Array4(rawParameters),
635
+ parameters: rawParameters
636
+ };
637
+ }
638
+ return { circuitJson: passive(rawParameters), parameters: rawParameters };
523
639
  };
524
640
 
525
641
  // src/helpers/circlepad.ts
@@ -3665,41 +3781,41 @@ var to92 = (raw_params) => {
3665
3781
  });
3666
3782
  const { p, id, od, w, h, inline } = parameters;
3667
3783
  const holeY = Number.parseFloat(h) / 2;
3668
- const padSpacing = Number.parseFloat(p);
3784
+ const padSpacing3 = Number.parseFloat(p);
3669
3785
  const holeDia = Number.parseFloat(id);
3670
3786
  const padDia = Number.parseFloat(od);
3671
- const padWidth = padDia;
3672
- const padHeight = padDia * (1.5 / 1.05);
3787
+ const padWidth3 = padDia;
3788
+ const padHeight3 = padDia * (1.5 / 1.05);
3673
3789
  let platedHoles = [];
3674
3790
  if (parameters.num_pins === 3) {
3675
3791
  if (inline) {
3676
3792
  platedHoles = [
3677
3793
  platedHoleWithRectPad(
3678
3794
  1,
3679
- -padSpacing,
3680
- holeY - padSpacing,
3795
+ -padSpacing3,
3796
+ holeY - padSpacing3,
3681
3797
  holeDia,
3682
3798
  padDia,
3683
- padHeight,
3799
+ padHeight3,
3684
3800
  0,
3685
3801
  0
3686
3802
  ),
3687
- platedHolePill(2, 0, holeY - padSpacing, holeDia, padWidth, padHeight),
3803
+ platedHolePill(2, 0, holeY - padSpacing3, holeDia, padWidth3, padHeight3),
3688
3804
  platedHolePill(
3689
3805
  3,
3690
- padSpacing,
3691
- holeY - padSpacing,
3806
+ padSpacing3,
3807
+ holeY - padSpacing3,
3692
3808
  holeDia,
3693
- padWidth,
3694
- padHeight
3809
+ padWidth3,
3810
+ padHeight3
3695
3811
  )
3696
3812
  ];
3697
3813
  } else {
3698
3814
  platedHoles = [
3699
3815
  platedHoleWithRectPad(
3700
3816
  1,
3701
- -padSpacing,
3702
- holeY - padSpacing,
3817
+ -padSpacing3,
3818
+ holeY - padSpacing3,
3703
3819
  holeDia,
3704
3820
  padDia,
3705
3821
  padDia,
@@ -3707,28 +3823,28 @@ var to92 = (raw_params) => {
3707
3823
  0
3708
3824
  ),
3709
3825
  platedhole(2, 0, holeY, holeDia, padDia),
3710
- platedhole(3, padSpacing, holeY - padSpacing, holeDia, padDia)
3826
+ platedhole(3, padSpacing3, holeY - padSpacing3, holeDia, padDia)
3711
3827
  ];
3712
3828
  }
3713
3829
  } else if (parameters.num_pins === 2) {
3714
3830
  platedHoles = [
3715
3831
  platedHoleWithRectPad(
3716
3832
  1,
3717
- -padSpacing,
3718
- holeY - padSpacing,
3833
+ -padSpacing3,
3834
+ holeY - padSpacing3,
3719
3835
  holeDia,
3720
- padWidth,
3721
- padHeight,
3836
+ padWidth3,
3837
+ padHeight3,
3722
3838
  0,
3723
3839
  0
3724
3840
  ),
3725
3841
  platedHolePill(
3726
3842
  2,
3727
- padSpacing,
3728
- holeY - padSpacing,
3843
+ padSpacing3,
3844
+ holeY - padSpacing3,
3729
3845
  holeDia,
3730
- padWidth,
3731
- padHeight
3846
+ padWidth3,
3847
+ padHeight3
3732
3848
  )
3733
3849
  ];
3734
3850
  } else {
@@ -4694,15 +4810,15 @@ var sot89_def = base_def.extend({
4694
4810
  var sot89_3 = (parameters) => {
4695
4811
  const pads = [];
4696
4812
  const padGap = Number.parseFloat(parameters.p);
4697
- const padWidth = Number.parseFloat(parameters.pw);
4813
+ const padWidth3 = Number.parseFloat(parameters.pw);
4698
4814
  const length51 = Number.parseFloat(parameters.w);
4699
- const padHeight = Number.parseFloat(parameters.pl);
4815
+ const padHeight3 = Number.parseFloat(parameters.pl);
4700
4816
  const centerExtra = 0.175;
4701
- const outerPadXShift = (padHeight - (padHeight + centerExtra)) / 2;
4817
+ const outerPadXShift = (padHeight3 - (padHeight3 + centerExtra)) / 2;
4702
4818
  pads.push(
4703
- rectpad(1, -length51 / 2 + outerPadXShift, padGap, padHeight, padWidth),
4704
- rectpad(2, -length51 / 2, 0, padHeight + centerExtra, padWidth),
4705
- rectpad(3, -length51 / 2 + outerPadXShift, -padGap, padHeight, padWidth)
4819
+ rectpad(1, -length51 / 2 + outerPadXShift, padGap, padHeight3, padWidth3),
4820
+ rectpad(2, -length51 / 2, 0, padHeight3 + centerExtra, padWidth3),
4821
+ rectpad(3, -length51 / 2 + outerPadXShift, -padGap, padHeight3, padWidth3)
4706
4822
  );
4707
4823
  const silkscreenRefText = silkscreenRef(0, 0, 0.3);
4708
4824
  const width = Number.parseFloat(parameters.w) / 2 - 1;
@@ -4741,7 +4857,7 @@ var sot89_3 = (parameters) => {
4741
4857
  var sot89_5 = (parameters) => {
4742
4858
  const pads = [];
4743
4859
  const padGap = Number.parseFloat(parameters.p);
4744
- const padWidth = Number.parseFloat(parameters.pw);
4860
+ const padWidth3 = Number.parseFloat(parameters.pw);
4745
4861
  const length51 = Number.parseFloat(parameters.w);
4746
4862
  pads.push(
4747
4863
  rectpad(1, -1.85, -1.5, 1.5, 0.7),
@@ -5897,20 +6013,20 @@ var to92s_def = base_def.extend({
5897
6013
  var to92s_3 = (parameters) => {
5898
6014
  const { p, id, od, w, h } = parameters;
5899
6015
  const holeY = Number.parseFloat(h) / 2;
5900
- const padSpacing = Number.parseFloat(p);
6016
+ const padSpacing3 = Number.parseFloat(p);
5901
6017
  return [
5902
- platedhole(1, -padSpacing, holeY - padSpacing, id, od),
5903
- platedhole(2, 0, holeY - padSpacing, id, od),
5904
- platedhole(3, padSpacing, holeY - padSpacing, id, od)
6018
+ platedhole(1, -padSpacing3, holeY - padSpacing3, id, od),
6019
+ platedhole(2, 0, holeY - padSpacing3, id, od),
6020
+ platedhole(3, padSpacing3, holeY - padSpacing3, id, od)
5905
6021
  ];
5906
6022
  };
5907
6023
  var to92s_2 = (parameters) => {
5908
6024
  const { p, id, od, h } = parameters;
5909
6025
  const holeY = Number.parseFloat(h) / 2;
5910
- const padSpacing = Number.parseFloat(p);
6026
+ const padSpacing3 = Number.parseFloat(p);
5911
6027
  return [
5912
- platedhole(1, -padSpacing, holeY - padSpacing, id, od),
5913
- platedhole(2, padSpacing, holeY - padSpacing, id, od)
6028
+ platedhole(1, -padSpacing3, holeY - padSpacing3, id, od),
6029
+ platedhole(2, padSpacing3, holeY - padSpacing3, id, od)
5914
6030
  ];
5915
6031
  };
5916
6032
  var to92s = (raw_params) => {
@@ -5929,19 +6045,19 @@ var to92s = (raw_params) => {
5929
6045
  throw new Error("Invalid number of pins for TO-92");
5930
6046
  }
5931
6047
  const holeY = Number.parseFloat(parameters.h) / 2;
5932
- const padSpacing = Number.parseFloat(parameters.p);
6048
+ const padSpacing3 = Number.parseFloat(parameters.p);
5933
6049
  const silkscreenBody = {
5934
6050
  type: "pcb_silkscreen_path",
5935
6051
  layer: "top",
5936
6052
  pcb_component_id: "",
5937
6053
  route: [
5938
- { x: -holeY, y: holeY - padSpacing },
6054
+ { x: -holeY, y: holeY - padSpacing3 },
5939
6055
  { x: -1.9, y: 0 },
5940
6056
  { x: 1.9, y: 0 },
5941
- { x: holeY, y: holeY - padSpacing },
6057
+ { x: holeY, y: holeY - padSpacing3 },
5942
6058
  { x: 1.5, y: Number.parseFloat(parameters.h) / 2 + 0.5 },
5943
6059
  { x: -1.5, y: Number.parseFloat(parameters.h) / 2 + 0.5 },
5944
- { x: -holeY, y: holeY - padSpacing }
6060
+ { x: -holeY, y: holeY - padSpacing3 }
5945
6061
  ],
5946
6062
  stroke_width: 0.1,
5947
6063
  pcb_silkscreen_path_id: ""
@@ -6720,13 +6836,13 @@ var getSonPadCoord = (num_pins, pn, w, p) => {
6720
6836
  import { length as length45 } from "circuit-json";
6721
6837
  var solderjumper = (params) => {
6722
6838
  const { num_pins, bridged, p = 2.54, pw = 1.5, ph = 1.5 } = params;
6723
- const padSpacing = length45.parse(p);
6724
- const padWidth = length45.parse(pw);
6725
- const padHeight = length45.parse(ph);
6726
- const traceWidth = Math.min(padHeight / 4, 0.5);
6839
+ const padSpacing3 = length45.parse(p);
6840
+ const padWidth3 = length45.parse(pw);
6841
+ const padHeight3 = length45.parse(ph);
6842
+ const traceWidth = Math.min(padHeight3 / 4, 0.5);
6727
6843
  const pads = [];
6728
6844
  for (let i = 0; i < num_pins; i++) {
6729
- pads.push(rectpad(i + 1, i * padSpacing, 0, padWidth, padHeight));
6845
+ pads.push(rectpad(i + 1, i * padSpacing3, 0, padWidth3, padHeight3));
6730
6846
  }
6731
6847
  let traces = [];
6732
6848
  if (bridged) {
@@ -6736,11 +6852,11 @@ var solderjumper = (params) => {
6736
6852
  const from = pins[i];
6737
6853
  const to = pins[i + 1];
6738
6854
  if (typeof from === "number" && typeof to === "number" && !isNaN(from) && !isNaN(to)) {
6739
- const xCenterFrom = (from - 1) * padSpacing;
6740
- const xCenterTo = (to - 1) * padSpacing;
6855
+ const xCenterFrom = (from - 1) * padSpacing3;
6856
+ const xCenterTo = (to - 1) * padSpacing3;
6741
6857
  const directionMult = Math.sign(xCenterTo - xCenterFrom);
6742
- const x1 = xCenterFrom + directionMult * (padWidth / 2);
6743
- const x2 = xCenterTo - directionMult * (padWidth / 2);
6858
+ const x1 = xCenterFrom + directionMult * (padWidth3 / 2);
6859
+ const x2 = xCenterTo - directionMult * (padWidth3 / 2);
6744
6860
  traces.push({
6745
6861
  type: "pcb_trace",
6746
6862
  pcb_trace_id: "",
@@ -6767,9 +6883,9 @@ var solderjumper = (params) => {
6767
6883
  }
6768
6884
  }
6769
6885
  }
6770
- const outlineWidth = (num_pins - 1) * padSpacing + padWidth + 0.7;
6771
- const outlineHeight = padHeight + 1;
6772
- const outlineCenterX = (num_pins - 1) * padSpacing / 2;
6886
+ const outlineWidth = (num_pins - 1) * padSpacing3 + padWidth3 + 0.7;
6887
+ const outlineHeight = padHeight3 + 1;
6888
+ const outlineCenterX = (num_pins - 1) * padSpacing3 / 2;
6773
6889
  const outlineCenterY = 0;
6774
6890
  const silkscreenRect = {
6775
6891
  type: "pcb_silkscreen_path",
@@ -6870,40 +6986,40 @@ var generateSot457Elements = (params) => {
6870
6986
  const pads = [];
6871
6987
  const pitch = parseDimension(params.p);
6872
6988
  const padLength = parseDimension(params.pl);
6873
- const padWidth = parseDimension(params.pw);
6989
+ const padWidth3 = parseDimension(params.pw);
6874
6990
  const width = parseDimension(params.w);
6875
6991
  const height = parseDimension(params.h);
6876
6992
  if (params.wave) {
6877
6993
  const pinConfigs = {
6878
- 1: ({ padWidth: padWidth2, padHeight }) => rectpad(1, -pitch, pitch, padHeight, padWidth2),
6879
- 2: ({ padWidth: padWidth2, padHeight }) => rectpad(2, -pitch, -pitch, padHeight, padWidth2),
6880
- 3: ({ padWidth: padWidth2, padHeight }) => pillpad(
6994
+ 1: ({ padWidth: padWidth4, padHeight: padHeight3 }) => rectpad(1, -pitch, pitch, padHeight3, padWidth4),
6995
+ 2: ({ padWidth: padWidth4, padHeight: padHeight3 }) => rectpad(2, -pitch, -pitch, padHeight3, padWidth4),
6996
+ 3: ({ padWidth: padWidth4, padHeight: padHeight3 }) => pillpad(
6881
6997
  3,
6882
6998
  -pitch,
6883
6999
  0,
6884
7000
  parseDimension(params.pillw),
6885
7001
  parseDimension(params.pillh)
6886
7002
  ),
6887
- 4: ({ padWidth: padWidth2, padHeight }) => pillpad(
7003
+ 4: ({ padWidth: padWidth4, padHeight: padHeight3 }) => pillpad(
6888
7004
  4,
6889
7005
  pitch,
6890
7006
  0,
6891
7007
  parseDimension(params.pillw),
6892
7008
  parseDimension(params.pillh)
6893
7009
  ),
6894
- 5: ({ padWidth: padWidth2, padHeight }) => rectpad(5, pitch, pitch, padHeight, padWidth2),
6895
- 6: ({ padWidth: padWidth2, padHeight }) => rectpad(6, pitch, -pitch, padHeight, padWidth2)
7010
+ 5: ({ padWidth: padWidth4, padHeight: padHeight3 }) => rectpad(5, pitch, pitch, padHeight3, padWidth4),
7011
+ 6: ({ padWidth: padWidth4, padHeight: padHeight3 }) => rectpad(6, pitch, -pitch, padHeight3, padWidth4)
6896
7012
  };
6897
7013
  for (let i = 1; i <= params.num_pins; i++) {
6898
7014
  const config = pinConfigs[i];
6899
7015
  if (config) {
6900
- pads.push(config({ padWidth: padLength, padHeight: padWidth }));
7016
+ pads.push(config({ padWidth: padLength, padHeight: padWidth3 }));
6901
7017
  }
6902
7018
  }
6903
7019
  } else {
6904
7020
  for (let i = 1; i <= params.num_pins; i++) {
6905
7021
  const { x, y } = getCcwSot457Coords({ pitch, width, pinNumber: i });
6906
- pads.push(rectpad(i, x, y, padLength, padWidth));
7022
+ pads.push(rectpad(i, x, y, padLength, padWidth3));
6907
7023
  }
6908
7024
  }
6909
7025
  const silkscreenPath1 = {
@@ -6932,7 +7048,7 @@ var generateSot457Elements = (params) => {
6932
7048
  const pin1Position = getCcwSot457Coords({ pitch, width, pinNumber: 1 });
6933
7049
  const triangleHeight = params.wave ? 1 : 0.5;
6934
7050
  const triangleWidth = params.wave ? 0.7 : 0.3;
6935
- pin1Position.x -= params.wave ? padWidth : padWidth * 1.7;
7051
+ pin1Position.x -= params.wave ? padWidth3 : padWidth3 * 1.7;
6936
7052
  const pin1Indicator = {
6937
7053
  type: "pcb_silkscreen_path",
6938
7054
  layer: "top",
@@ -7794,7 +7910,7 @@ var m2host_def = base_def.extend({
7794
7910
  var m2host = (raw_params) => {
7795
7911
  const parameters = m2host_def.parse(raw_params);
7796
7912
  const pads = [];
7797
- const padWidth = 0.5 - 0.15;
7913
+ const padWidth3 = 0.5 - 0.15;
7798
7914
  const padLength = 1.5;
7799
7915
  const pitch = 0.5;
7800
7916
  const halfPitch = pitch / 2;
@@ -7809,7 +7925,7 @@ var m2host = (raw_params) => {
7809
7925
  const padLengthWithOffset = padLength + (isBottomLayer ? 0.25 : 0);
7810
7926
  const rightEdgeOffset = 0.5;
7811
7927
  const x = rightEdgeOffset - padLengthWithOffset / 2;
7812
- const pad2 = rectpad(pn, x, y, padLengthWithOffset, padWidth);
7928
+ const pad2 = rectpad(pn, x, y, padLengthWithOffset, padWidth3);
7813
7929
  pad2.layer = isBottomLayer ? "bottom" : "top";
7814
7930
  pads.push(pad2);
7815
7931
  }