@tscircuit/footprinter 0.0.179 → 0.0.181
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 +4 -4
- package/dist/index.js +42 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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<
|
|
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
|
-
},
|
|
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<
|
|
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
|
-
},
|
|
497
|
+
}, "strip", z.ZodTypeAny, {
|
|
498
498
|
fn: string;
|
|
499
499
|
num_pins: number;
|
|
500
500
|
p: number;
|
package/dist/index.js
CHANGED
|
@@ -388,16 +388,11 @@ var deriveGFromW = (w) => 0.59 * w - 0.31;
|
|
|
388
388
|
var deriveCFromW = (w) => -0.01 * w ** 2 + 0.94 * w + 0.03;
|
|
389
389
|
var passive = (params) => {
|
|
390
390
|
let { tht, p, pw, ph, metric, imperial, w, h } = params;
|
|
391
|
-
if (typeof w === "string")
|
|
392
|
-
|
|
393
|
-
if (typeof
|
|
394
|
-
|
|
395
|
-
if (typeof
|
|
396
|
-
p = mm2(p);
|
|
397
|
-
if (typeof pw === "string")
|
|
398
|
-
pw = mm2(pw);
|
|
399
|
-
if (typeof ph === "string")
|
|
400
|
-
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);
|
|
401
396
|
if (h > w) {
|
|
402
397
|
throw new Error(
|
|
403
398
|
"height cannot be greater than width (rotated footprint not yet implemented)"
|
|
@@ -427,10 +422,8 @@ var passive = (params) => {
|
|
|
427
422
|
pw = (sz.Z_mm_min - sz.G_mm_min) / 2;
|
|
428
423
|
ph = (sz.Z_mm_min - sz.G_mm_min) / 2;
|
|
429
424
|
}
|
|
430
|
-
if (pw === void 0)
|
|
431
|
-
|
|
432
|
-
if (ph === void 0)
|
|
433
|
-
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");
|
|
434
427
|
const silkscreenLine = {
|
|
435
428
|
type: "pcb_silkscreen_path",
|
|
436
429
|
layer: "top",
|
|
@@ -507,8 +500,7 @@ var dim2d = z3.string().transform((a) => {
|
|
|
507
500
|
// src/helpers/zod/function-call.ts
|
|
508
501
|
import { z as z4 } from "zod";
|
|
509
502
|
var function_call = z4.string().or(z4.array(z4.any())).transform((a) => {
|
|
510
|
-
if (Array.isArray(a))
|
|
511
|
-
return a;
|
|
503
|
+
if (Array.isArray(a)) return a;
|
|
512
504
|
if (a.startsWith("(") && a.endsWith(")")) {
|
|
513
505
|
a = a.slice(1, -1);
|
|
514
506
|
}
|
|
@@ -536,27 +528,20 @@ var bga_def = z5.object({
|
|
|
536
528
|
missing: function_call.default([])
|
|
537
529
|
}).transform((a) => {
|
|
538
530
|
let origin = "tl";
|
|
539
|
-
if (a.blorigin)
|
|
540
|
-
|
|
541
|
-
if (a.
|
|
542
|
-
origin = "tr";
|
|
543
|
-
if (a.brorigin)
|
|
544
|
-
origin = "br";
|
|
531
|
+
if (a.blorigin) origin = "bl";
|
|
532
|
+
if (a.trorigin) origin = "tr";
|
|
533
|
+
if (a.brorigin) origin = "br";
|
|
545
534
|
if (!a.grid) {
|
|
546
535
|
const largest_square = Math.ceil(Math.sqrt(a.num_pins));
|
|
547
536
|
a.grid = { x: largest_square, y: largest_square };
|
|
548
537
|
}
|
|
549
538
|
if (a.missing) {
|
|
550
539
|
a.missing = a.missing.map((s) => {
|
|
551
|
-
if (typeof s === "number")
|
|
552
|
-
|
|
553
|
-
if (s === "
|
|
554
|
-
return "center";
|
|
555
|
-
if (s === "topleft")
|
|
556
|
-
return "topleft";
|
|
540
|
+
if (typeof s === "number") return s;
|
|
541
|
+
if (s === "center") return "center";
|
|
542
|
+
if (s === "topleft") return "topleft";
|
|
557
543
|
const m = s.match(/([A-Z]+)(\d+)/);
|
|
558
|
-
if (!m)
|
|
559
|
-
return s;
|
|
544
|
+
if (!m) return s;
|
|
560
545
|
const Y = ALPHABET.indexOf(m[1]);
|
|
561
546
|
const X = Number.parseInt(m[2]) - 1;
|
|
562
547
|
return Y * a.grid.x + X + 1;
|
|
@@ -1148,10 +1133,8 @@ var qfp = (raw_params) => {
|
|
|
1148
1133
|
raw_params.p = 0.8;
|
|
1149
1134
|
break;
|
|
1150
1135
|
case 52:
|
|
1151
|
-
if (raw_params.w === 14)
|
|
1152
|
-
|
|
1153
|
-
else
|
|
1154
|
-
raw_params.p = 0.65;
|
|
1136
|
+
if (raw_params.w === 14) raw_params.p = 1;
|
|
1137
|
+
else raw_params.p = 0.65;
|
|
1155
1138
|
break;
|
|
1156
1139
|
case 208:
|
|
1157
1140
|
raw_params.p = 0.5;
|
|
@@ -1180,10 +1163,8 @@ var qfp = (raw_params) => {
|
|
|
1180
1163
|
raw_params.pw = 0.5;
|
|
1181
1164
|
break;
|
|
1182
1165
|
case 52:
|
|
1183
|
-
if (raw_params.w === 14)
|
|
1184
|
-
|
|
1185
|
-
else
|
|
1186
|
-
raw_params.pw = 0.55;
|
|
1166
|
+
if (raw_params.w === 14) raw_params.pw = 0.45;
|
|
1167
|
+
else raw_params.pw = 0.55;
|
|
1187
1168
|
break;
|
|
1188
1169
|
case 208:
|
|
1189
1170
|
raw_params.pw = 0.3;
|
|
@@ -1584,16 +1565,12 @@ var silkscreenPin = ({
|
|
|
1584
1565
|
}
|
|
1585
1566
|
let anchor_alignment = "center";
|
|
1586
1567
|
if (textalign === "left") {
|
|
1587
|
-
if (verticallyinverted)
|
|
1588
|
-
|
|
1589
|
-
else
|
|
1590
|
-
anchor_alignment = "center_left";
|
|
1568
|
+
if (verticallyinverted) anchor_alignment = "center_right";
|
|
1569
|
+
else anchor_alignment = "center_left";
|
|
1591
1570
|
}
|
|
1592
1571
|
if (textalign === "right") {
|
|
1593
|
-
if (verticallyinverted)
|
|
1594
|
-
|
|
1595
|
-
else
|
|
1596
|
-
anchor_alignment = "center_right";
|
|
1572
|
+
if (verticallyinverted) anchor_alignment = "center_left";
|
|
1573
|
+
else anchor_alignment = "center_right";
|
|
1597
1574
|
}
|
|
1598
1575
|
if (layer === "bottom") {
|
|
1599
1576
|
if (anchor_alignment === "center_left") {
|
|
@@ -1698,10 +1675,8 @@ var pinrow = (raw_params) => {
|
|
|
1698
1675
|
doublesidedpinlabel
|
|
1699
1676
|
} = parameters;
|
|
1700
1677
|
let pinlabelTextAlign = "center";
|
|
1701
|
-
if (pinlabeltextalignleft)
|
|
1702
|
-
|
|
1703
|
-
else if (pinlabeltextalignright)
|
|
1704
|
-
pinlabelTextAlign = "right";
|
|
1678
|
+
if (pinlabeltextalignleft) pinlabelTextAlign = "left";
|
|
1679
|
+
else if (pinlabeltextalignright) pinlabelTextAlign = "right";
|
|
1705
1680
|
const holes = [];
|
|
1706
1681
|
const numPinsPerRow = Math.ceil(num_pins / rows);
|
|
1707
1682
|
const ySpacing = -p;
|
|
@@ -1778,8 +1753,7 @@ var pinrow = (raw_params) => {
|
|
|
1778
1753
|
const pinNumber = i + 1;
|
|
1779
1754
|
const xoff = xStart + i * p;
|
|
1780
1755
|
const posKey = `${xoff},${0}`;
|
|
1781
|
-
if (usedPositions.has(posKey))
|
|
1782
|
-
throw new Error(`Overlap at ${posKey}`);
|
|
1756
|
+
if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
|
|
1783
1757
|
usedPositions.add(posKey);
|
|
1784
1758
|
addPin(pinNumber, xoff, 0);
|
|
1785
1759
|
}
|
|
@@ -1791,8 +1765,7 @@ var pinrow = (raw_params) => {
|
|
|
1791
1765
|
const xoff = xStart + col * p;
|
|
1792
1766
|
const yoff = row * ySpacing;
|
|
1793
1767
|
const posKey = `${xoff},${yoff}`;
|
|
1794
|
-
if (usedPositions.has(posKey))
|
|
1795
|
-
throw new Error(`Overlap at ${posKey}`);
|
|
1768
|
+
if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
|
|
1796
1769
|
usedPositions.add(posKey);
|
|
1797
1770
|
addPin(currentPin++, xoff, yoff);
|
|
1798
1771
|
}
|
|
@@ -1809,8 +1782,7 @@ var pinrow = (raw_params) => {
|
|
|
1809
1782
|
const xoff = xStart + left * p;
|
|
1810
1783
|
const yoff = row * ySpacing;
|
|
1811
1784
|
const posKey = `${xoff},${yoff}`;
|
|
1812
|
-
if (usedPositions.has(posKey))
|
|
1813
|
-
throw new Error(`Overlap at ${posKey}`);
|
|
1785
|
+
if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
|
|
1814
1786
|
usedPositions.add(posKey);
|
|
1815
1787
|
addPin(currentPin++, xoff, yoff);
|
|
1816
1788
|
}
|
|
@@ -1819,8 +1791,7 @@ var pinrow = (raw_params) => {
|
|
|
1819
1791
|
const xoff = xStart + col * p;
|
|
1820
1792
|
const yoff = bottom * ySpacing;
|
|
1821
1793
|
const posKey = `${xoff},${yoff}`;
|
|
1822
|
-
if (usedPositions.has(posKey))
|
|
1823
|
-
throw new Error(`Overlap at ${posKey}`);
|
|
1794
|
+
if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
|
|
1824
1795
|
usedPositions.add(posKey);
|
|
1825
1796
|
addPin(currentPin++, xoff, yoff);
|
|
1826
1797
|
}
|
|
@@ -1830,8 +1801,7 @@ var pinrow = (raw_params) => {
|
|
|
1830
1801
|
const xoff = xStart + right * p;
|
|
1831
1802
|
const yoff = row * ySpacing;
|
|
1832
1803
|
const posKey = `${xoff},${yoff}`;
|
|
1833
|
-
if (usedPositions.has(posKey))
|
|
1834
|
-
throw new Error(`Overlap at ${posKey}`);
|
|
1804
|
+
if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
|
|
1835
1805
|
usedPositions.add(posKey);
|
|
1836
1806
|
addPin(currentPin++, xoff, yoff);
|
|
1837
1807
|
}
|
|
@@ -1842,8 +1812,7 @@ var pinrow = (raw_params) => {
|
|
|
1842
1812
|
const xoff = xStart + col * p;
|
|
1843
1813
|
const yoff = top * ySpacing;
|
|
1844
1814
|
const posKey = `${xoff},${yoff}`;
|
|
1845
|
-
if (usedPositions.has(posKey))
|
|
1846
|
-
throw new Error(`Overlap at ${posKey}`);
|
|
1815
|
+
if (usedPositions.has(posKey)) throw new Error(`Overlap at ${posKey}`);
|
|
1847
1816
|
usedPositions.add(posKey);
|
|
1848
1817
|
addPin(currentPin++, xoff, yoff);
|
|
1849
1818
|
}
|
|
@@ -3049,7 +3018,8 @@ var pad = (params) => {
|
|
|
3049
3018
|
circuitJson: [
|
|
3050
3019
|
rectpad(1, 0, 0, width, height),
|
|
3051
3020
|
silkscreenRef(0, height / 2 + 0.5, 0.2)
|
|
3052
|
-
]
|
|
3021
|
+
],
|
|
3022
|
+
parameters: params
|
|
3053
3023
|
};
|
|
3054
3024
|
};
|
|
3055
3025
|
|
|
@@ -6658,23 +6628,15 @@ var platedhole_def = z58.object({
|
|
|
6658
6628
|
squarepad: z58.boolean().optional().default(false)
|
|
6659
6629
|
}).transform((v) => {
|
|
6660
6630
|
let holeD;
|
|
6661
|
-
if (v.d !== void 0)
|
|
6662
|
-
|
|
6663
|
-
else if (v.
|
|
6664
|
-
|
|
6665
|
-
else
|
|
6666
|
-
holeD = mm6(v.r) * 2;
|
|
6667
|
-
else if (v.hr !== void 0)
|
|
6668
|
-
holeD = mm6(v.hr) * 2;
|
|
6669
|
-
else
|
|
6670
|
-
holeD = mm6("1mm");
|
|
6631
|
+
if (v.d !== void 0) holeD = mm6(v.d);
|
|
6632
|
+
else if (v.hd !== void 0) holeD = mm6(v.hd);
|
|
6633
|
+
else if (v.r !== void 0) holeD = mm6(v.r) * 2;
|
|
6634
|
+
else if (v.hr !== void 0) holeD = mm6(v.hr) * 2;
|
|
6635
|
+
else holeD = mm6("1mm");
|
|
6671
6636
|
let padD;
|
|
6672
|
-
if (v.pd !== void 0)
|
|
6673
|
-
|
|
6674
|
-
else
|
|
6675
|
-
padD = mm6(v.pr) * 2;
|
|
6676
|
-
else
|
|
6677
|
-
padD = holeD * (1.5 / 1);
|
|
6637
|
+
if (v.pd !== void 0) padD = mm6(v.pd);
|
|
6638
|
+
else if (v.pr !== void 0) padD = mm6(v.pr) * 2;
|
|
6639
|
+
else padD = holeD * (1.5 / 1);
|
|
6678
6640
|
return {
|
|
6679
6641
|
fn: v.fn,
|
|
6680
6642
|
d: holeD,
|
|
@@ -6830,8 +6792,7 @@ var string2 = (def) => {
|
|
|
6830
6792
|
const def_parts = modifiedDef.split("_").map((s) => {
|
|
6831
6793
|
const m = s.match(/([a-z]+)([\(\d\.\+\?].*)?/);
|
|
6832
6794
|
const [_, fn, v] = m ?? [];
|
|
6833
|
-
if (v?.includes("?"))
|
|
6834
|
-
return null;
|
|
6795
|
+
if (v?.includes("?")) return null;
|
|
6835
6796
|
return { fn: m?.[1], v: m?.[2] };
|
|
6836
6797
|
}).filter(isNotNull);
|
|
6837
6798
|
for (const { fn, v } of def_parts) {
|