@tscircuit/footprinter 0.0.178 → 0.0.180

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
@@ -192,7 +192,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
192
192
  p?: string | number | undefined;
193
193
  id?: string | number | undefined;
194
194
  od?: string | number | undefined;
195
- }>, z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
195
+ }>, z.ZodEffects<z.ZodObject<{
196
196
  fn: z.ZodString;
197
197
  cc: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
198
198
  ccw: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
@@ -217,7 +217,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
217
217
  y: number;
218
218
  }>>]>>;
219
219
  legsoutside: z.ZodDefault<z.ZodBoolean>;
220
- }, {}>, "strip", z.ZodTypeAny, {
220
+ }, "strip", z.ZodTypeAny, {
221
221
  fn: string;
222
222
  num_pins: number;
223
223
  p: number;
@@ -469,7 +469,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
469
469
  pinlabelverticallyinverted?: boolean | undefined;
470
470
  nosquareplating?: boolean | undefined;
471
471
  doublesidedpinlabel?: boolean | undefined;
472
- }>, z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
472
+ }>, z.ZodEffects<z.ZodObject<{
473
473
  fn: z.ZodString;
474
474
  cc: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
475
475
  ccw: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
@@ -494,7 +494,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
494
494
  y: number;
495
495
  }>>]>>;
496
496
  legsoutside: z.ZodDefault<z.ZodBoolean>;
497
- }, {}>, "strip", z.ZodTypeAny, {
497
+ }, "strip", z.ZodTypeAny, {
498
498
  fn: string;
499
499
  num_pins: number;
500
500
  p: number;
@@ -1067,6 +1067,7 @@ type Footprinter = {
1067
1067
  sot563: () => FootprinterParamsBuilder<"w" | "p" | "pl" | "pw">;
1068
1068
  sot723: () => FootprinterParamsBuilder<"w" | "h" | "pl" | "pw">;
1069
1069
  sot23: () => FootprinterParamsBuilder<"w" | "h" | "pl" | "pw">;
1070
+ sot: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1070
1071
  sot323: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1071
1072
  sot89: () => FootprinterParamsBuilder<"w" | "p" | "pl" | "pw" | "h">;
1072
1073
  sod323w: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
package/dist/index.js CHANGED
@@ -60,6 +60,7 @@ __export(fn_exports, {
60
60
  solderjumper: () => solderjumper,
61
61
  son: () => son,
62
62
  sop8: () => sop8,
63
+ sot: () => sot,
63
64
  sot223: () => sot223,
64
65
  sot23: () => sot23,
65
66
  sot23w: () => sot23w,
@@ -387,16 +388,11 @@ var deriveGFromW = (w) => 0.59 * w - 0.31;
387
388
  var deriveCFromW = (w) => -0.01 * w ** 2 + 0.94 * w + 0.03;
388
389
  var passive = (params) => {
389
390
  let { tht, p, pw, ph, metric, imperial, w, h } = params;
390
- if (typeof w === "string")
391
- w = mm2(w);
392
- if (typeof h === "string")
393
- h = mm2(h);
394
- if (typeof p === "string")
395
- p = mm2(p);
396
- if (typeof pw === "string")
397
- pw = mm2(pw);
398
- if (typeof ph === "string")
399
- ph = mm2(ph);
391
+ if (typeof w === "string") w = mm2(w);
392
+ if (typeof h === "string") h = mm2(h);
393
+ if (typeof p === "string") p = mm2(p);
394
+ if (typeof pw === "string") pw = mm2(pw);
395
+ if (typeof ph === "string") ph = mm2(ph);
400
396
  if (h > w) {
401
397
  throw new Error(
402
398
  "height cannot be greater than width (rotated footprint not yet implemented)"
@@ -426,10 +422,8 @@ var passive = (params) => {
426
422
  pw = (sz.Z_mm_min - sz.G_mm_min) / 2;
427
423
  ph = (sz.Z_mm_min - sz.G_mm_min) / 2;
428
424
  }
429
- if (pw === void 0)
430
- throw new Error("could not infer pad width");
431
- if (ph === void 0)
432
- throw new Error("could not infer pad width");
425
+ if (pw === void 0) throw new Error("could not infer pad width");
426
+ if (ph === void 0) throw new Error("could not infer pad width");
433
427
  const silkscreenLine = {
434
428
  type: "pcb_silkscreen_path",
435
429
  layer: "top",
@@ -506,8 +500,7 @@ var dim2d = z3.string().transform((a) => {
506
500
  // src/helpers/zod/function-call.ts
507
501
  import { z as z4 } from "zod";
508
502
  var function_call = z4.string().or(z4.array(z4.any())).transform((a) => {
509
- if (Array.isArray(a))
510
- return a;
503
+ if (Array.isArray(a)) return a;
511
504
  if (a.startsWith("(") && a.endsWith(")")) {
512
505
  a = a.slice(1, -1);
513
506
  }
@@ -535,27 +528,20 @@ var bga_def = z5.object({
535
528
  missing: function_call.default([])
536
529
  }).transform((a) => {
537
530
  let origin = "tl";
538
- if (a.blorigin)
539
- origin = "bl";
540
- if (a.trorigin)
541
- origin = "tr";
542
- if (a.brorigin)
543
- origin = "br";
531
+ if (a.blorigin) origin = "bl";
532
+ if (a.trorigin) origin = "tr";
533
+ if (a.brorigin) origin = "br";
544
534
  if (!a.grid) {
545
535
  const largest_square = Math.ceil(Math.sqrt(a.num_pins));
546
536
  a.grid = { x: largest_square, y: largest_square };
547
537
  }
548
538
  if (a.missing) {
549
539
  a.missing = a.missing.map((s) => {
550
- if (typeof s === "number")
551
- return s;
552
- if (s === "center")
553
- return "center";
554
- if (s === "topleft")
555
- return "topleft";
540
+ if (typeof s === "number") return s;
541
+ if (s === "center") return "center";
542
+ if (s === "topleft") return "topleft";
556
543
  const m = s.match(/([A-Z]+)(\d+)/);
557
- if (!m)
558
- return s;
544
+ if (!m) return s;
559
545
  const Y = ALPHABET.indexOf(m[1]);
560
546
  const X = Number.parseInt(m[2]) - 1;
561
547
  return Y * a.grid.x + X + 1;
@@ -1147,10 +1133,8 @@ var qfp = (raw_params) => {
1147
1133
  raw_params.p = 0.8;
1148
1134
  break;
1149
1135
  case 52:
1150
- if (raw_params.w === 14)
1151
- raw_params.p = 1;
1152
- else
1153
- raw_params.p = 0.65;
1136
+ if (raw_params.w === 14) raw_params.p = 1;
1137
+ else raw_params.p = 0.65;
1154
1138
  break;
1155
1139
  case 208:
1156
1140
  raw_params.p = 0.5;
@@ -1179,10 +1163,8 @@ var qfp = (raw_params) => {
1179
1163
  raw_params.pw = 0.5;
1180
1164
  break;
1181
1165
  case 52:
1182
- if (raw_params.w === 14)
1183
- raw_params.pw = 0.45;
1184
- else
1185
- raw_params.pw = 0.55;
1166
+ if (raw_params.w === 14) raw_params.pw = 0.45;
1167
+ else raw_params.pw = 0.55;
1186
1168
  break;
1187
1169
  case 208:
1188
1170
  raw_params.pw = 0.3;
@@ -1583,16 +1565,12 @@ var silkscreenPin = ({
1583
1565
  }
1584
1566
  let anchor_alignment = "center";
1585
1567
  if (textalign === "left") {
1586
- if (verticallyinverted)
1587
- anchor_alignment = "center_right";
1588
- else
1589
- anchor_alignment = "center_left";
1568
+ if (verticallyinverted) anchor_alignment = "center_right";
1569
+ else anchor_alignment = "center_left";
1590
1570
  }
1591
1571
  if (textalign === "right") {
1592
- if (verticallyinverted)
1593
- anchor_alignment = "center_left";
1594
- else
1595
- anchor_alignment = "center_right";
1572
+ if (verticallyinverted) anchor_alignment = "center_left";
1573
+ else anchor_alignment = "center_right";
1596
1574
  }
1597
1575
  if (layer === "bottom") {
1598
1576
  if (anchor_alignment === "center_left") {
@@ -1697,10 +1675,8 @@ var pinrow = (raw_params) => {
1697
1675
  doublesidedpinlabel
1698
1676
  } = parameters;
1699
1677
  let pinlabelTextAlign = "center";
1700
- if (pinlabeltextalignleft)
1701
- pinlabelTextAlign = "left";
1702
- else if (pinlabeltextalignright)
1703
- pinlabelTextAlign = "right";
1678
+ if (pinlabeltextalignleft) pinlabelTextAlign = "left";
1679
+ else if (pinlabeltextalignright) pinlabelTextAlign = "right";
1704
1680
  const holes = [];
1705
1681
  const numPinsPerRow = Math.ceil(num_pins / rows);
1706
1682
  const ySpacing = -p;
@@ -1777,8 +1753,7 @@ var pinrow = (raw_params) => {
1777
1753
  const pinNumber = i + 1;
1778
1754
  const xoff = xStart + i * p;
1779
1755
  const posKey = `${xoff},${0}`;
1780
- if (usedPositions.has(posKey))
1781
- throw new Error(`Overlap at ${posKey}`);
1756
+ if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
1782
1757
  usedPositions.add(posKey);
1783
1758
  addPin(pinNumber, xoff, 0);
1784
1759
  }
@@ -1790,8 +1765,7 @@ var pinrow = (raw_params) => {
1790
1765
  const xoff = xStart + col * p;
1791
1766
  const yoff = row * ySpacing;
1792
1767
  const posKey = `${xoff},${yoff}`;
1793
- if (usedPositions.has(posKey))
1794
- throw new Error(`Overlap at ${posKey}`);
1768
+ if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
1795
1769
  usedPositions.add(posKey);
1796
1770
  addPin(currentPin++, xoff, yoff);
1797
1771
  }
@@ -1808,8 +1782,7 @@ var pinrow = (raw_params) => {
1808
1782
  const xoff = xStart + left * p;
1809
1783
  const yoff = row * ySpacing;
1810
1784
  const posKey = `${xoff},${yoff}`;
1811
- if (usedPositions.has(posKey))
1812
- throw new Error(`Overlap at ${posKey}`);
1785
+ if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
1813
1786
  usedPositions.add(posKey);
1814
1787
  addPin(currentPin++, xoff, yoff);
1815
1788
  }
@@ -1818,8 +1791,7 @@ var pinrow = (raw_params) => {
1818
1791
  const xoff = xStart + col * p;
1819
1792
  const yoff = bottom * ySpacing;
1820
1793
  const posKey = `${xoff},${yoff}`;
1821
- if (usedPositions.has(posKey))
1822
- throw new Error(`Overlap at ${posKey}`);
1794
+ if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
1823
1795
  usedPositions.add(posKey);
1824
1796
  addPin(currentPin++, xoff, yoff);
1825
1797
  }
@@ -1829,8 +1801,7 @@ var pinrow = (raw_params) => {
1829
1801
  const xoff = xStart + right * p;
1830
1802
  const yoff = row * ySpacing;
1831
1803
  const posKey = `${xoff},${yoff}`;
1832
- if (usedPositions.has(posKey))
1833
- throw new Error(`Overlap at ${posKey}`);
1804
+ if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
1834
1805
  usedPositions.add(posKey);
1835
1806
  addPin(currentPin++, xoff, yoff);
1836
1807
  }
@@ -1841,8 +1812,7 @@ var pinrow = (raw_params) => {
1841
1812
  const xoff = xStart + col * p;
1842
1813
  const yoff = top * ySpacing;
1843
1814
  const posKey = `${xoff},${yoff}`;
1844
- if (usedPositions.has(posKey))
1845
- throw new Error(`Overlap at ${posKey}`);
1815
+ if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
1846
1816
  usedPositions.add(posKey);
1847
1817
  addPin(currentPin++, xoff, yoff);
1848
1818
  }
@@ -6657,23 +6627,15 @@ var platedhole_def = z58.object({
6657
6627
  squarepad: z58.boolean().optional().default(false)
6658
6628
  }).transform((v) => {
6659
6629
  let holeD;
6660
- if (v.d !== void 0)
6661
- holeD = mm6(v.d);
6662
- else if (v.hd !== void 0)
6663
- holeD = mm6(v.hd);
6664
- else if (v.r !== void 0)
6665
- holeD = mm6(v.r) * 2;
6666
- else if (v.hr !== void 0)
6667
- holeD = mm6(v.hr) * 2;
6668
- else
6669
- holeD = mm6("1mm");
6630
+ if (v.d !== void 0) holeD = mm6(v.d);
6631
+ else if (v.hd !== void 0) holeD = mm6(v.hd);
6632
+ else if (v.r !== void 0) holeD = mm6(v.r) * 2;
6633
+ else if (v.hr !== void 0) holeD = mm6(v.hr) * 2;
6634
+ else holeD = mm6("1mm");
6670
6635
  let padD;
6671
- if (v.pd !== void 0)
6672
- padD = mm6(v.pd);
6673
- else if (v.pr !== void 0)
6674
- padD = mm6(v.pr) * 2;
6675
- else
6676
- padD = holeD * (1.5 / 1);
6636
+ if (v.pd !== void 0) padD = mm6(v.pd);
6637
+ else if (v.pr !== void 0) padD = mm6(v.pr) * 2;
6638
+ else padD = holeD * (1.5 / 1);
6677
6639
  return {
6678
6640
  fn: v.fn,
6679
6641
  d: holeD,
@@ -6693,6 +6655,130 @@ var platedhole3 = (raw_params) => {
6693
6655
  };
6694
6656
  };
6695
6657
 
6658
+ // src/fn/sot.ts
6659
+ import { z as z59 } from "zod";
6660
+ var sot_def = z59.object({
6661
+ fn: z59.string(),
6662
+ num_pins: z59.literal(6).default(6),
6663
+ h: z59.string().default("1.6mm"),
6664
+ pl: z59.string().default("1mm"),
6665
+ pw: z59.string().default("0.7mm"),
6666
+ p: z59.string().default("0.95mm")
6667
+ });
6668
+ var sot = (raw_params) => {
6669
+ const parameters = sot_def.parse(raw_params);
6670
+ return {
6671
+ circuitJson: sotWithoutParsing(parameters),
6672
+ parameters
6673
+ };
6674
+ };
6675
+ var getCcwSotCoords = (parameters) => {
6676
+ const { p, h, pn } = parameters;
6677
+ if (pn === 1) {
6678
+ return { x: -h / 2 - 0.5, y: p };
6679
+ }
6680
+ if (pn === 2) {
6681
+ return { x: -h / 2 - 0.5, y: 0 };
6682
+ }
6683
+ if (pn === 3) {
6684
+ return { x: -h / 2 - 0.5, y: -p };
6685
+ }
6686
+ if (pn === 4) {
6687
+ return { x: h / 2 + 0.5, y: -p };
6688
+ }
6689
+ if (pn === 5) {
6690
+ return { x: h / 2 + 0.5, y: 0 };
6691
+ }
6692
+ if (pn === 6) {
6693
+ return { x: h / 2 + 0.5, y: p };
6694
+ }
6695
+ throw new Error("Invalid pin number");
6696
+ };
6697
+ var sotWithoutParsing = (parameters) => {
6698
+ const pads = [];
6699
+ for (let i = 1; i <= parameters.num_pins; i++) {
6700
+ const { x, y } = getCcwSotCoords({
6701
+ h: Number.parseFloat(parameters.h),
6702
+ p: Number.parseFloat(parameters.p),
6703
+ pn: i
6704
+ });
6705
+ pads.push(
6706
+ rectpad(
6707
+ i,
6708
+ x,
6709
+ y,
6710
+ Number.parseFloat(parameters.pl),
6711
+ Number.parseFloat(parameters.pw)
6712
+ )
6713
+ );
6714
+ }
6715
+ const width = parameters.num_pins / 2 * Number.parseFloat(parameters.p);
6716
+ const height = Number.parseFloat(parameters.h);
6717
+ const silkscreenPath1 = {
6718
+ layer: "top",
6719
+ pcb_component_id: "",
6720
+ pcb_silkscreen_path_id: "silkscreen_path_1",
6721
+ route: [
6722
+ { x: -width / 3, y: height / 2 + Number.parseFloat(parameters.p) / 1.3 },
6723
+ { x: width / 3, y: height / 2 + Number.parseFloat(parameters.p) / 1.3 }
6724
+ ],
6725
+ type: "pcb_silkscreen_path",
6726
+ stroke_width: 0.05
6727
+ };
6728
+ const silkscreenPath2 = {
6729
+ layer: "top",
6730
+ pcb_component_id: "",
6731
+ pcb_silkscreen_path_id: "silkscreen_path_2",
6732
+ route: [
6733
+ { x: -width / 3, y: -height / 2 - Number.parseFloat(parameters.p) / 1.3 },
6734
+ { x: width / 3, y: -height / 2 - Number.parseFloat(parameters.p) / 1.3 }
6735
+ ],
6736
+ type: "pcb_silkscreen_path",
6737
+ stroke_width: 0.05
6738
+ };
6739
+ const silkscreenRefText = silkscreenRef(0, height + 0.3, 0.3);
6740
+ const pin1Position = getCcwSotCoords({
6741
+ h: Number.parseFloat(parameters.h),
6742
+ p: Number.parseFloat(parameters.p),
6743
+ pn: 1
6744
+ });
6745
+ pin1Position.x = pin1Position.x - Number.parseFloat(parameters.pw) * 1.5;
6746
+ const triangleHeight = 0.7;
6747
+ const triangleWidth = 0.3;
6748
+ const pin1Indicator = {
6749
+ type: "pcb_silkscreen_path",
6750
+ layer: "top",
6751
+ pcb_component_id: "",
6752
+ pcb_silkscreen_path_id: "pin1_indicator",
6753
+ route: [
6754
+ {
6755
+ x: pin1Position.x + triangleHeight / 2,
6756
+ y: pin1Position.y
6757
+ },
6758
+ {
6759
+ x: pin1Position.x - triangleHeight / 2,
6760
+ y: pin1Position.y + triangleWidth / 2
6761
+ },
6762
+ {
6763
+ x: pin1Position.x - triangleHeight / 2,
6764
+ y: pin1Position.y - triangleWidth / 2
6765
+ },
6766
+ {
6767
+ x: pin1Position.x + triangleHeight / 2,
6768
+ y: pin1Position.y
6769
+ }
6770
+ ],
6771
+ stroke_width: 0.05
6772
+ };
6773
+ return [
6774
+ ...pads,
6775
+ silkscreenRefText,
6776
+ silkscreenPath1,
6777
+ silkscreenPath2,
6778
+ pin1Indicator
6779
+ ];
6780
+ };
6781
+
6696
6782
  // src/helpers/is-not-null.ts
6697
6783
  function isNotNull(value) {
6698
6784
  return value !== null;
@@ -6705,8 +6791,7 @@ var string2 = (def) => {
6705
6791
  const def_parts = modifiedDef.split("_").map((s) => {
6706
6792
  const m = s.match(/([a-z]+)([\(\d\.\+\?].*)?/);
6707
6793
  const [_, fn, v] = m ?? [];
6708
- if (v?.includes("?"))
6709
- return null;
6794
+ if (v?.includes("?")) return null;
6710
6795
  return { fn: m?.[1], v: m?.[2] };
6711
6796
  }).filter(isNotNull);
6712
6797
  for (const { fn, v } of def_parts) {