@tscircuit/footprinter 0.0.203 → 0.0.205

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
@@ -377,6 +377,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
377
377
  nosquareplating: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
378
378
  nopinlabels: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
379
379
  doublesidedpinlabel: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
380
+ backsidelabel: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
380
381
  }, "strip", z.ZodTypeAny, {
381
382
  fn: string;
382
383
  num_pins: number;
@@ -392,6 +393,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
392
393
  nosquareplating: boolean;
393
394
  nopinlabels: boolean;
394
395
  doublesidedpinlabel: boolean;
396
+ backsidelabel: boolean;
395
397
  male?: boolean | undefined;
396
398
  female?: boolean | undefined;
397
399
  }, {
@@ -411,6 +413,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
411
413
  nosquareplating?: boolean | undefined;
412
414
  nopinlabels?: boolean | undefined;
413
415
  doublesidedpinlabel?: boolean | undefined;
416
+ backsidelabel?: boolean | undefined;
414
417
  }>, {
415
418
  pinlabelAnchorSide: "top" | "bottom" | "left" | "right";
416
419
  male: boolean;
@@ -429,6 +432,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
429
432
  nosquareplating: boolean;
430
433
  nopinlabels: boolean;
431
434
  doublesidedpinlabel: boolean;
435
+ backsidelabel: boolean;
432
436
  }, {
433
437
  fn: string;
434
438
  num_pins?: number | undefined;
@@ -446,6 +450,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
446
450
  nosquareplating?: boolean | undefined;
447
451
  nopinlabels?: boolean | undefined;
448
452
  doublesidedpinlabel?: boolean | undefined;
453
+ backsidelabel?: boolean | undefined;
449
454
  }>, {
450
455
  pinlabelAnchorSide: "top" | "bottom" | "left" | "right";
451
456
  male: boolean;
@@ -464,6 +469,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
464
469
  nosquareplating: boolean;
465
470
  nopinlabels: boolean;
466
471
  doublesidedpinlabel: boolean;
472
+ backsidelabel: boolean;
467
473
  }, {
468
474
  fn: string;
469
475
  num_pins?: number | undefined;
@@ -481,6 +487,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
481
487
  nosquareplating?: boolean | undefined;
482
488
  nopinlabels?: boolean | undefined;
483
489
  doublesidedpinlabel?: boolean | undefined;
490
+ backsidelabel?: boolean | undefined;
484
491
  }>, z.ZodEffects<z.ZodObject<{
485
492
  fn: z.ZodString;
486
493
  cc: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
@@ -1161,7 +1168,7 @@ type Footprinter = {
1161
1168
  ssop: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
1162
1169
  tssop: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
1163
1170
  dfn: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
1164
- pinrow: (num_pins?: number) => FootprinterParamsBuilder<"p" | "id" | "od" | "male" | "female" | "rows" | "pinlabeltextalignleft" | "pinlabeltextaligncenter" | "pinlabeltextalignright" | "pinlabelverticallyinverted" | "pinlabelorthogonal" | "nosquareplating" | "nopinlabels" | "doublesidedpinlabel">;
1171
+ pinrow: (num_pins?: number) => FootprinterParamsBuilder<"p" | "id" | "od" | "male" | "female" | "rows" | "pinlabeltextalignleft" | "pinlabeltextaligncenter" | "pinlabeltextalignright" | "pinlabelverticallyinverted" | "pinlabelorthogonal" | "nosquareplating" | "nopinlabels" | "doublesidedpinlabel" | "backsidelabel">;
1165
1172
  axial: () => FootprinterParamsBuilder<"p" | "id" | "od">;
1166
1173
  hc49: () => FootprinterParamsBuilder<"p" | "id" | "od" | "w" | "h">;
1167
1174
  to220: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "od">;
@@ -1178,7 +1185,7 @@ type Footprinter = {
1178
1185
  smc: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pw" | "pl">;
1179
1186
  minimelf: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pw" | "pl">;
1180
1187
  melf: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pw" | "pl">;
1181
- jst: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "pw" | "pl">;
1188
+ jst: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "pw" | "pl" | "ph" | "sh">;
1182
1189
  micromelf: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pw" | "pl">;
1183
1190
  ms013: () => FootprinterParamsBuilder<"w" | "p">;
1184
1191
  ms012: () => FootprinterParamsBuilder<"w" | "p">;
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ __export(fn_exports, {
29
29
  msop: () => msop,
30
30
  pad: () => pad,
31
31
  pinrow: () => pinrow,
32
- platedhole: () => platedhole3,
32
+ platedhole: () => platedhole2,
33
33
  potentiometer: () => potentiometer,
34
34
  pushbutton: () => pushbutton,
35
35
  qfn: () => qfn,
@@ -1661,7 +1661,10 @@ var pinrow_def = z12.object({
1661
1661
  pinlabelorthogonal: z12.boolean().optional().default(false),
1662
1662
  nosquareplating: z12.boolean().optional().default(false).describe("do not use rectangular pad for pin 1"),
1663
1663
  nopinlabels: z12.boolean().optional().default(false).describe("omit silkscreen pin labels"),
1664
- doublesidedpinlabel: z12.boolean().optional().default(false).describe("add silkscreen pins in top and bottom layers")
1664
+ doublesidedpinlabel: z12.boolean().optional().default(false).describe("add silkscreen pins in top and bottom layers"),
1665
+ backsidelabel: z12.boolean().optional().default(false).describe(
1666
+ "place the silkscreen reference text on the bottom layer instead of top"
1667
+ )
1665
1668
  }).transform((data) => {
1666
1669
  const pinlabelAnchorSide = determinePinlabelAnchorSide(data);
1667
1670
  return {
@@ -1693,7 +1696,8 @@ var pinrow = (raw_params) => {
1693
1696
  pinlabeltextalignleft,
1694
1697
  pinlabeltextalignright,
1695
1698
  nopinlabels,
1696
- doublesidedpinlabel
1699
+ doublesidedpinlabel,
1700
+ backsidelabel
1697
1701
  } = parameters;
1698
1702
  let pinlabelTextAlign = "center";
1699
1703
  if (pinlabeltextalignleft) pinlabelTextAlign = "left";
@@ -1738,19 +1742,35 @@ var pinrow = (raw_params) => {
1738
1742
  anchorSide: pinlabelAnchorSide
1739
1743
  });
1740
1744
  if (!nopinlabels) {
1741
- holes.push(
1742
- silkscreenPin({
1743
- fs: od / 5,
1744
- pn: pinNumber,
1745
- anchor_x,
1746
- anchor_y,
1747
- anchorplacement: pinlabelAnchorSide,
1748
- textalign: pinlabelTextAlign,
1749
- orthogonal: pinlabelorthogonal,
1750
- verticallyinverted: pinlabelverticallyinverted,
1751
- layer: "top"
1752
- })
1753
- );
1745
+ if (!backsidelabel) {
1746
+ holes.push(
1747
+ silkscreenPin({
1748
+ fs: od / 5,
1749
+ pn: pinNumber,
1750
+ anchor_x,
1751
+ anchor_y,
1752
+ anchorplacement: pinlabelAnchorSide,
1753
+ textalign: pinlabelTextAlign,
1754
+ orthogonal: pinlabelorthogonal,
1755
+ verticallyinverted: pinlabelverticallyinverted,
1756
+ layer: "top"
1757
+ })
1758
+ );
1759
+ } else {
1760
+ holes.push(
1761
+ silkscreenPin({
1762
+ fs: od / 5,
1763
+ pn: pinNumber,
1764
+ anchor_x,
1765
+ anchor_y,
1766
+ anchorplacement: pinlabelAnchorSide,
1767
+ textalign: pinlabelTextAlign,
1768
+ orthogonal: pinlabelorthogonal,
1769
+ verticallyinverted: pinlabelverticallyinverted,
1770
+ layer: "bottom"
1771
+ })
1772
+ );
1773
+ }
1754
1774
  if (doublesidedpinlabel) {
1755
1775
  holes.push(
1756
1776
  silkscreenPin({
@@ -5345,43 +5365,135 @@ import {
5345
5365
  import { z as z47 } from "zod";
5346
5366
  var jst_def = z47.object({
5347
5367
  fn: z47.string(),
5348
- p: length35.optional().default("2.2mm"),
5349
- id: length35.optional().default("0.70mm"),
5350
- pw: length35.optional().default("1.20mm"),
5351
- pl: length35.optional().default("1.20mm"),
5352
- w: length35.optional().default("6mm"),
5353
- h: length35.optional().default("5mm")
5368
+ p: length35.optional(),
5369
+ id: length35.optional(),
5370
+ pw: length35.optional(),
5371
+ pl: length35.optional(),
5372
+ w: length35.optional(),
5373
+ h: length35.optional(),
5374
+ sh: z47.union([z47.boolean(), z47.string(), z47.number()]).optional().transform((v) => {
5375
+ if (typeof v === "string") {
5376
+ const n = Number(v);
5377
+ return Number.isNaN(n) ? true : n;
5378
+ }
5379
+ return v;
5380
+ }).describe(
5381
+ 'JST SH (Surface-mount) connector family. SH stands for "Super High-density".'
5382
+ ),
5383
+ ph: z47.boolean().optional().describe(
5384
+ 'JST PH (Through-hole) connector family. PH stands for "Pin Header".'
5385
+ ),
5386
+ string: z47.string().optional()
5354
5387
  });
5388
+ var variantDefaults = {
5389
+ ph: {
5390
+ p: length35.parse("2.2mm"),
5391
+ id: length35.parse("0.70mm"),
5392
+ pw: length35.parse("1.20mm"),
5393
+ pl: length35.parse("1.20mm"),
5394
+ w: length35.parse("6mm"),
5395
+ h: length35.parse("5mm")
5396
+ },
5397
+ sh: {
5398
+ p: length35.parse("1mm"),
5399
+ pw: length35.parse("0.6mm"),
5400
+ pl: length35.parse("1.55mm"),
5401
+ w: length35.parse("5.8mm"),
5402
+ h: length35.parse("7.8mm")
5403
+ }
5404
+ };
5405
+ function getVariant(params) {
5406
+ if (params.sh) return "sh";
5407
+ if (params.ph) return "ph";
5408
+ return "ph";
5409
+ }
5410
+ function generatePads(variant, numPins, p, id, pw, pl) {
5411
+ const pads = [];
5412
+ if (variant === "ph") {
5413
+ const half_p = p / 2;
5414
+ pads.push(platedHoleWithRectPad(1, -half_p, 2, id, pw, pl));
5415
+ pads.push(platedHoleWithRectPad(2, half_p, 2, id, pw, pl));
5416
+ } else {
5417
+ const startX = -((numPins - 1) / 2) * p;
5418
+ for (let i = 0; i < numPins; i++) {
5419
+ const x = startX + i * p;
5420
+ console.log("x si", x);
5421
+ pads.push(rectpad(i + 1, x, -1.325, pw, pl));
5422
+ }
5423
+ const sideOffset = (numPins - 1) / 2 * p + 1.3;
5424
+ console.log("offset", sideOffset);
5425
+ pads.push(rectpad(numPins + 1, -sideOffset, 1.22, 1.2, 1.8));
5426
+ pads.push(rectpad(numPins + 2, sideOffset, 1.22, 1.2, 1.8));
5427
+ }
5428
+ return pads;
5429
+ }
5430
+ function generateSilkscreenBody(variant, w, h) {
5431
+ if (variant === "ph") {
5432
+ return {
5433
+ type: "pcb_silkscreen_path",
5434
+ layer: "top",
5435
+ pcb_component_id: "",
5436
+ route: [
5437
+ { x: -3, y: 3 },
5438
+ { x: 3, y: 3 },
5439
+ { x: 3, y: -2 },
5440
+ { x: -3, y: -2 },
5441
+ { x: -3, y: 3 }
5442
+ ],
5443
+ stroke_width: 0.1,
5444
+ pcb_silkscreen_path_id: ""
5445
+ };
5446
+ } else {
5447
+ return {
5448
+ type: "pcb_silkscreen_path",
5449
+ layer: "top",
5450
+ pcb_component_id: "",
5451
+ route: [],
5452
+ stroke_width: 0.1,
5453
+ pcb_silkscreen_path_id: ""
5454
+ };
5455
+ }
5456
+ }
5355
5457
  var jst = (raw_params) => {
5356
- const parameters = jst_def.parse(raw_params);
5357
- const { p, id, pw, pl, h } = parameters;
5358
- const half_p = p / 2;
5359
- const plated_holes = [
5360
- platedHoleWithRectPad(1, -half_p, 2, id, pw, pl),
5361
- platedHoleWithRectPad(2, half_p, 2, id, pw, pl)
5362
- ];
5363
- const silkscreenBody = {
5364
- type: "pcb_silkscreen_path",
5365
- layer: "top",
5366
- pcb_component_id: "",
5367
- route: [
5368
- { x: -3, y: 3 },
5369
- { x: 3, y: 3 },
5370
- { x: 3, y: -2 },
5371
- { x: -3, y: -2 },
5372
- { x: -3, y: 3 }
5373
- ],
5374
- stroke_width: 0.1,
5375
- pcb_silkscreen_path_id: ""
5376
- };
5458
+ const params = jst_def.parse(raw_params);
5459
+ const variant = getVariant(params);
5460
+ const defaults = variantDefaults[variant];
5461
+ const p = params.p ?? defaults.p;
5462
+ const id = params.id ?? defaults.id;
5463
+ const pw = params.pw ?? defaults.pw;
5464
+ const pl = params.pl ?? defaults.pl;
5465
+ const w = params.w ?? defaults.w;
5466
+ const h = params.h ?? defaults.h;
5467
+ let numPins = variant === "sh" ? 4 : 2;
5468
+ if (variant === "sh") {
5469
+ const str = typeof raw_params.string === "string" ? raw_params.string : "";
5470
+ const match = str.match(/sh(\d+)/);
5471
+ if (match && match[1]) {
5472
+ const parsed = parseInt(match[1], 10);
5473
+ if (!Number.isNaN(parsed)) {
5474
+ numPins = parsed;
5475
+ }
5476
+ } else if (typeof params.sh === "number") {
5477
+ numPins = params.sh;
5478
+ }
5479
+ }
5480
+ const pads = generatePads(variant, numPins, p, id, pw, pl);
5481
+ const silkscreenBody = generateSilkscreenBody(variant, w, h);
5377
5482
  const silkscreenRefText = silkscreenRef(0, h / 2 + 1, 0.5);
5378
5483
  return {
5379
- circuitJson: [
5380
- ...plated_holes,
5381
- silkscreenBody,
5382
- silkscreenRefText
5383
- ],
5384
- parameters
5484
+ circuitJson: [...pads, silkscreenBody, silkscreenRefText],
5485
+ parameters: {
5486
+ ...params,
5487
+ p,
5488
+ id,
5489
+ pw,
5490
+ pl,
5491
+ w,
5492
+ h,
5493
+ num_pins: numPins,
5494
+ sh: variant === "sh",
5495
+ ph: variant === "ph"
5496
+ }
5385
5497
  };
5386
5498
  };
5387
5499
 
@@ -6759,7 +6871,7 @@ var platedhole_def = z60.object({
6759
6871
  squarepad: v.squarepad ?? false
6760
6872
  };
6761
6873
  });
6762
- var platedhole3 = (raw_params) => {
6874
+ var platedhole2 = (raw_params) => {
6763
6875
  const params = platedhole_def.parse(raw_params);
6764
6876
  const { d, pd, squarepad } = params;
6765
6877
  return {