@tscircuit/footprinter 0.0.281 → 0.0.283

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,150 @@ var led = (parameters) => {
517
517
  return { circuitJson: passive(parameters), parameters };
518
518
  };
519
519
 
520
+ // src/helpers/chipArray.ts
521
+ var chipArray = (params) => {
522
+ const { padSpacing: padSpacing3, padWidth: padWidth3, padHeight: padHeight3, padPitch: padPitch3, numRows, textbottom } = params;
523
+ const yPositions = [];
524
+ const halfRange = (numRows - 1) * (padPitch3 / 2);
525
+ for (let i = 0; i < numRows; i++) {
526
+ yPositions.push(halfRange - i * padPitch3);
527
+ }
528
+ const pads = [];
529
+ yPositions.forEach((y, index) => {
530
+ pads.push(rectpad(index + 1, -padSpacing3 / 2, y, padWidth3, padHeight3));
531
+ });
532
+ yPositions.slice().reverse().forEach((y, index) => {
533
+ pads.push(
534
+ rectpad(index + numRows + 1, padSpacing3 / 2, y, padWidth3, padHeight3)
535
+ );
536
+ });
537
+ const top = Math.max(...yPositions) + padHeight3 / 2 + 0.4;
538
+ const bottom = Math.min(...yPositions) - padHeight3 / 2 - 0.4;
539
+ const left = -padSpacing3 / 2 - padWidth3 / 2 - 0.4;
540
+ const right = padSpacing3 / 2 + padWidth3 / 2 + 0.4;
541
+ const silkscreenTop = {
542
+ type: "pcb_silkscreen_path",
543
+ layer: "top",
544
+ pcb_component_id: "",
545
+ route: [
546
+ { x: right * 0.5, y: top },
547
+ { x: left * 0.5, y: top }
548
+ ],
549
+ stroke_width: 0.12,
550
+ pcb_silkscreen_path_id: "silkscreen_top"
551
+ };
552
+ const silkscreenBottom = {
553
+ type: "pcb_silkscreen_path",
554
+ layer: "top",
555
+ pcb_component_id: "",
556
+ route: [
557
+ { x: right * 0.5, y: bottom },
558
+ { x: left * 0.5, y: bottom }
559
+ ],
560
+ stroke_width: 0.12,
561
+ pcb_silkscreen_path_id: "silkscreen_bottom"
562
+ };
563
+ const pin1X = -padSpacing3 / 2;
564
+ const pin1Y = Math.max(...yPositions);
565
+ const pin1MarkerSize = 0.2;
566
+ const pin1Left = pin1X - padWidth3 / 2 - 0.1;
567
+ const pin1Top = pin1Y + padHeight3 / 2 + 0.1;
568
+ const pin1Marker = {
569
+ type: "pcb_silkscreen_path",
570
+ layer: "top",
571
+ pcb_component_id: "",
572
+ pcb_silkscreen_path_id: "pin1_marker",
573
+ route: [
574
+ { x: pin1Left, y: pin1Top },
575
+ { x: pin1Left - pin1MarkerSize, y: pin1Top },
576
+ { x: pin1Left, y: pin1Top + pin1MarkerSize },
577
+ { x: pin1Left, y: pin1Top }
578
+ ],
579
+ stroke_width: 0.1
580
+ };
581
+ const textY = textbottom ? bottom - 0.9 : top + 0.9;
582
+ const silkscreenRefText = silkscreenRef(0, textY, 0.2);
583
+ return [
584
+ ...pads,
585
+ silkscreenTop,
586
+ silkscreenBottom,
587
+ pin1Marker,
588
+ silkscreenRefText
589
+ ];
590
+ };
591
+
592
+ // src/helpers/res0402-array2.ts
593
+ var padSpacing = 1;
594
+ var padWidth = 0.5;
595
+ var padHeight = 0.4;
596
+ var padPitch = 0.7;
597
+ var res0402Array2 = (params) => {
598
+ return chipArray({
599
+ padSpacing,
600
+ padWidth,
601
+ padHeight,
602
+ padPitch,
603
+ numRows: 2,
604
+ textbottom: params.textbottom
605
+ });
606
+ };
607
+
608
+ // src/helpers/res0402-array4.ts
609
+ var padSpacing2 = 1;
610
+ var padWidth2 = 0.5;
611
+ var padHeight2 = 0.32;
612
+ var padPitch2 = 0.5;
613
+ var res0402Array4 = (params) => {
614
+ return chipArray({
615
+ padSpacing: padSpacing2,
616
+ padWidth: padWidth2,
617
+ padHeight: padHeight2,
618
+ padPitch: padPitch2,
619
+ numRows: 4,
620
+ textbottom: params.textbottom
621
+ });
622
+ };
623
+
520
624
  // src/fn/res.ts
521
- var res = (parameters) => {
522
- return { circuitJson: passive(parameters), parameters };
625
+ var getArrayCount = (parameters) => {
626
+ const arrayValue = parameters.array ?? parameters.x;
627
+ if (typeof arrayValue === "number") {
628
+ return Number.isNaN(arrayValue) ? void 0 : arrayValue;
629
+ }
630
+ if (typeof arrayValue === "string") {
631
+ const parsed = Number.parseInt(arrayValue, 10);
632
+ return Number.isNaN(parsed) ? void 0 : parsed;
633
+ }
634
+ if (typeof parameters.imperial === "string") {
635
+ const match = parameters.imperial.match(/(?:array|x)(2|4)$/);
636
+ const count = match?.[1];
637
+ if (count) {
638
+ return Number.parseInt(count, 10);
639
+ }
640
+ }
641
+ return void 0;
642
+ };
643
+ var getImperialBase = (imperial) => {
644
+ if (!imperial) return void 0;
645
+ const imperialString = typeof imperial === "number" ? `${imperial}` : imperial;
646
+ return imperialString.split("_")[0];
647
+ };
648
+ var res = (rawParameters) => {
649
+ const arrayCount = getArrayCount(rawParameters);
650
+ const imperialBase = getImperialBase(rawParameters.imperial);
651
+ if (arrayCount === 2 && imperialBase === "0402") {
652
+ return {
653
+ circuitJson: res0402Array2(rawParameters),
654
+ parameters: rawParameters
655
+ };
656
+ }
657
+ if (arrayCount === 4 && imperialBase === "0402") {
658
+ return {
659
+ circuitJson: res0402Array4(rawParameters),
660
+ parameters: rawParameters
661
+ };
662
+ }
663
+ return { circuitJson: passive(rawParameters), parameters: rawParameters };
523
664
  };
524
665
 
525
666
  // src/helpers/circlepad.ts
@@ -3665,41 +3806,41 @@ var to92 = (raw_params) => {
3665
3806
  });
3666
3807
  const { p, id, od, w, h, inline } = parameters;
3667
3808
  const holeY = Number.parseFloat(h) / 2;
3668
- const padSpacing = Number.parseFloat(p);
3809
+ const padSpacing3 = Number.parseFloat(p);
3669
3810
  const holeDia = Number.parseFloat(id);
3670
3811
  const padDia = Number.parseFloat(od);
3671
- const padWidth = padDia;
3672
- const padHeight = padDia * (1.5 / 1.05);
3812
+ const padWidth3 = padDia;
3813
+ const padHeight3 = padDia * (1.5 / 1.05);
3673
3814
  let platedHoles = [];
3674
3815
  if (parameters.num_pins === 3) {
3675
3816
  if (inline) {
3676
3817
  platedHoles = [
3677
3818
  platedHoleWithRectPad(
3678
3819
  1,
3679
- -padSpacing,
3680
- holeY - padSpacing,
3820
+ -padSpacing3,
3821
+ holeY - padSpacing3,
3681
3822
  holeDia,
3682
3823
  padDia,
3683
- padHeight,
3824
+ padHeight3,
3684
3825
  0,
3685
3826
  0
3686
3827
  ),
3687
- platedHolePill(2, 0, holeY - padSpacing, holeDia, padWidth, padHeight),
3828
+ platedHolePill(2, 0, holeY - padSpacing3, holeDia, padWidth3, padHeight3),
3688
3829
  platedHolePill(
3689
3830
  3,
3690
- padSpacing,
3691
- holeY - padSpacing,
3831
+ padSpacing3,
3832
+ holeY - padSpacing3,
3692
3833
  holeDia,
3693
- padWidth,
3694
- padHeight
3834
+ padWidth3,
3835
+ padHeight3
3695
3836
  )
3696
3837
  ];
3697
3838
  } else {
3698
3839
  platedHoles = [
3699
3840
  platedHoleWithRectPad(
3700
3841
  1,
3701
- -padSpacing,
3702
- holeY - padSpacing,
3842
+ -padSpacing3,
3843
+ holeY - padSpacing3,
3703
3844
  holeDia,
3704
3845
  padDia,
3705
3846
  padDia,
@@ -3707,28 +3848,28 @@ var to92 = (raw_params) => {
3707
3848
  0
3708
3849
  ),
3709
3850
  platedhole(2, 0, holeY, holeDia, padDia),
3710
- platedhole(3, padSpacing, holeY - padSpacing, holeDia, padDia)
3851
+ platedhole(3, padSpacing3, holeY - padSpacing3, holeDia, padDia)
3711
3852
  ];
3712
3853
  }
3713
3854
  } else if (parameters.num_pins === 2) {
3714
3855
  platedHoles = [
3715
3856
  platedHoleWithRectPad(
3716
3857
  1,
3717
- -padSpacing,
3718
- holeY - padSpacing,
3858
+ -padSpacing3,
3859
+ holeY - padSpacing3,
3719
3860
  holeDia,
3720
- padWidth,
3721
- padHeight,
3861
+ padWidth3,
3862
+ padHeight3,
3722
3863
  0,
3723
3864
  0
3724
3865
  ),
3725
3866
  platedHolePill(
3726
3867
  2,
3727
- padSpacing,
3728
- holeY - padSpacing,
3868
+ padSpacing3,
3869
+ holeY - padSpacing3,
3729
3870
  holeDia,
3730
- padWidth,
3731
- padHeight
3871
+ padWidth3,
3872
+ padHeight3
3732
3873
  )
3733
3874
  ];
3734
3875
  } else {
@@ -4694,15 +4835,15 @@ var sot89_def = base_def.extend({
4694
4835
  var sot89_3 = (parameters) => {
4695
4836
  const pads = [];
4696
4837
  const padGap = Number.parseFloat(parameters.p);
4697
- const padWidth = Number.parseFloat(parameters.pw);
4838
+ const padWidth3 = Number.parseFloat(parameters.pw);
4698
4839
  const length51 = Number.parseFloat(parameters.w);
4699
- const padHeight = Number.parseFloat(parameters.pl);
4840
+ const padHeight3 = Number.parseFloat(parameters.pl);
4700
4841
  const centerExtra = 0.175;
4701
- const outerPadXShift = (padHeight - (padHeight + centerExtra)) / 2;
4842
+ const outerPadXShift = (padHeight3 - (padHeight3 + centerExtra)) / 2;
4702
4843
  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)
4844
+ rectpad(1, -length51 / 2 + outerPadXShift, padGap, padHeight3, padWidth3),
4845
+ rectpad(2, -length51 / 2, 0, padHeight3 + centerExtra, padWidth3),
4846
+ rectpad(3, -length51 / 2 + outerPadXShift, -padGap, padHeight3, padWidth3)
4706
4847
  );
4707
4848
  const silkscreenRefText = silkscreenRef(0, 0, 0.3);
4708
4849
  const width = Number.parseFloat(parameters.w) / 2 - 1;
@@ -4741,7 +4882,7 @@ var sot89_3 = (parameters) => {
4741
4882
  var sot89_5 = (parameters) => {
4742
4883
  const pads = [];
4743
4884
  const padGap = Number.parseFloat(parameters.p);
4744
- const padWidth = Number.parseFloat(parameters.pw);
4885
+ const padWidth3 = Number.parseFloat(parameters.pw);
4745
4886
  const length51 = Number.parseFloat(parameters.w);
4746
4887
  pads.push(
4747
4888
  rectpad(1, -1.85, -1.5, 1.5, 0.7),
@@ -5897,20 +6038,20 @@ var to92s_def = base_def.extend({
5897
6038
  var to92s_3 = (parameters) => {
5898
6039
  const { p, id, od, w, h } = parameters;
5899
6040
  const holeY = Number.parseFloat(h) / 2;
5900
- const padSpacing = Number.parseFloat(p);
6041
+ const padSpacing3 = Number.parseFloat(p);
5901
6042
  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)
6043
+ platedhole(1, -padSpacing3, holeY - padSpacing3, id, od),
6044
+ platedhole(2, 0, holeY - padSpacing3, id, od),
6045
+ platedhole(3, padSpacing3, holeY - padSpacing3, id, od)
5905
6046
  ];
5906
6047
  };
5907
6048
  var to92s_2 = (parameters) => {
5908
6049
  const { p, id, od, h } = parameters;
5909
6050
  const holeY = Number.parseFloat(h) / 2;
5910
- const padSpacing = Number.parseFloat(p);
6051
+ const padSpacing3 = Number.parseFloat(p);
5911
6052
  return [
5912
- platedhole(1, -padSpacing, holeY - padSpacing, id, od),
5913
- platedhole(2, padSpacing, holeY - padSpacing, id, od)
6053
+ platedhole(1, -padSpacing3, holeY - padSpacing3, id, od),
6054
+ platedhole(2, padSpacing3, holeY - padSpacing3, id, od)
5914
6055
  ];
5915
6056
  };
5916
6057
  var to92s = (raw_params) => {
@@ -5929,19 +6070,19 @@ var to92s = (raw_params) => {
5929
6070
  throw new Error("Invalid number of pins for TO-92");
5930
6071
  }
5931
6072
  const holeY = Number.parseFloat(parameters.h) / 2;
5932
- const padSpacing = Number.parseFloat(parameters.p);
6073
+ const padSpacing3 = Number.parseFloat(parameters.p);
5933
6074
  const silkscreenBody = {
5934
6075
  type: "pcb_silkscreen_path",
5935
6076
  layer: "top",
5936
6077
  pcb_component_id: "",
5937
6078
  route: [
5938
- { x: -holeY, y: holeY - padSpacing },
6079
+ { x: -holeY, y: holeY - padSpacing3 },
5939
6080
  { x: -1.9, y: 0 },
5940
6081
  { x: 1.9, y: 0 },
5941
- { x: holeY, y: holeY - padSpacing },
6082
+ { x: holeY, y: holeY - padSpacing3 },
5942
6083
  { x: 1.5, y: Number.parseFloat(parameters.h) / 2 + 0.5 },
5943
6084
  { x: -1.5, y: Number.parseFloat(parameters.h) / 2 + 0.5 },
5944
- { x: -holeY, y: holeY - padSpacing }
6085
+ { x: -holeY, y: holeY - padSpacing3 }
5945
6086
  ],
5946
6087
  stroke_width: 0.1,
5947
6088
  pcb_silkscreen_path_id: ""
@@ -6720,13 +6861,13 @@ var getSonPadCoord = (num_pins, pn, w, p) => {
6720
6861
  import { length as length45 } from "circuit-json";
6721
6862
  var solderjumper = (params) => {
6722
6863
  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);
6864
+ const padSpacing3 = length45.parse(p);
6865
+ const padWidth3 = length45.parse(pw);
6866
+ const padHeight3 = length45.parse(ph);
6867
+ const traceWidth = Math.min(padHeight3 / 4, 0.5);
6727
6868
  const pads = [];
6728
6869
  for (let i = 0; i < num_pins; i++) {
6729
- pads.push(rectpad(i + 1, i * padSpacing, 0, padWidth, padHeight));
6870
+ pads.push(rectpad(i + 1, i * padSpacing3, 0, padWidth3, padHeight3));
6730
6871
  }
6731
6872
  let traces = [];
6732
6873
  if (bridged) {
@@ -6736,11 +6877,11 @@ var solderjumper = (params) => {
6736
6877
  const from = pins[i];
6737
6878
  const to = pins[i + 1];
6738
6879
  if (typeof from === "number" && typeof to === "number" && !isNaN(from) && !isNaN(to)) {
6739
- const xCenterFrom = (from - 1) * padSpacing;
6740
- const xCenterTo = (to - 1) * padSpacing;
6880
+ const xCenterFrom = (from - 1) * padSpacing3;
6881
+ const xCenterTo = (to - 1) * padSpacing3;
6741
6882
  const directionMult = Math.sign(xCenterTo - xCenterFrom);
6742
- const x1 = xCenterFrom + directionMult * (padWidth / 2);
6743
- const x2 = xCenterTo - directionMult * (padWidth / 2);
6883
+ const x1 = xCenterFrom + directionMult * (padWidth3 / 2);
6884
+ const x2 = xCenterTo - directionMult * (padWidth3 / 2);
6744
6885
  traces.push({
6745
6886
  type: "pcb_trace",
6746
6887
  pcb_trace_id: "",
@@ -6767,9 +6908,9 @@ var solderjumper = (params) => {
6767
6908
  }
6768
6909
  }
6769
6910
  }
6770
- const outlineWidth = (num_pins - 1) * padSpacing + padWidth + 0.7;
6771
- const outlineHeight = padHeight + 1;
6772
- const outlineCenterX = (num_pins - 1) * padSpacing / 2;
6911
+ const outlineWidth = (num_pins - 1) * padSpacing3 + padWidth3 + 0.7;
6912
+ const outlineHeight = padHeight3 + 1;
6913
+ const outlineCenterX = (num_pins - 1) * padSpacing3 / 2;
6773
6914
  const outlineCenterY = 0;
6774
6915
  const silkscreenRect = {
6775
6916
  type: "pcb_silkscreen_path",
@@ -6870,40 +7011,40 @@ var generateSot457Elements = (params) => {
6870
7011
  const pads = [];
6871
7012
  const pitch = parseDimension(params.p);
6872
7013
  const padLength = parseDimension(params.pl);
6873
- const padWidth = parseDimension(params.pw);
7014
+ const padWidth3 = parseDimension(params.pw);
6874
7015
  const width = parseDimension(params.w);
6875
7016
  const height = parseDimension(params.h);
6876
7017
  if (params.wave) {
6877
7018
  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(
7019
+ 1: ({ padWidth: padWidth4, padHeight: padHeight3 }) => rectpad(1, -pitch, pitch, padHeight3, padWidth4),
7020
+ 2: ({ padWidth: padWidth4, padHeight: padHeight3 }) => rectpad(2, -pitch, -pitch, padHeight3, padWidth4),
7021
+ 3: ({ padWidth: padWidth4, padHeight: padHeight3 }) => pillpad(
6881
7022
  3,
6882
7023
  -pitch,
6883
7024
  0,
6884
7025
  parseDimension(params.pillw),
6885
7026
  parseDimension(params.pillh)
6886
7027
  ),
6887
- 4: ({ padWidth: padWidth2, padHeight }) => pillpad(
7028
+ 4: ({ padWidth: padWidth4, padHeight: padHeight3 }) => pillpad(
6888
7029
  4,
6889
7030
  pitch,
6890
7031
  0,
6891
7032
  parseDimension(params.pillw),
6892
7033
  parseDimension(params.pillh)
6893
7034
  ),
6894
- 5: ({ padWidth: padWidth2, padHeight }) => rectpad(5, pitch, pitch, padHeight, padWidth2),
6895
- 6: ({ padWidth: padWidth2, padHeight }) => rectpad(6, pitch, -pitch, padHeight, padWidth2)
7035
+ 5: ({ padWidth: padWidth4, padHeight: padHeight3 }) => rectpad(5, pitch, pitch, padHeight3, padWidth4),
7036
+ 6: ({ padWidth: padWidth4, padHeight: padHeight3 }) => rectpad(6, pitch, -pitch, padHeight3, padWidth4)
6896
7037
  };
6897
7038
  for (let i = 1; i <= params.num_pins; i++) {
6898
7039
  const config = pinConfigs[i];
6899
7040
  if (config) {
6900
- pads.push(config({ padWidth: padLength, padHeight: padWidth }));
7041
+ pads.push(config({ padWidth: padLength, padHeight: padWidth3 }));
6901
7042
  }
6902
7043
  }
6903
7044
  } else {
6904
7045
  for (let i = 1; i <= params.num_pins; i++) {
6905
7046
  const { x, y } = getCcwSot457Coords({ pitch, width, pinNumber: i });
6906
- pads.push(rectpad(i, x, y, padLength, padWidth));
7047
+ pads.push(rectpad(i, x, y, padLength, padWidth3));
6907
7048
  }
6908
7049
  }
6909
7050
  const silkscreenPath1 = {
@@ -6932,7 +7073,7 @@ var generateSot457Elements = (params) => {
6932
7073
  const pin1Position = getCcwSot457Coords({ pitch, width, pinNumber: 1 });
6933
7074
  const triangleHeight = params.wave ? 1 : 0.5;
6934
7075
  const triangleWidth = params.wave ? 0.7 : 0.3;
6935
- pin1Position.x -= params.wave ? padWidth : padWidth * 1.7;
7076
+ pin1Position.x -= params.wave ? padWidth3 : padWidth3 * 1.7;
6936
7077
  const pin1Indicator = {
6937
7078
  type: "pcb_silkscreen_path",
6938
7079
  layer: "top",
@@ -7794,7 +7935,7 @@ var m2host_def = base_def.extend({
7794
7935
  var m2host = (raw_params) => {
7795
7936
  const parameters = m2host_def.parse(raw_params);
7796
7937
  const pads = [];
7797
- const padWidth = 0.5 - 0.15;
7938
+ const padWidth3 = 0.5 - 0.15;
7798
7939
  const padLength = 1.5;
7799
7940
  const pitch = 0.5;
7800
7941
  const halfPitch = pitch / 2;
@@ -7809,7 +7950,7 @@ var m2host = (raw_params) => {
7809
7950
  const padLengthWithOffset = padLength + (isBottomLayer ? 0.25 : 0);
7810
7951
  const rightEdgeOffset = 0.5;
7811
7952
  const x = rightEdgeOffset - padLengthWithOffset / 2;
7812
- const pad2 = rectpad(pn, x, y, padLengthWithOffset, padWidth);
7953
+ const pad2 = rectpad(pn, x, y, padLengthWithOffset, padWidth3);
7813
7954
  pad2.layer = isBottomLayer ? "bottom" : "top";
7814
7955
  pads.push(pad2);
7815
7956
  }