@tscircuit/footprinter 0.0.126 → 0.0.128

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 CHANGED
@@ -1007,16 +1007,18 @@ type Footprinter = {
1007
1007
  sot23: () => FootprinterParamsBuilder<"w" | "h" | "pl" | "pw">;
1008
1008
  sot236: () => FootprinterParamsBuilder<"w" | "p">;
1009
1009
  sot89: () => FootprinterParamsBuilder<"w" | "p" | "pl">;
1010
- to92: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "od">;
1010
+ smc: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pw" | "pl">;
1011
1011
  minimelf: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pw" | "pl">;
1012
1012
  melf: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pw" | "pl">;
1013
1013
  micromelf: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pw" | "pl">;
1014
1014
  ms013: () => FootprinterParamsBuilder<"w" | "p">;
1015
1015
  ms012: () => FootprinterParamsBuilder<"w" | "p">;
1016
1016
  lqfp: (num_pins?: number) => FootprinterParamsBuilder<"w" | "h" | "pl" | "pw">;
1017
+ sma: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1017
1018
  smf: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1018
1019
  smb: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1019
1020
  sod923: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1021
+ vssop8: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1020
1022
  sod882: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1021
1023
  sod882d: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1022
1024
  sod723: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
@@ -1025,6 +1027,7 @@ type Footprinter = {
1025
1027
  sod128: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1026
1028
  sod123f: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1027
1029
  sod123: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1030
+ to92: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "od" | "inline">;
1028
1031
  pushbutton: () => FootprinterParamsBuilder<"tllabel" | "trlabel" | "bllabel" | "brlabel">;
1029
1032
  stampboard: () => FootprinterParamsBuilder<"w" | "h" | "left" | "right" | "top" | "bottom" | "p" | "pw" | "pl" | "innerhole" | "innerholeedgedistance">;
1030
1033
  stampreceiver: () => FootprinterParamsBuilder<"w" | "h" | "left" | "right" | "top" | "bottom" | "p" | "pw" | "pl" | "innerhole" | "innerholeedgedistance">;
package/dist/index.js CHANGED
@@ -30,7 +30,9 @@ __export(fn_exports, {
30
30
  qfp: () => qfp,
31
31
  quad: () => quad,
32
32
  res: () => res,
33
+ sma: () => sma,
33
34
  smb: () => smb,
35
+ smc: () => smc,
34
36
  smf: () => smf,
35
37
  sod123: () => sod123,
36
38
  sod123f: () => sod123f,
@@ -54,7 +56,8 @@ __export(fn_exports, {
54
56
  stampreceiver: () => stampreceiver,
55
57
  to220: () => to220,
56
58
  to92: () => to92,
57
- tssop: () => tssop
59
+ tssop: () => tssop,
60
+ vssop8: () => vssop8
58
61
  });
59
62
 
60
63
  // src/helpers/silkscreenRef.ts
@@ -124,8 +127,13 @@ var extendDipDef = (newDefaults) => z.object({
124
127
  od: lengthInMm.optional()
125
128
  }).transform((v) => {
126
129
  if (!v.id && !v.od) {
127
- v.id = convertMilToMm("1.0mm");
128
- v.od = convertMilToMm("1.5mm");
130
+ if (Math.abs(v.p - 1.27) < 0.01) {
131
+ v.id = convertMilToMm("0.55mm");
132
+ v.od = convertMilToMm("0.95mm");
133
+ } else {
134
+ v.id = convertMilToMm("1.0mm");
135
+ v.od = convertMilToMm("1.5mm");
136
+ }
129
137
  } else if (!v.id) {
130
138
  v.id = v.od * (1 / 1.5);
131
139
  } else if (!v.od) {
@@ -1200,7 +1208,7 @@ var sot23WithoutParsing = (parameters) => {
1200
1208
  }
1201
1209
  const silkscreenRefText = silkscreenRef(
1202
1210
  0,
1203
- Number(parameters.h),
1211
+ parseInt(parameters.h),
1204
1212
  0.3
1205
1213
  );
1206
1214
  return [...pads, silkscreenRefText];
@@ -2617,21 +2625,21 @@ var to92_def = z22.object({
2617
2625
  od: length15.optional().default(".95mm"),
2618
2626
  w: length15.optional().default("4.5mm"),
2619
2627
  h: length15.optional().default("4.5mm"),
2620
- arrangement: z22.enum(["triangular", "inline"]).optional().default("triangular")
2628
+ inline: z22.boolean().optional().default(false)
2621
2629
  });
2622
2630
  var to92 = (raw_params) => {
2623
2631
  const parameters = to92_def.parse(raw_params);
2624
- const { p, id, od, w, h, arrangement } = parameters;
2632
+ const { p, id, od, w, h, inline } = parameters;
2625
2633
  const radius = w / 2;
2626
2634
  const holeY = h / 2;
2627
- const plated_holes = arrangement === "triangular" ? [
2635
+ const plated_holes = inline ? [
2636
+ platedhole(1, -p, holeY - p, id, od),
2637
+ platedhole(2, 0, holeY - p, id, od),
2638
+ platedhole(3, p, holeY - p, id, od)
2639
+ ] : [
2628
2640
  platedhole(1, 0, holeY, id, od),
2629
2641
  platedhole(2, -p, holeY - p, id, od),
2630
2642
  platedhole(3, p, holeY - p, id, od)
2631
- ] : [
2632
- platedhole(1, -p, holeY, id, od),
2633
- platedhole(2, 0, holeY, id, od),
2634
- platedhole(3, p, holeY, id, od)
2635
2643
  ];
2636
2644
  const semicircle = generate_semicircle(0, h / 2, radius);
2637
2645
  const silkscreenBody = {
@@ -3678,23 +3686,23 @@ var microMelfWithoutParsing = (parameters) => {
3678
3686
  return pads;
3679
3687
  };
3680
3688
 
3681
- // src/fn/smf.ts
3689
+ // src/fn/sma.ts
3682
3690
  import { z as z35 } from "zod";
3683
3691
  import { length as length28 } from "circuit-json";
3684
- var smf_def = z35.object({
3692
+ var sma_def = z35.object({
3685
3693
  fn: z35.string(),
3686
3694
  num_pins: z35.literal(2).default(2),
3687
- w: z35.string().default("4.80mm"),
3688
- h: z35.string().default("2.10mm"),
3689
- pl: z35.string().default("1.30mm"),
3690
- pw: z35.string().default("1.40mm"),
3691
- p: z35.string().default("2.9mm")
3695
+ w: z35.string().default("7.10mm"),
3696
+ h: z35.string().default("3.40mm"),
3697
+ pl: z35.string().default("2.45mm"),
3698
+ pw: z35.string().default("1.80mm"),
3699
+ p: z35.string().default("4.05mm")
3692
3700
  });
3693
- var smf = (raw_params) => {
3694
- const parameters = smf_def.parse(raw_params);
3701
+ var sma = (raw_params) => {
3702
+ const parameters = sma_def.parse(raw_params);
3695
3703
  const silkscreenRefText = silkscreenRef(
3696
3704
  0,
3697
- length28.parse(parameters.h) - 0.5,
3705
+ length28.parse(parameters.h) / 2 + 0.5,
3698
3706
  0.3
3699
3707
  );
3700
3708
  const silkscreenLine = {
@@ -3707,11 +3715,11 @@ var smf = (raw_params) => {
3707
3715
  y: length28.parse(parameters.h) / 2
3708
3716
  },
3709
3717
  {
3710
- x: -length28.parse(parameters.w) / 2,
3718
+ x: -length28.parse(parameters.w) / 2 - 0.5,
3711
3719
  y: length28.parse(parameters.h) / 2
3712
3720
  },
3713
3721
  {
3714
- x: -length28.parse(parameters.w) / 2,
3722
+ x: -length28.parse(parameters.w) / 2 - 0.5,
3715
3723
  y: -length28.parse(parameters.h) / 2
3716
3724
  },
3717
3725
  {
@@ -3723,25 +3731,24 @@ var smf = (raw_params) => {
3723
3731
  pcb_silkscreen_path_id: ""
3724
3732
  };
3725
3733
  return {
3726
- circuitJson: smfWithoutParsing(parameters).concat(
3734
+ circuitJson: smaWithoutParsing(parameters).concat(
3727
3735
  silkscreenLine,
3728
3736
  silkscreenRefText
3729
3737
  ),
3730
3738
  parameters
3731
3739
  };
3732
3740
  };
3733
- var getSmfCoords = (parameters) => {
3741
+ var getSmaCoords = (parameters) => {
3734
3742
  const { pn, p } = parameters;
3735
3743
  if (pn === 1) {
3736
3744
  return { x: -p / 2, y: 0 };
3737
- } else {
3738
- return { x: p / 2, y: 0 };
3739
3745
  }
3746
+ return { x: p / 2, y: 0 };
3740
3747
  };
3741
- var smfWithoutParsing = (parameters) => {
3748
+ var smaWithoutParsing = (parameters) => {
3742
3749
  const pads = [];
3743
3750
  for (let i = 1; i <= parameters.num_pins; i++) {
3744
- const { x, y } = getSmfCoords({
3751
+ const { x, y } = getSmaCoords({
3745
3752
  pn: i,
3746
3753
  p: Number.parseFloat(parameters.p)
3747
3754
  });
@@ -3758,23 +3765,23 @@ var smfWithoutParsing = (parameters) => {
3758
3765
  return pads;
3759
3766
  };
3760
3767
 
3761
- // src/fn/smb.ts
3768
+ // src/fn/smf.ts
3762
3769
  import { z as z36 } from "zod";
3763
3770
  import { length as length29 } from "circuit-json";
3764
- var smb_def = z36.object({
3771
+ var smf_def = z36.object({
3765
3772
  fn: z36.string(),
3766
3773
  num_pins: z36.literal(2).default(2),
3767
- w: z36.string().default("7.30mm"),
3768
- h: z36.string().default("4.40mm"),
3769
- pl: z36.string().default("2.50mm"),
3770
- pw: z36.string().default("2.30mm"),
3771
- p: z36.string().default("4.30mm")
3774
+ w: z36.string().default("4.80mm"),
3775
+ h: z36.string().default("2.10mm"),
3776
+ pl: z36.string().default("1.30mm"),
3777
+ pw: z36.string().default("1.40mm"),
3778
+ p: z36.string().default("2.9mm")
3772
3779
  });
3773
- var smb = (raw_params) => {
3774
- const parameters = smb_def.parse(raw_params);
3780
+ var smf = (raw_params) => {
3781
+ const parameters = smf_def.parse(raw_params);
3775
3782
  const silkscreenRefText = silkscreenRef(
3776
3783
  0,
3777
- length29.parse(parameters.h) / 2 + 0.5,
3784
+ length29.parse(parameters.h) - 0.5,
3778
3785
  0.3
3779
3786
  );
3780
3787
  const silkscreenLine = {
@@ -3787,11 +3794,11 @@ var smb = (raw_params) => {
3787
3794
  y: length29.parse(parameters.h) / 2
3788
3795
  },
3789
3796
  {
3790
- x: -length29.parse(parameters.w) / 2 - 0.1,
3797
+ x: -length29.parse(parameters.w) / 2,
3791
3798
  y: length29.parse(parameters.h) / 2
3792
3799
  },
3793
3800
  {
3794
- x: -length29.parse(parameters.w) / 2 - 0.1,
3801
+ x: -length29.parse(parameters.w) / 2,
3795
3802
  y: -length29.parse(parameters.h) / 2
3796
3803
  },
3797
3804
  {
@@ -3802,6 +3809,86 @@ var smb = (raw_params) => {
3802
3809
  stroke_width: 0.1,
3803
3810
  pcb_silkscreen_path_id: ""
3804
3811
  };
3812
+ return {
3813
+ circuitJson: smfWithoutParsing(parameters).concat(
3814
+ silkscreenLine,
3815
+ silkscreenRefText
3816
+ ),
3817
+ parameters
3818
+ };
3819
+ };
3820
+ var getSmfCoords = (parameters) => {
3821
+ const { pn, p } = parameters;
3822
+ if (pn === 1) {
3823
+ return { x: -p / 2, y: 0 };
3824
+ } else {
3825
+ return { x: p / 2, y: 0 };
3826
+ }
3827
+ };
3828
+ var smfWithoutParsing = (parameters) => {
3829
+ const pads = [];
3830
+ for (let i = 1; i <= parameters.num_pins; i++) {
3831
+ const { x, y } = getSmfCoords({
3832
+ pn: i,
3833
+ p: Number.parseFloat(parameters.p)
3834
+ });
3835
+ pads.push(
3836
+ rectpad(
3837
+ i,
3838
+ x,
3839
+ y,
3840
+ Number.parseFloat(parameters.pl),
3841
+ Number.parseFloat(parameters.pw)
3842
+ )
3843
+ );
3844
+ }
3845
+ return pads;
3846
+ };
3847
+
3848
+ // src/fn/smb.ts
3849
+ import { z as z37 } from "zod";
3850
+ import { length as length30 } from "circuit-json";
3851
+ var smb_def = z37.object({
3852
+ fn: z37.string(),
3853
+ num_pins: z37.literal(2).default(2),
3854
+ w: z37.string().default("7.30mm"),
3855
+ h: z37.string().default("4.40mm"),
3856
+ pl: z37.string().default("2.50mm"),
3857
+ pw: z37.string().default("2.30mm"),
3858
+ p: z37.string().default("4.30mm")
3859
+ });
3860
+ var smb = (raw_params) => {
3861
+ const parameters = smb_def.parse(raw_params);
3862
+ const silkscreenRefText = silkscreenRef(
3863
+ 0,
3864
+ length30.parse(parameters.h) / 2 + 0.5,
3865
+ 0.3
3866
+ );
3867
+ const silkscreenLine = {
3868
+ type: "pcb_silkscreen_path",
3869
+ layer: "top",
3870
+ pcb_component_id: "",
3871
+ route: [
3872
+ {
3873
+ x: length30.parse(parameters.p) / 2,
3874
+ y: length30.parse(parameters.h) / 2
3875
+ },
3876
+ {
3877
+ x: -length30.parse(parameters.w) / 2 - 0.1,
3878
+ y: length30.parse(parameters.h) / 2
3879
+ },
3880
+ {
3881
+ x: -length30.parse(parameters.w) / 2 - 0.1,
3882
+ y: -length30.parse(parameters.h) / 2
3883
+ },
3884
+ {
3885
+ x: length30.parse(parameters.p) / 2,
3886
+ y: -length30.parse(parameters.h) / 2
3887
+ }
3888
+ ],
3889
+ stroke_width: 0.1,
3890
+ pcb_silkscreen_path_id: ""
3891
+ };
3805
3892
  return {
3806
3893
  circuitJson: smbWithoutParsing(parameters).concat(
3807
3894
  silkscreenLine,
@@ -3838,6 +3925,182 @@ var smbWithoutParsing = (parameters) => {
3838
3925
  return pads;
3839
3926
  };
3840
3927
 
3928
+ // src/fn/vssop8.ts
3929
+ import { z as z38 } from "zod";
3930
+ import { length as length31 } from "circuit-json";
3931
+ var vssop8_def = z38.object({
3932
+ fn: z38.string(),
3933
+ num_pins: z38.literal(8).default(8),
3934
+ w: z38.string().default("3.06mm"),
3935
+ h: z38.string().default("3.14mm"),
3936
+ p: z38.string().default("0.65mm"),
3937
+ pl: z38.string().default("1.6mm"),
3938
+ pw: z38.string().default("0.5mm")
3939
+ });
3940
+ var vssop8 = (raw_params) => {
3941
+ const parameters = vssop8_def.parse(raw_params);
3942
+ const pad_spacing = length31.parse(parameters.p);
3943
+ const silkscreenRefText = silkscreenRef(
3944
+ 0,
3945
+ length31.parse(parameters.h) / 2 + 0.5,
3946
+ 0.3
3947
+ );
3948
+ const silkscreenBoxWidth = length31.parse(parameters.w);
3949
+ const silkscreenBoxHeight = length31.parse(parameters.h);
3950
+ const silkscreenTopLine = {
3951
+ type: "pcb_silkscreen_path",
3952
+ layer: "top",
3953
+ pcb_component_id: "",
3954
+ route: [
3955
+ { x: -silkscreenBoxWidth / 2, y: silkscreenBoxHeight / 2 },
3956
+ { x: silkscreenBoxWidth / 2, y: silkscreenBoxHeight / 2 }
3957
+ ],
3958
+ stroke_width: 0.05,
3959
+ pcb_silkscreen_path_id: ""
3960
+ };
3961
+ const silkscreenBottomLine = {
3962
+ type: "pcb_silkscreen_path",
3963
+ layer: "top",
3964
+ pcb_component_id: "",
3965
+ route: [
3966
+ { x: -silkscreenBoxWidth / 2, y: -silkscreenBoxHeight / 2 },
3967
+ { x: silkscreenBoxWidth / 2, y: -silkscreenBoxHeight / 2 }
3968
+ ],
3969
+ stroke_width: 0.05,
3970
+ pcb_silkscreen_path_id: ""
3971
+ };
3972
+ const pin1Position = getVssop8PadCoord({ pn: 1, pad_spacing });
3973
+ const pin1MarkerPosition = {
3974
+ x: pin1Position.x - 0.8,
3975
+ y: pin1Position.y
3976
+ };
3977
+ const pin1Marking = {
3978
+ type: "pcb_silkscreen_path",
3979
+ layer: "top",
3980
+ pcb_component_id: "pin_marker_1",
3981
+ route: [
3982
+ { x: pin1MarkerPosition.x - 0.4, y: pin1MarkerPosition.y },
3983
+ { x: pin1MarkerPosition.x - 0.7, y: pin1MarkerPosition.y + 0.3 },
3984
+ { x: pin1MarkerPosition.x - 0.7, y: pin1MarkerPosition.y - 0.3 },
3985
+ { x: pin1MarkerPosition.x - 0.4, y: pin1MarkerPosition.y }
3986
+ ],
3987
+ stroke_width: 0.05,
3988
+ pcb_silkscreen_path_id: "pin_marker_1"
3989
+ };
3990
+ return {
3991
+ circuitJson: getVssop8Pads(parameters, pad_spacing).concat(
3992
+ silkscreenTopLine,
3993
+ silkscreenBottomLine,
3994
+ silkscreenRefText,
3995
+ pin1Marking
3996
+ ),
3997
+ parameters
3998
+ };
3999
+ };
4000
+ var getVssop8PadCoord = (parameters) => {
4001
+ const { pn, pad_spacing } = parameters;
4002
+ const col = pn <= 4 ? -1 : 1;
4003
+ const row = 1.5 - (pn - 1) % 4;
4004
+ return {
4005
+ x: col * length31.parse("1.8mm"),
4006
+ y: row * pad_spacing
4007
+ };
4008
+ };
4009
+ var getVssop8Pads = (parameters, pad_spacing) => {
4010
+ const pads = [];
4011
+ for (let i = 1; i <= parameters.num_pins; i++) {
4012
+ const { x, y } = getVssop8PadCoord({
4013
+ pn: i,
4014
+ pad_spacing
4015
+ });
4016
+ pads.push(
4017
+ rectpad(
4018
+ i,
4019
+ x,
4020
+ y,
4021
+ Number.parseFloat(parameters.pl),
4022
+ Number.parseFloat(parameters.pw)
4023
+ )
4024
+ );
4025
+ }
4026
+ return pads;
4027
+ };
4028
+
4029
+ // src/fn/smc.ts
4030
+ import { z as z39 } from "zod";
4031
+ import { length as length32 } from "circuit-json";
4032
+ var smc_def = z39.object({
4033
+ fn: z39.string(),
4034
+ num_pins: z39.literal(2).default(2),
4035
+ w: z39.string().default("10.70mm"),
4036
+ h: z39.string().default("6.60mm"),
4037
+ pl: z39.string().default("3.30mm"),
4038
+ pw: z39.string().default("2.50mm"),
4039
+ p: z39.string().default("6.80mm")
4040
+ });
4041
+ var smc = (raw_params) => {
4042
+ const parameters = smc_def.parse(raw_params);
4043
+ const silkscreenRefText = silkscreenRef(0, 3, 0.3);
4044
+ const silkscreenLine = {
4045
+ type: "pcb_silkscreen_path",
4046
+ layer: "top",
4047
+ pcb_component_id: "",
4048
+ route: [
4049
+ {
4050
+ x: length32.parse(parameters.p) / 2,
4051
+ y: length32.parse(parameters.h) / 2 - 0.8
4052
+ },
4053
+ {
4054
+ x: -length32.parse(parameters.w) / 2 - 0.8,
4055
+ y: length32.parse(parameters.h) / 2 - 0.8
4056
+ },
4057
+ {
4058
+ x: -length32.parse(parameters.w) / 2 - 0.8,
4059
+ y: -length32.parse(parameters.h) / 2 + 0.8
4060
+ },
4061
+ {
4062
+ x: length32.parse(parameters.p) / 2,
4063
+ y: -length32.parse(parameters.h) / 2 + 0.8
4064
+ }
4065
+ ],
4066
+ stroke_width: 0.1,
4067
+ pcb_silkscreen_path_id: ""
4068
+ };
4069
+ return {
4070
+ circuitJson: smcWithoutParsing(parameters).concat(
4071
+ silkscreenLine,
4072
+ silkscreenRefText
4073
+ ),
4074
+ parameters
4075
+ };
4076
+ };
4077
+ var getSmcCoords = (parameters) => {
4078
+ const { pn, p } = parameters;
4079
+ if (pn === 1) {
4080
+ return { x: -p / 2, y: 0 };
4081
+ }
4082
+ return { x: p / 2, y: 0 };
4083
+ };
4084
+ var smcWithoutParsing = (parameters) => {
4085
+ const pads = [];
4086
+ for (let i = 1; i <= parameters.num_pins; i++) {
4087
+ const { x, y } = getSmcCoords({
4088
+ pn: i,
4089
+ p: Number.parseFloat(parameters.p)
4090
+ });
4091
+ pads.push(
4092
+ rectpad(
4093
+ i,
4094
+ x,
4095
+ y,
4096
+ Number.parseFloat(parameters.pl),
4097
+ Number.parseFloat(parameters.pw)
4098
+ )
4099
+ );
4100
+ }
4101
+ return pads;
4102
+ };
4103
+
3841
4104
  // src/helpers/is-not-null.ts
3842
4105
  function isNotNull(value) {
3843
4106
  return value !== null;
@@ -3846,9 +4109,8 @@ function isNotNull(value) {
3846
4109
  // src/footprinter.ts
3847
4110
  var string = (def) => {
3848
4111
  let fp2 = footprinter();
3849
- if ((def.length === 4 || def.length === 5) && /^\d+$/.test(def))
3850
- def = `res${def}`;
3851
- const def_parts = def.split("_").map((s) => {
4112
+ const modifiedDef = (def.length === 4 || def.length === 5) && /^\d+$/.test(def) ? `res${def}` : def;
4113
+ const def_parts = modifiedDef.split("_").map((s) => {
3852
4114
  const m = s.match(/([a-z]+)([\(\d\.\+\?].*)?/);
3853
4115
  const [_, fn, v] = m ?? [];
3854
4116
  if (v?.includes("?"))