@tscircuit/footprinter 0.0.168 → 0.0.170
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 +38 -1
- package/dist/index.js +141 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -364,6 +364,11 @@ 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
|
+
pinlabeltextalignleft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
368
|
+
pinlabeltextaligncenter: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
369
|
+
pinlabeltextalignright: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
370
|
+
pinlabelverticallyinverted: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
371
|
+
pinlabelorthogonal: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
367
372
|
nosquareplating: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
368
373
|
}, "strip", z.ZodTypeAny, {
|
|
369
374
|
fn: string;
|
|
@@ -371,7 +376,12 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
|
|
|
371
376
|
p: number;
|
|
372
377
|
id: number;
|
|
373
378
|
od: number;
|
|
379
|
+
pinlabeltextalignleft: boolean;
|
|
380
|
+
pinlabeltextalignright: boolean;
|
|
381
|
+
pinlabelverticallyinverted: boolean;
|
|
382
|
+
pinlabelorthogonal: boolean;
|
|
374
383
|
rows: number;
|
|
384
|
+
pinlabeltextaligncenter: boolean;
|
|
375
385
|
nosquareplating: boolean;
|
|
376
386
|
male?: boolean | undefined;
|
|
377
387
|
female?: boolean | undefined;
|
|
@@ -383,9 +393,15 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
|
|
|
383
393
|
od?: string | number | undefined;
|
|
384
394
|
male?: boolean | undefined;
|
|
385
395
|
female?: boolean | undefined;
|
|
396
|
+
pinlabeltextalignleft?: boolean | undefined;
|
|
397
|
+
pinlabeltextalignright?: boolean | undefined;
|
|
398
|
+
pinlabelverticallyinverted?: boolean | undefined;
|
|
399
|
+
pinlabelorthogonal?: boolean | undefined;
|
|
386
400
|
rows?: string | number | undefined;
|
|
401
|
+
pinlabeltextaligncenter?: boolean | undefined;
|
|
387
402
|
nosquareplating?: boolean | undefined;
|
|
388
403
|
}>, {
|
|
404
|
+
pinlabelAnchorSide: "top" | "bottom" | "left" | "right";
|
|
389
405
|
male: boolean;
|
|
390
406
|
female: boolean;
|
|
391
407
|
fn: string;
|
|
@@ -393,7 +409,12 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
|
|
|
393
409
|
p: number;
|
|
394
410
|
id: number;
|
|
395
411
|
od: number;
|
|
412
|
+
pinlabeltextalignleft: boolean;
|
|
413
|
+
pinlabeltextalignright: boolean;
|
|
414
|
+
pinlabelverticallyinverted: boolean;
|
|
415
|
+
pinlabelorthogonal: boolean;
|
|
396
416
|
rows: number;
|
|
417
|
+
pinlabeltextaligncenter: boolean;
|
|
397
418
|
nosquareplating: boolean;
|
|
398
419
|
}, {
|
|
399
420
|
fn: string;
|
|
@@ -403,9 +424,15 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
|
|
|
403
424
|
od?: string | number | undefined;
|
|
404
425
|
male?: boolean | undefined;
|
|
405
426
|
female?: boolean | undefined;
|
|
427
|
+
pinlabeltextalignleft?: boolean | undefined;
|
|
428
|
+
pinlabeltextalignright?: boolean | undefined;
|
|
429
|
+
pinlabelverticallyinverted?: boolean | undefined;
|
|
430
|
+
pinlabelorthogonal?: boolean | undefined;
|
|
406
431
|
rows?: string | number | undefined;
|
|
432
|
+
pinlabeltextaligncenter?: boolean | undefined;
|
|
407
433
|
nosquareplating?: boolean | undefined;
|
|
408
434
|
}>, {
|
|
435
|
+
pinlabelAnchorSide: "top" | "bottom" | "left" | "right";
|
|
409
436
|
male: boolean;
|
|
410
437
|
female: boolean;
|
|
411
438
|
fn: string;
|
|
@@ -413,7 +440,12 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
|
|
|
413
440
|
p: number;
|
|
414
441
|
id: number;
|
|
415
442
|
od: number;
|
|
443
|
+
pinlabeltextalignleft: boolean;
|
|
444
|
+
pinlabeltextalignright: boolean;
|
|
445
|
+
pinlabelverticallyinverted: boolean;
|
|
446
|
+
pinlabelorthogonal: boolean;
|
|
416
447
|
rows: number;
|
|
448
|
+
pinlabeltextaligncenter: boolean;
|
|
417
449
|
nosquareplating: boolean;
|
|
418
450
|
}, {
|
|
419
451
|
fn: string;
|
|
@@ -423,7 +455,12 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
|
|
|
423
455
|
od?: string | number | undefined;
|
|
424
456
|
male?: boolean | undefined;
|
|
425
457
|
female?: boolean | undefined;
|
|
458
|
+
pinlabeltextalignleft?: boolean | undefined;
|
|
459
|
+
pinlabeltextalignright?: boolean | undefined;
|
|
460
|
+
pinlabelverticallyinverted?: boolean | undefined;
|
|
461
|
+
pinlabelorthogonal?: boolean | undefined;
|
|
426
462
|
rows?: string | number | undefined;
|
|
463
|
+
pinlabeltextaligncenter?: boolean | undefined;
|
|
427
464
|
nosquareplating?: boolean | undefined;
|
|
428
465
|
}>, z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
|
|
429
466
|
fn: z.ZodString;
|
|
@@ -1014,7 +1051,7 @@ type Footprinter = {
|
|
|
1014
1051
|
ssop: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
|
|
1015
1052
|
tssop: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
|
|
1016
1053
|
dfn: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
|
|
1017
|
-
pinrow: (num_pins?: number) => FootprinterParamsBuilder<"p" | "id" | "od" | "male" | "female" | "rows" | "nosquareplating">;
|
|
1054
|
+
pinrow: (num_pins?: number) => FootprinterParamsBuilder<"p" | "id" | "od" | "male" | "female" | "rows" | "pinlabeltextalignleft" | "pinlabeltextaligncenter" | "pinlabeltextalignright" | "pinlabelverticallyinverted" | "pinlabelorthogonal" | "nosquareplating">;
|
|
1018
1055
|
axial: () => FootprinterParamsBuilder<"p" | "id" | "od">;
|
|
1019
1056
|
hc49: () => FootprinterParamsBuilder<"p" | "id" | "od" | "w" | "h">;
|
|
1020
1057
|
to220: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "od">;
|
package/dist/index.js
CHANGED
|
@@ -1559,27 +1559,91 @@ var platedHoleWithRectPad = (pn, x, y, holeDiameter, rectPadWidth, rectPadHeight
|
|
|
1559
1559
|
|
|
1560
1560
|
// src/helpers/silkscreenPin.ts
|
|
1561
1561
|
var silkscreenPin = ({
|
|
1562
|
-
x,
|
|
1563
|
-
y,
|
|
1564
1562
|
fs,
|
|
1565
|
-
pn
|
|
1563
|
+
pn,
|
|
1564
|
+
anchor_x,
|
|
1565
|
+
anchor_y,
|
|
1566
|
+
textalign = "center",
|
|
1567
|
+
orthogonal = false,
|
|
1568
|
+
verticallyinverted = false
|
|
1566
1569
|
}) => {
|
|
1570
|
+
let ccw_rotation = 0;
|
|
1571
|
+
if (orthogonal && verticallyinverted) {
|
|
1572
|
+
ccw_rotation = 270;
|
|
1573
|
+
} else if (verticallyinverted) {
|
|
1574
|
+
ccw_rotation = 180;
|
|
1575
|
+
} else if (orthogonal) {
|
|
1576
|
+
ccw_rotation = 90;
|
|
1577
|
+
} else {
|
|
1578
|
+
ccw_rotation = 0;
|
|
1579
|
+
}
|
|
1580
|
+
let anchor_alignment = "center";
|
|
1581
|
+
if (textalign === "left") {
|
|
1582
|
+
anchor_alignment = "center_left";
|
|
1583
|
+
}
|
|
1584
|
+
if (textalign === "right") {
|
|
1585
|
+
anchor_alignment = "center_right";
|
|
1586
|
+
}
|
|
1567
1587
|
return {
|
|
1568
1588
|
type: "pcb_silkscreen_text",
|
|
1569
1589
|
pcb_silkscreen_text_id: "silkscreen_text_1",
|
|
1570
1590
|
font: "tscircuit2024",
|
|
1571
1591
|
font_size: fs,
|
|
1572
|
-
stroke_width: fs / 100,
|
|
1573
1592
|
pcb_component_id: "pcb_component_1",
|
|
1574
1593
|
text: `{PIN${pn}}`,
|
|
1575
1594
|
layer: "top",
|
|
1576
|
-
anchor_position: { x, y },
|
|
1577
|
-
anchor_alignment
|
|
1595
|
+
anchor_position: { x: anchor_x, y: anchor_y },
|
|
1596
|
+
anchor_alignment,
|
|
1597
|
+
ccw_rotation
|
|
1578
1598
|
};
|
|
1579
1599
|
};
|
|
1580
1600
|
|
|
1581
1601
|
// src/fn/pinrow.ts
|
|
1582
1602
|
import "@tscircuit/mm";
|
|
1603
|
+
|
|
1604
|
+
// src/helpers/determine-pin-label-anchor-side.ts
|
|
1605
|
+
function determinePinlabelAnchorSide({
|
|
1606
|
+
pinlabeltextalignleft,
|
|
1607
|
+
pinlabeltextalignright,
|
|
1608
|
+
pinlabelverticallyinverted,
|
|
1609
|
+
pinlabelorthogonal
|
|
1610
|
+
}) {
|
|
1611
|
+
let pinlabelAnchorSide = "top";
|
|
1612
|
+
if (pinlabelorthogonal && pinlabelverticallyinverted) {
|
|
1613
|
+
pinlabelAnchorSide = "left";
|
|
1614
|
+
} else if (pinlabelorthogonal) {
|
|
1615
|
+
pinlabelAnchorSide = "right";
|
|
1616
|
+
} else if (pinlabelverticallyinverted) {
|
|
1617
|
+
pinlabelAnchorSide = "bottom";
|
|
1618
|
+
} else {
|
|
1619
|
+
pinlabelAnchorSide = "top";
|
|
1620
|
+
}
|
|
1621
|
+
if (pinlabeltextalignleft) {
|
|
1622
|
+
if (pinlabelorthogonal && pinlabelverticallyinverted) {
|
|
1623
|
+
pinlabelAnchorSide = "top";
|
|
1624
|
+
} else if (pinlabelorthogonal) {
|
|
1625
|
+
pinlabelAnchorSide = "bottom";
|
|
1626
|
+
} else if (pinlabelverticallyinverted) {
|
|
1627
|
+
pinlabelAnchorSide = "left";
|
|
1628
|
+
} else {
|
|
1629
|
+
pinlabelAnchorSide = "right";
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
if (pinlabeltextalignright) {
|
|
1633
|
+
if (pinlabelorthogonal && pinlabelverticallyinverted) {
|
|
1634
|
+
pinlabelAnchorSide = "bottom";
|
|
1635
|
+
} else if (pinlabelorthogonal) {
|
|
1636
|
+
pinlabelAnchorSide = "top";
|
|
1637
|
+
} else if (pinlabelverticallyinverted) {
|
|
1638
|
+
pinlabelAnchorSide = "right";
|
|
1639
|
+
} else {
|
|
1640
|
+
pinlabelAnchorSide = "left";
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
return pinlabelAnchorSide;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
// src/fn/pinrow.ts
|
|
1583
1647
|
var pinrow_def = z11.object({
|
|
1584
1648
|
fn: z11.string(),
|
|
1585
1649
|
num_pins: z11.number().optional().default(6),
|
|
@@ -1589,12 +1653,21 @@ var pinrow_def = z11.object({
|
|
|
1589
1653
|
od: length5.default("1.5mm").describe("outer diameter"),
|
|
1590
1654
|
male: z11.boolean().optional().describe("for male pin headers"),
|
|
1591
1655
|
female: z11.boolean().optional().describe("for female pin headers"),
|
|
1656
|
+
pinlabeltextalignleft: z11.boolean().optional().default(false),
|
|
1657
|
+
pinlabeltextaligncenter: z11.boolean().optional().default(false),
|
|
1658
|
+
pinlabeltextalignright: z11.boolean().optional().default(false),
|
|
1659
|
+
pinlabelverticallyinverted: z11.boolean().optional().default(false),
|
|
1660
|
+
pinlabelorthogonal: z11.boolean().optional().default(false),
|
|
1592
1661
|
nosquareplating: z11.boolean().optional().default(false).describe("do not use rectangular pad for pin 1")
|
|
1593
|
-
}).transform((data) =>
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1662
|
+
}).transform((data) => {
|
|
1663
|
+
const pinlabelAnchorSide = determinePinlabelAnchorSide(data);
|
|
1664
|
+
return {
|
|
1665
|
+
...data,
|
|
1666
|
+
pinlabelAnchorSide,
|
|
1667
|
+
male: data.male ?? (data.female ? false : true),
|
|
1668
|
+
female: data.female ?? false
|
|
1669
|
+
};
|
|
1670
|
+
}).superRefine((data, ctx) => {
|
|
1598
1671
|
if (data.male && data.female) {
|
|
1599
1672
|
ctx.addIssue({
|
|
1600
1673
|
code: z11.ZodIssueCode.custom,
|
|
@@ -1605,18 +1678,73 @@ var pinrow_def = z11.object({
|
|
|
1605
1678
|
});
|
|
1606
1679
|
var pinrow = (raw_params) => {
|
|
1607
1680
|
const parameters = pinrow_def.parse(raw_params);
|
|
1608
|
-
const {
|
|
1681
|
+
const {
|
|
1682
|
+
p,
|
|
1683
|
+
id,
|
|
1684
|
+
od,
|
|
1685
|
+
rows,
|
|
1686
|
+
num_pins,
|
|
1687
|
+
pinlabelAnchorSide,
|
|
1688
|
+
pinlabelverticallyinverted,
|
|
1689
|
+
pinlabelorthogonal,
|
|
1690
|
+
pinlabeltextalignleft,
|
|
1691
|
+
pinlabeltextalignright
|
|
1692
|
+
} = parameters;
|
|
1693
|
+
let pinlabelTextAlign = "center";
|
|
1694
|
+
if (pinlabeltextalignleft)
|
|
1695
|
+
pinlabelTextAlign = "left";
|
|
1696
|
+
else if (pinlabeltextalignright)
|
|
1697
|
+
pinlabelTextAlign = "right";
|
|
1609
1698
|
const holes = [];
|
|
1610
1699
|
const numPinsPerRow = Math.ceil(num_pins / rows);
|
|
1611
1700
|
const ySpacing = -p;
|
|
1701
|
+
const calculateAnchorPosition = ({
|
|
1702
|
+
xoff,
|
|
1703
|
+
yoff,
|
|
1704
|
+
od: od2,
|
|
1705
|
+
anchorSide
|
|
1706
|
+
}) => {
|
|
1707
|
+
let dx = 0, dy = 0;
|
|
1708
|
+
const offset = od2 * 0.75;
|
|
1709
|
+
switch (anchorSide) {
|
|
1710
|
+
case "right":
|
|
1711
|
+
dx = offset;
|
|
1712
|
+
break;
|
|
1713
|
+
case "top":
|
|
1714
|
+
dy = offset;
|
|
1715
|
+
break;
|
|
1716
|
+
case "bottom":
|
|
1717
|
+
dy = -offset;
|
|
1718
|
+
break;
|
|
1719
|
+
case "left":
|
|
1720
|
+
dx = -offset;
|
|
1721
|
+
break;
|
|
1722
|
+
}
|
|
1723
|
+
return { anchor_x: xoff + dx, anchor_y: yoff + dy };
|
|
1724
|
+
};
|
|
1612
1725
|
const addPin = (pinNumber, xoff, yoff) => {
|
|
1613
1726
|
if (pinNumber === 1 && !parameters.nosquareplating) {
|
|
1614
1727
|
holes.push(platedHoleWithRectPad(pinNumber, xoff, yoff, id, od, od));
|
|
1615
1728
|
} else {
|
|
1616
1729
|
holes.push(platedhole(pinNumber, xoff, yoff, id, od));
|
|
1617
1730
|
}
|
|
1731
|
+
const { anchor_x, anchor_y } = calculateAnchorPosition({
|
|
1732
|
+
xoff,
|
|
1733
|
+
yoff,
|
|
1734
|
+
od,
|
|
1735
|
+
anchorSide: pinlabelAnchorSide
|
|
1736
|
+
});
|
|
1618
1737
|
holes.push(
|
|
1619
|
-
silkscreenPin({
|
|
1738
|
+
silkscreenPin({
|
|
1739
|
+
fs: od / 5,
|
|
1740
|
+
pn: pinNumber,
|
|
1741
|
+
anchor_x,
|
|
1742
|
+
anchor_y,
|
|
1743
|
+
anchorplacement: pinlabelAnchorSide,
|
|
1744
|
+
textalign: pinlabelTextAlign,
|
|
1745
|
+
orthogonal: pinlabelorthogonal,
|
|
1746
|
+
verticallyinverted: pinlabelverticallyinverted
|
|
1747
|
+
})
|
|
1620
1748
|
);
|
|
1621
1749
|
};
|
|
1622
1750
|
const usedPositions = /* @__PURE__ */ new Set();
|