@tscircuit/footprinter 0.0.168 → 0.0.169

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
@@ -364,6 +364,12 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
364
364
  od: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
365
365
  male: z.ZodOptional<z.ZodBoolean>;
366
366
  female: z.ZodOptional<z.ZodBoolean>;
367
+ pinlabeltop: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
368
+ pinlabelbottom: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
369
+ pinlabelleft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
370
+ pinlabelright: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
371
+ pinlabelparallel: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
372
+ pinlabelorthogonal: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
367
373
  nosquareplating: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
368
374
  }, "strip", z.ZodTypeAny, {
369
375
  fn: string;
@@ -371,7 +377,13 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
371
377
  p: number;
372
378
  id: number;
373
379
  od: number;
380
+ pinlabelparallel: boolean;
381
+ pinlabelorthogonal: boolean;
374
382
  rows: number;
383
+ pinlabeltop: boolean;
384
+ pinlabelbottom: boolean;
385
+ pinlabelleft: boolean;
386
+ pinlabelright: boolean;
375
387
  nosquareplating: boolean;
376
388
  male?: boolean | undefined;
377
389
  female?: boolean | undefined;
@@ -383,9 +395,16 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
383
395
  od?: string | number | undefined;
384
396
  male?: boolean | undefined;
385
397
  female?: boolean | undefined;
398
+ pinlabelparallel?: boolean | undefined;
399
+ pinlabelorthogonal?: boolean | undefined;
386
400
  rows?: string | number | undefined;
401
+ pinlabeltop?: boolean | undefined;
402
+ pinlabelbottom?: boolean | undefined;
403
+ pinlabelleft?: boolean | undefined;
404
+ pinlabelright?: boolean | undefined;
387
405
  nosquareplating?: boolean | undefined;
388
406
  }>, {
407
+ resolvedPinLabelPosition: "top" | "bottom" | "left" | "right";
389
408
  male: boolean;
390
409
  female: boolean;
391
410
  fn: string;
@@ -393,7 +412,13 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
393
412
  p: number;
394
413
  id: number;
395
414
  od: number;
415
+ pinlabelparallel: boolean;
416
+ pinlabelorthogonal: boolean;
396
417
  rows: number;
418
+ pinlabeltop: boolean;
419
+ pinlabelbottom: boolean;
420
+ pinlabelleft: boolean;
421
+ pinlabelright: boolean;
397
422
  nosquareplating: boolean;
398
423
  }, {
399
424
  fn: string;
@@ -403,9 +428,16 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
403
428
  od?: string | number | undefined;
404
429
  male?: boolean | undefined;
405
430
  female?: boolean | undefined;
431
+ pinlabelparallel?: boolean | undefined;
432
+ pinlabelorthogonal?: boolean | undefined;
406
433
  rows?: string | number | undefined;
434
+ pinlabeltop?: boolean | undefined;
435
+ pinlabelbottom?: boolean | undefined;
436
+ pinlabelleft?: boolean | undefined;
437
+ pinlabelright?: boolean | undefined;
407
438
  nosquareplating?: boolean | undefined;
408
439
  }>, {
440
+ resolvedPinLabelPosition: "top" | "bottom" | "left" | "right";
409
441
  male: boolean;
410
442
  female: boolean;
411
443
  fn: string;
@@ -413,7 +445,13 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
413
445
  p: number;
414
446
  id: number;
415
447
  od: number;
448
+ pinlabelparallel: boolean;
449
+ pinlabelorthogonal: boolean;
416
450
  rows: number;
451
+ pinlabeltop: boolean;
452
+ pinlabelbottom: boolean;
453
+ pinlabelleft: boolean;
454
+ pinlabelright: boolean;
417
455
  nosquareplating: boolean;
418
456
  }, {
419
457
  fn: string;
@@ -423,7 +461,13 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
423
461
  od?: string | number | undefined;
424
462
  male?: boolean | undefined;
425
463
  female?: boolean | undefined;
464
+ pinlabelparallel?: boolean | undefined;
465
+ pinlabelorthogonal?: boolean | undefined;
426
466
  rows?: string | number | undefined;
467
+ pinlabeltop?: boolean | undefined;
468
+ pinlabelbottom?: boolean | undefined;
469
+ pinlabelleft?: boolean | undefined;
470
+ pinlabelright?: boolean | undefined;
427
471
  nosquareplating?: boolean | undefined;
428
472
  }>, z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
429
473
  fn: z.ZodString;
@@ -1014,7 +1058,7 @@ type Footprinter = {
1014
1058
  ssop: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
1015
1059
  tssop: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
1016
1060
  dfn: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
1017
- pinrow: (num_pins?: number) => FootprinterParamsBuilder<"p" | "id" | "od" | "male" | "female" | "rows" | "nosquareplating">;
1061
+ pinrow: (num_pins?: number) => FootprinterParamsBuilder<"p" | "id" | "od" | "male" | "female" | "rows" | "pinlabeltop" | "pinlabelbottom" | "pinlabelleft" | "pinlabelright" | "pinlabelparallel" | "pinlabelorthogonal" | "nosquareplating">;
1018
1062
  axial: () => FootprinterParamsBuilder<"p" | "id" | "od">;
1019
1063
  hc49: () => FootprinterParamsBuilder<"p" | "id" | "od" | "w" | "h">;
1020
1064
  to220: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "od">;
package/dist/index.js CHANGED
@@ -1558,23 +1558,48 @@ var platedHoleWithRectPad = (pn, x, y, holeDiameter, rectPadWidth, rectPadHeight
1558
1558
  };
1559
1559
 
1560
1560
  // src/helpers/silkscreenPin.ts
1561
+ var fullyExplicitAlignmentMap = {
1562
+ top: { 0: "center", 90: "center_right", 180: "center", 270: "center_left" },
1563
+ bottom: {
1564
+ 0: "center",
1565
+ 90: "center_left",
1566
+ 180: "center",
1567
+ 270: "center_right"
1568
+ },
1569
+ left: { 0: "center_right", 90: "center", 180: "center_left", 270: "center" },
1570
+ right: { 0: "center_left", 90: "center", 180: "center_right", 270: "center" }
1571
+ };
1561
1572
  var silkscreenPin = ({
1562
- x,
1563
- y,
1564
1573
  fs,
1565
- pn
1574
+ pn,
1575
+ anchor_x,
1576
+ anchor_y,
1577
+ pinlabelposition = "top",
1578
+ pinlabelparallel = false,
1579
+ pinlabelorthogonal = false
1566
1580
  }) => {
1581
+ let ccw_rotation = 0;
1582
+ if (!pinlabelparallel && !pinlabelorthogonal) {
1583
+ ccw_rotation = 0;
1584
+ } else if (pinlabelparallel && !pinlabelorthogonal) {
1585
+ ccw_rotation = 90;
1586
+ } else if (!pinlabelparallel && pinlabelorthogonal) {
1587
+ ccw_rotation = 180;
1588
+ } else if (pinlabelparallel && pinlabelorthogonal) {
1589
+ ccw_rotation = 270;
1590
+ }
1591
+ const anchor_alignment = fullyExplicitAlignmentMap[pinlabelposition][ccw_rotation];
1567
1592
  return {
1568
1593
  type: "pcb_silkscreen_text",
1569
1594
  pcb_silkscreen_text_id: "silkscreen_text_1",
1570
1595
  font: "tscircuit2024",
1571
1596
  font_size: fs,
1572
- stroke_width: fs / 100,
1573
1597
  pcb_component_id: "pcb_component_1",
1574
1598
  text: `{PIN${pn}}`,
1575
1599
  layer: "top",
1576
- anchor_position: { x, y },
1577
- anchor_alignment: "center"
1600
+ anchor_position: { x: anchor_x, y: anchor_y },
1601
+ anchor_alignment,
1602
+ ccw_rotation
1578
1603
  };
1579
1604
  };
1580
1605
 
@@ -1589,12 +1614,39 @@ var pinrow_def = z11.object({
1589
1614
  od: length5.default("1.5mm").describe("outer diameter"),
1590
1615
  male: z11.boolean().optional().describe("for male pin headers"),
1591
1616
  female: z11.boolean().optional().describe("for female pin headers"),
1617
+ pinlabeltop: z11.boolean().optional().default(false),
1618
+ pinlabelbottom: z11.boolean().optional().default(false),
1619
+ pinlabelleft: z11.boolean().optional().default(false),
1620
+ pinlabelright: z11.boolean().optional().default(false),
1621
+ pinlabelparallel: z11.boolean().optional().default(false),
1622
+ pinlabelorthogonal: z11.boolean().optional().default(false),
1592
1623
  nosquareplating: z11.boolean().optional().default(false).describe("do not use rectangular pad for pin 1")
1593
- }).transform((data) => ({
1594
- ...data,
1595
- male: data.male ?? (data.female ? false : true),
1596
- female: data.female ?? false
1597
- })).superRefine((data, ctx) => {
1624
+ }).transform((data) => {
1625
+ let resolvedPinLabelPosition;
1626
+ const { pinlabeltop, pinlabelbottom, pinlabelleft, pinlabelright } = data;
1627
+ const truePositionFlags = [];
1628
+ if (pinlabeltop)
1629
+ truePositionFlags.push("top");
1630
+ if (pinlabelbottom)
1631
+ truePositionFlags.push("bottom");
1632
+ if (pinlabelleft)
1633
+ truePositionFlags.push("left");
1634
+ if (pinlabelright)
1635
+ truePositionFlags.push("right");
1636
+ if (truePositionFlags.includes("top")) {
1637
+ resolvedPinLabelPosition = "top";
1638
+ } else if (truePositionFlags.length === 1) {
1639
+ resolvedPinLabelPosition = truePositionFlags[0];
1640
+ } else {
1641
+ resolvedPinLabelPosition = "top";
1642
+ }
1643
+ return {
1644
+ ...data,
1645
+ resolvedPinLabelPosition,
1646
+ male: data.male ?? (data.female ? false : true),
1647
+ female: data.female ?? false
1648
+ };
1649
+ }).superRefine((data, ctx) => {
1598
1650
  if (data.male && data.female) {
1599
1651
  ctx.addIssue({
1600
1652
  code: z11.ZodIssueCode.custom,
@@ -1605,18 +1657,67 @@ var pinrow_def = z11.object({
1605
1657
  });
1606
1658
  var pinrow = (raw_params) => {
1607
1659
  const parameters = pinrow_def.parse(raw_params);
1608
- const { p, id, od, rows, num_pins } = parameters;
1660
+ const {
1661
+ p,
1662
+ id,
1663
+ od,
1664
+ rows,
1665
+ num_pins,
1666
+ resolvedPinLabelPosition,
1667
+ pinlabelparallel,
1668
+ pinlabelorthogonal
1669
+ } = parameters;
1609
1670
  const holes = [];
1610
1671
  const numPinsPerRow = Math.ceil(num_pins / rows);
1611
1672
  const ySpacing = -p;
1673
+ const calculateAnchorPosition = (xoff, yoff, od2, resolvedPinLabelPosition2) => {
1674
+ let dx = 0, dy = 0;
1675
+ const offset = od2 * 0.75;
1676
+ switch (resolvedPinLabelPosition2) {
1677
+ case "right":
1678
+ dx = offset;
1679
+ dy = 0;
1680
+ break;
1681
+ case "top":
1682
+ dx = 0;
1683
+ dy = offset;
1684
+ break;
1685
+ case "bottom":
1686
+ dx = 0;
1687
+ dy = -offset;
1688
+ break;
1689
+ case "left":
1690
+ dx = -offset;
1691
+ dy = 0;
1692
+ break;
1693
+ default:
1694
+ dx = 0;
1695
+ dy = 0;
1696
+ }
1697
+ return { anchor_x: xoff + dx, anchor_y: yoff + dy };
1698
+ };
1612
1699
  const addPin = (pinNumber, xoff, yoff) => {
1613
1700
  if (pinNumber === 1 && !parameters.nosquareplating) {
1614
1701
  holes.push(platedHoleWithRectPad(pinNumber, xoff, yoff, id, od, od));
1615
1702
  } else {
1616
1703
  holes.push(platedhole(pinNumber, xoff, yoff, id, od));
1617
1704
  }
1705
+ const { anchor_x, anchor_y } = calculateAnchorPosition(
1706
+ xoff,
1707
+ yoff,
1708
+ od,
1709
+ resolvedPinLabelPosition
1710
+ );
1618
1711
  holes.push(
1619
- silkscreenPin({ x: xoff, y: yoff + p / 2, fs: od / 5, pn: pinNumber })
1712
+ silkscreenPin({
1713
+ fs: od / 5,
1714
+ pn: pinNumber,
1715
+ anchor_x,
1716
+ anchor_y,
1717
+ pinlabelposition: resolvedPinLabelPosition,
1718
+ pinlabelparallel,
1719
+ pinlabelorthogonal
1720
+ })
1620
1721
  );
1621
1722
  };
1622
1723
  const usedPositions = /* @__PURE__ */ new Set();