@tscircuit/footprinter 0.0.143 → 0.0.145

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
@@ -1043,6 +1043,8 @@ type Footprinter = {
1043
1043
  to92: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "od" | "inline">;
1044
1044
  to92s: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "od">;
1045
1045
  sot223: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1046
+ msop: (num_pins?: number) => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1047
+ sot23w: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1046
1048
  pushbutton: () => FootprinterParamsBuilder<"tllabel" | "trlabel" | "bllabel" | "brlabel">;
1047
1049
  stampboard: () => FootprinterParamsBuilder<"w" | "h" | "left" | "right" | "top" | "bottom" | "p" | "pw" | "pl" | "innerhole" | "innerholeedgedistance">;
1048
1050
  stampreceiver: () => FootprinterParamsBuilder<"w" | "h" | "left" | "right" | "top" | "bottom" | "p" | "pw" | "pl" | "innerhole" | "innerholeedgedistance">;
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ __export(fn_exports, {
24
24
  mlp: () => mlp,
25
25
  ms012: () => ms012,
26
26
  ms013: () => ms013,
27
+ msop: () => msop,
27
28
  pad: () => pad,
28
29
  pinrow: () => pinrow,
29
30
  pushbutton: () => pushbutton,
@@ -51,6 +52,7 @@ __export(fn_exports, {
51
52
  sop8: () => sop8,
52
53
  sot223: () => sot223,
53
54
  sot23: () => sot23,
55
+ sot23w: () => sot23w,
54
56
  sot363: () => sot363,
55
57
  sot563: () => sot563,
56
58
  sot723: () => sot723,
@@ -3536,12 +3538,12 @@ var sot89_3 = (parameters) => {
3536
3538
  const pads = [];
3537
3539
  const padGap = Number.parseFloat(parameters.p);
3538
3540
  const padWidth = Number.parseFloat(parameters.pw);
3539
- const length37 = Number.parseFloat(parameters.w);
3541
+ const length38 = Number.parseFloat(parameters.w);
3540
3542
  const padHeight = Number.parseFloat(parameters.pl);
3541
3543
  pads.push(
3542
- rectpad(1, -length37 / 2, padGap, padHeight, padWidth),
3543
- rectpad(2, -length37 / 2 + (1.5 - 1.3) / 2, 0, 1.5, padWidth),
3544
- rectpad(3, -length37 / 2, -padGap, padHeight, padWidth)
3544
+ rectpad(1, -length38 / 2, padGap, padHeight, padWidth),
3545
+ rectpad(2, -length38 / 2 + (1.5 - 1.3) / 2, 0, 1.5, padWidth),
3546
+ rectpad(3, -length38 / 2, -padGap, padHeight, padWidth)
3545
3547
  );
3546
3548
  const silkscreenRefText = silkscreenRef(0, 0, 0.3);
3547
3549
  const width = Number.parseFloat(parameters.w) / 2 - 1;
@@ -3581,7 +3583,7 @@ var sot89_5 = (parameters) => {
3581
3583
  const pads = [];
3582
3584
  const padGap = Number.parseFloat(parameters.p);
3583
3585
  const padWidth = Number.parseFloat(parameters.pw);
3584
- const length37 = Number.parseFloat(parameters.w);
3586
+ const length38 = Number.parseFloat(parameters.w);
3585
3587
  pads.push(
3586
3588
  rectpad(1, -1.85, -1.5, 1.5, 0.7),
3587
3589
  rectpad(2, -1.85, 1.5, 1.5, 0.7),
@@ -4725,18 +4727,115 @@ var sot223_6 = (parameters) => {
4725
4727
  return [...pads, silkscreenPath1, silkscreenPath2, silkscreenRefText];
4726
4728
  };
4727
4729
 
4728
- // src/fn/to92s.ts
4730
+ // src/fn/sot23w.ts
4729
4731
  import { z as z43 } from "zod";
4730
- var to92s_def = z43.object({
4732
+ var sot23w_def = z43.object({
4731
4733
  fn: z43.string(),
4732
- num_pins: z43.union([z43.literal(3), z43.literal(2)]).default(3),
4733
- p: z43.string().default("1.27mm"),
4734
- id: z43.string().default("0.72mm"),
4735
- od: z43.string().default("0.95mm"),
4736
- w: z43.string().default("2.5mm"),
4737
- h: z43.string().default("4.2mm"),
4734
+ num_pins: z43.number().default(3),
4735
+ w: z43.string().default("3.40mm"),
4736
+ h: z43.string().default("3.30mm"),
4737
+ pl: z43.string().default("1mm"),
4738
+ pw: z43.string().default("0.7mm"),
4739
+ p: z43.string().default("1.2mm"),
4738
4740
  string: z43.string().optional()
4739
4741
  });
4742
+ var sot23w = (raw_params) => {
4743
+ const match = raw_params.string?.match(/^sot23w_(\d+)/);
4744
+ const numPins = match ? Number.parseInt(match[1], 3) : 3;
4745
+ const parameters = sot23w_def.parse({
4746
+ ...raw_params,
4747
+ num_pins: numPins
4748
+ });
4749
+ if (parameters.num_pins === 3) {
4750
+ return {
4751
+ circuitJson: sot23w_3(parameters),
4752
+ parameters
4753
+ };
4754
+ }
4755
+ throw new Error("Invalid number of pins");
4756
+ };
4757
+ var getCcwSot23wCoords = (parameters) => {
4758
+ const { pn, w, h, pl, p } = parameters;
4759
+ if (pn === 1) {
4760
+ return { x: -p, y: 0.95 };
4761
+ }
4762
+ if (pn === 2) {
4763
+ return { x: -p, y: -0.95 };
4764
+ }
4765
+ return { x: p, y: 0 };
4766
+ };
4767
+ var sot23w_3 = (parameters) => {
4768
+ const pads = [];
4769
+ for (let i = 0; i < parameters.num_pins; i++) {
4770
+ const { x, y } = getCcwSot23wCoords({
4771
+ num_pins: parameters.num_pins,
4772
+ pn: i + 1,
4773
+ w: Number.parseFloat(parameters.w),
4774
+ h: Number.parseFloat(parameters.h),
4775
+ pl: Number.parseFloat(parameters.pl),
4776
+ p: Number.parseFloat(parameters.p)
4777
+ });
4778
+ pads.push(
4779
+ rectpad(
4780
+ i + 1,
4781
+ x,
4782
+ y,
4783
+ Number.parseFloat(parameters.pl),
4784
+ Number.parseFloat(parameters.pw)
4785
+ )
4786
+ );
4787
+ }
4788
+ const silkscreenRefText = silkscreenRef(
4789
+ 0,
4790
+ Number.parseInt(parameters.h) / 2 + 1,
4791
+ 0.3
4792
+ );
4793
+ const width = Number.parseFloat(parameters.w) / 2 - 1;
4794
+ const height = Number.parseFloat(parameters.h) / 2;
4795
+ const silkscreenPath1 = {
4796
+ layer: "top",
4797
+ pcb_component_id: "",
4798
+ pcb_silkscreen_path_id: "silkscreen_path_1",
4799
+ route: [
4800
+ { x: -width, y: height },
4801
+ { x: width + 0.3, y: height },
4802
+ { x: width + 0.3, y: height / 2 }
4803
+ ],
4804
+ type: "pcb_silkscreen_path",
4805
+ stroke_width: 0.1
4806
+ };
4807
+ const silkscreenPath2 = {
4808
+ layer: "top",
4809
+ pcb_component_id: "",
4810
+ pcb_silkscreen_path_id: "silkscreen_path_2",
4811
+ route: [
4812
+ { x: -width, y: -height },
4813
+ { x: width + 0.3, y: -height },
4814
+ { x: width + 0.3, y: -height / 2 }
4815
+ ],
4816
+ type: "pcb_silkscreen_path",
4817
+ stroke_width: 0.1
4818
+ };
4819
+ return [
4820
+ ...pads,
4821
+ silkscreenPath1,
4822
+ silkscreenPath2,
4823
+ silkscreenRefText
4824
+ ];
4825
+ };
4826
+
4827
+ // src/fn/to92s.ts
4828
+ import { z as z44 } from "zod";
4829
+ var to92s_def = z44.object({
4830
+ fn: z44.string(),
4831
+ num_pins: z44.union([z44.literal(3), z44.literal(2)]).default(3),
4832
+ p: z44.string().default("1.27mm"),
4833
+ id: z44.string().default("0.72mm"),
4834
+ od: z44.string().default("0.95mm"),
4835
+ w: z44.string().default("2.5mm"),
4836
+ h: z44.string().default("4.2mm"),
4837
+ string: z44.string().optional()
4838
+ });
4740
4839
  var to92s_3 = (parameters) => {
4741
4840
  const { p, id, od, w, h } = parameters;
4742
4841
  const holeY = Number.parseFloat(h) / 2;
@@ -4804,7 +4903,7 @@ var to92s = (raw_params) => {
4804
4903
  import {
4805
4904
  length as length35
4806
4905
  } from "circuit-json";
4807
- import { z as z44 } from "zod";
4906
+ import { z as z45 } from "zod";
4808
4907
 
4809
4908
  // src/helpers/platedHoleWithRectPad.ts
4810
4909
  import { mm as mm4 } from "@tscircuit/mm";
@@ -4827,8 +4926,8 @@ var platedHoleWithRectPad = (pn, x, y, holeDiameter, rectPadWidth, rectPadHeight
4827
4926
  };
4828
4927
 
4829
4928
  // src/fn/jst.ts
4830
- var jst_def = z44.object({
4831
- fn: z44.string(),
4929
+ var jst_def = z45.object({
4930
+ fn: z45.string(),
4832
4931
  p: length35.optional().default("2.2mm"),
4833
4932
  id: length35.optional().default("0.70mm"),
4834
4933
  pw: length35.optional().default("1.20mm"),
@@ -4870,16 +4969,16 @@ var jst = (raw_params) => {
4870
4969
  };
4871
4970
 
4872
4971
  // src/fn/sod110.ts
4873
- import { z as z45 } from "zod";
4972
+ import { z as z46 } from "zod";
4874
4973
  import { length as length36 } from "circuit-json";
4875
- var sod_def12 = z45.object({
4876
- fn: z45.string(),
4877
- num_pins: z45.literal(2).default(2),
4878
- w: z45.string().default("3.30mm"),
4879
- h: z45.string().default("1.70mm"),
4880
- pl: z45.string().default("0.80mm"),
4881
- pw: z45.string().default("1mm"),
4882
- p: z45.string().default("1.90mm")
4974
+ var sod_def12 = z46.object({
4975
+ fn: z46.string(),
4976
+ num_pins: z46.literal(2).default(2),
4977
+ w: z46.string().default("3.30mm"),
4978
+ h: z46.string().default("1.70mm"),
4979
+ pl: z46.string().default("0.80mm"),
4980
+ pw: z46.string().default("1mm"),
4981
+ p: z46.string().default("1.90mm")
4883
4982
  });
4884
4983
  var sod110 = (raw_params) => {
4885
4984
  const parameters = sod_def12.parse(raw_params);
@@ -4948,6 +5047,142 @@ var sodWithoutParsing12 = (parameters) => {
4948
5047
  return pads;
4949
5048
  };
4950
5049
 
5050
+ // src/fn/msop.ts
5051
+ import { z as z47 } from "zod";
5052
+ import { length as length37 } from "circuit-json";
5053
+ var getDefaultValues = (num_pins) => {
5054
+ switch (num_pins) {
5055
+ case 10:
5056
+ return {
5057
+ w: "3.10mm",
5058
+ h: "3.32mm",
5059
+ p: "0.5mm",
5060
+ pl: "1.63mm",
5061
+ pw: "0.33mm"
5062
+ };
5063
+ case 12:
5064
+ return {
5065
+ w: "3mm",
5066
+ h: "4mm",
5067
+ p: "0.65mm",
5068
+ pl: "0.88mm",
5069
+ pw: "0.4mm"
5070
+ };
5071
+ case 16:
5072
+ return {
5073
+ w: "3.10mm",
5074
+ h: "4mm",
5075
+ p: "0.5mm",
5076
+ pl: "0.88mm",
5077
+ pw: "0.3mm"
5078
+ };
5079
+ default:
5080
+ return {
5081
+ w: "3.10mm",
5082
+ h: "3.32mm",
5083
+ p: "0.65mm",
5084
+ pl: "1.63mm",
5085
+ pw: "0.4mm"
5086
+ };
5087
+ }
5088
+ };
5089
+ var msop_def = z47.object({
5090
+ fn: z47.string(),
5091
+ num_pins: z47.union([z47.literal(8), z47.literal(10), z47.literal(12), z47.literal(16)]).default(8),
5092
+ w: z47.string().optional(),
5093
+ h: z47.string().optional(),
5094
+ p: z47.string().optional(),
5095
+ pl: z47.string().optional(),
5096
+ pw: z47.string().optional(),
5097
+ string: z47.string().optional()
5098
+ });
5099
+ var getMsopCoords = (pinCount, pn, w, p) => {
5100
+ const half = pinCount / 2;
5101
+ const rowIndex = (pn - 1) % half;
5102
+ const col = pn <= half ? -1 : 1;
5103
+ const row = (half - 1) / 2 - rowIndex;
5104
+ return {
5105
+ x: col * length37.parse("2mm"),
5106
+ y: row * p
5107
+ };
5108
+ };
5109
+ var msop = (raw_params) => {
5110
+ const parameters = msop_def.parse(raw_params);
5111
+ const defaults = getDefaultValues(parameters.num_pins);
5112
+ const w = length37.parse(parameters.w || defaults.w);
5113
+ const h = length37.parse(parameters.h || defaults.h);
5114
+ const p = length37.parse(parameters.p || defaults.p);
5115
+ const pl = length37.parse(parameters.pl || defaults.pl);
5116
+ const pw = length37.parse(parameters.pw || defaults.pw);
5117
+ const pads = [];
5118
+ for (let i = 0; i < parameters.num_pins; i++) {
5119
+ const { x, y } = getMsopCoords(parameters.num_pins, i + 1, w, p);
5120
+ pads.push(rectpad(i + 1, x, y, pl, pw));
5121
+ }
5122
+ const silkscreenBoxWidth = w;
5123
+ const silkscreenBoxHeight = h;
5124
+ const silkscreenTopLine = {
5125
+ type: "pcb_silkscreen_path",
5126
+ layer: "top",
5127
+ pcb_component_id: "",
5128
+ route: [
5129
+ { x: -silkscreenBoxWidth / 2, y: silkscreenBoxHeight / 2 },
5130
+ { x: silkscreenBoxWidth / 2, y: silkscreenBoxHeight / 2 }
5131
+ ],
5132
+ stroke_width: 0.05,
5133
+ pcb_silkscreen_path_id: ""
5134
+ };
5135
+ const silkscreenBottomLine = {
5136
+ type: "pcb_silkscreen_path",
5137
+ layer: "top",
5138
+ pcb_component_id: "",
5139
+ route: [
5140
+ { x: -silkscreenBoxWidth / 2, y: -silkscreenBoxHeight / 2 },
5141
+ { x: silkscreenBoxWidth / 2, y: -silkscreenBoxHeight / 2 }
5142
+ ],
5143
+ stroke_width: 0.05,
5144
+ pcb_silkscreen_path_id: ""
5145
+ };
5146
+ const pin1Position = getMsopCoords(
5147
+ parameters.num_pins,
5148
+ 1,
5149
+ silkscreenBoxWidth,
5150
+ p
5151
+ );
5152
+ const pin1MarkerPosition = {
5153
+ x: pin1Position.x - 0.8,
5154
+ y: pin1Position.y
5155
+ };
5156
+ const pin1Marking = {
5157
+ type: "pcb_silkscreen_path",
5158
+ layer: "top",
5159
+ pcb_component_id: "pin_marker_1",
5160
+ route: [
5161
+ { x: pin1MarkerPosition.x - 0.4, y: pin1MarkerPosition.y },
5162
+ { x: pin1MarkerPosition.x - 0.7, y: pin1MarkerPosition.y + 0.3 },
5163
+ { x: pin1MarkerPosition.x - 0.7, y: pin1MarkerPosition.y - 0.3 },
5164
+ { x: pin1MarkerPosition.x - 0.4, y: pin1MarkerPosition.y }
5165
+ ],
5166
+ stroke_width: 0.05,
5167
+ pcb_silkscreen_path_id: "pin_marker_1"
5168
+ };
5169
+ const silkscreenRefText = silkscreenRef(
5170
+ 0,
5171
+ silkscreenBoxHeight / 2 + 0.5,
5172
+ 0.3
5173
+ );
5174
+ return {
5175
+ circuitJson: [
5176
+ ...pads,
5177
+ silkscreenTopLine,
5178
+ silkscreenBottomLine,
5179
+ silkscreenRefText,
5180
+ pin1Marking
5181
+ ],
5182
+ parameters
5183
+ };
5184
+ };
5185
+
4951
5186
  // src/helpers/is-not-null.ts
4952
5187
  function isNotNull(value) {
4953
5188
  return value !== null;