@tscircuit/footprinter 0.0.137 → 0.0.139

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
@@ -358,6 +358,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
358
358
  }>, z.ZodEffects<z.ZodEffects<z.ZodObject<{
359
359
  fn: z.ZodString;
360
360
  num_pins: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
361
+ rows: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>>;
361
362
  p: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
362
363
  id: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
363
364
  od: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
@@ -369,6 +370,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
369
370
  p: number;
370
371
  id: number;
371
372
  od: number;
373
+ rows: number;
372
374
  male?: boolean | undefined;
373
375
  female?: boolean | undefined;
374
376
  }, {
@@ -377,6 +379,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
377
379
  p?: string | number | undefined;
378
380
  id?: string | number | undefined;
379
381
  od?: string | number | undefined;
382
+ rows?: string | number | undefined;
380
383
  male?: boolean | undefined;
381
384
  female?: boolean | undefined;
382
385
  }>, {
@@ -387,12 +390,14 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
387
390
  p: number;
388
391
  id: number;
389
392
  od: number;
393
+ rows: number;
390
394
  }, {
391
395
  fn: string;
392
396
  num_pins?: number | undefined;
393
397
  p?: string | number | undefined;
394
398
  id?: string | number | undefined;
395
399
  od?: string | number | undefined;
400
+ rows?: string | number | undefined;
396
401
  male?: boolean | undefined;
397
402
  female?: boolean | undefined;
398
403
  }>, {
@@ -403,12 +408,14 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
403
408
  p: number;
404
409
  id: number;
405
410
  od: number;
411
+ rows: number;
406
412
  }, {
407
413
  fn: string;
408
414
  num_pins?: number | undefined;
409
415
  p?: string | number | undefined;
410
416
  id?: string | number | undefined;
411
417
  od?: string | number | undefined;
418
+ rows?: string | number | undefined;
412
419
  male?: boolean | undefined;
413
420
  female?: boolean | undefined;
414
421
  }>, z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
@@ -1000,7 +1007,7 @@ type Footprinter = {
1000
1007
  ssop: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
1001
1008
  tssop: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
1002
1009
  dfn: (num_pins?: number) => FootprinterParamsBuilder<"w" | "p">;
1003
- pinrow: (num_pins?: number) => FootprinterParamsBuilder<"p" | "id" | "od" | "male" | "female">;
1010
+ pinrow: (num_pins?: number) => FootprinterParamsBuilder<"p" | "id" | "od" | "male" | "female" | "rows">;
1004
1011
  axial: () => FootprinterParamsBuilder<"p" | "id" | "od">;
1005
1012
  hc49: () => FootprinterParamsBuilder<"p" | "id" | "od" | "w" | "h">;
1006
1013
  to220: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "od">;
@@ -1032,6 +1039,7 @@ type Footprinter = {
1032
1039
  sod123: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1033
1040
  sod123w: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1034
1041
  to92: () => FootprinterParamsBuilder<"w" | "h" | "p" | "id" | "od" | "inline">;
1042
+ sot223: () => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw">;
1035
1043
  pushbutton: () => FootprinterParamsBuilder<"tllabel" | "trlabel" | "bllabel" | "brlabel">;
1036
1044
  stampboard: () => FootprinterParamsBuilder<"w" | "h" | "left" | "right" | "top" | "bottom" | "p" | "pw" | "pl" | "innerhole" | "innerholeedgedistance">;
1037
1045
  stampreceiver: () => FootprinterParamsBuilder<"w" | "h" | "left" | "right" | "top" | "bottom" | "p" | "pw" | "pl" | "innerhole" | "innerholeedgedistance">;
package/dist/index.js CHANGED
@@ -47,6 +47,7 @@ __export(fn_exports, {
47
47
  sod923: () => sod923,
48
48
  soic: () => soic,
49
49
  sop8: () => sop8,
50
+ sot223: () => sot223,
50
51
  sot23: () => sot23,
51
52
  sot363: () => sot363,
52
53
  sot563: () => sot563,
@@ -1435,6 +1436,7 @@ import { length as length5 } from "circuit-json";
1435
1436
  var pinrow_def = z11.object({
1436
1437
  fn: z11.string(),
1437
1438
  num_pins: z11.number().optional().default(6),
1439
+ rows: z11.union([z11.string(), z11.number()]).transform((val) => Number(val)).optional().default(1).describe("number of rows"),
1438
1440
  p: length5.default("0.1in").describe("pitch"),
1439
1441
  id: length5.default("1.0mm").describe("inner diameter"),
1440
1442
  od: length5.default("1.5mm").describe("outer diameter"),
@@ -1443,29 +1445,56 @@ var pinrow_def = z11.object({
1443
1445
  }).transform((data) => ({
1444
1446
  ...data,
1445
1447
  male: data.male ?? (data.female ? false : true),
1446
- // Auto-set male if not explicitly provided
1447
1448
  female: data.female ?? false
1448
- // Default female to false if not provided
1449
1449
  })).superRefine((data, ctx) => {
1450
1450
  if (data.male && data.female) {
1451
1451
  ctx.addIssue({
1452
1452
  code: z11.ZodIssueCode.custom,
1453
- message: "'male' and 'female' cannot both be true it should be male or female.",
1454
- //Error message if male and female are both true
1453
+ message: "'male' and 'female' cannot both be true; it should be male or female.",
1455
1454
  path: ["male", "female"]
1456
1455
  });
1457
1456
  }
1458
1457
  });
1459
1458
  var pinrow = (raw_params) => {
1460
1459
  const parameters = pinrow_def.parse(raw_params);
1461
- const { p, id, od } = parameters;
1460
+ const { p, id, od, rows } = parameters;
1462
1461
  const holes = [];
1463
- const ns = parameters.num_pins - 1;
1464
- const xoff = -(ns / 2) * p;
1465
- for (let i = 0; i < parameters.num_pins; i++) {
1466
- holes.push(platedhole(i + 1, xoff + i * p, 0, id, od));
1462
+ const num_pins = parameters.num_pins;
1463
+ if (rows > 1) {
1464
+ const num_pins_per_row = Math.ceil(num_pins / rows);
1465
+ const ySpacing = p;
1466
+ for (let row = 0; row < rows; row++) {
1467
+ const yoff = row * ySpacing;
1468
+ const startPin = row * num_pins_per_row;
1469
+ for (let pinIndex = 0; pinIndex < num_pins_per_row; pinIndex++) {
1470
+ const pinNumber = startPin + pinIndex + 1;
1471
+ if (pinNumber > num_pins)
1472
+ break;
1473
+ const xoff = pinIndex * p;
1474
+ holes.push(platedhole(pinNumber, xoff, yoff, id, od));
1475
+ }
1476
+ }
1477
+ } else {
1478
+ const num_spaces = num_pins - 1;
1479
+ const xoff = -(num_spaces / 2) * p;
1480
+ for (let i = 0; i < num_pins; i++) {
1481
+ holes.push(platedhole(i + 1, xoff + i * p, 0, id, od));
1482
+ }
1467
1483
  }
1468
- const silkscreenRefText = silkscreenRef(0, p / 2, 0.5);
1484
+ if (rows === 1) {
1485
+ const silkscreenRefText2 = silkscreenRef(0, rows * p, 0.5);
1486
+ return {
1487
+ circuitJson: [...holes, silkscreenRefText2],
1488
+ parameters
1489
+ };
1490
+ }
1491
+ const silkscreenRefText = silkscreenRef(
1492
+ (num_pins / rows - 1) * p / 2,
1493
+ // Center the silkscreen horizontally
1494
+ rows * p,
1495
+ // Keep it at the top vertically
1496
+ 0.5
1497
+ );
1469
1498
  return {
1470
1499
  circuitJson: [...holes, silkscreenRefText],
1471
1500
  parameters
@@ -4310,6 +4339,261 @@ var smcWithoutParsing = (parameters) => {
4310
4339
  return pads;
4311
4340
  };
4312
4341
 
4342
+ // src/fn/sot223.ts
4343
+ import { z as z41 } from "zod";
4344
+ var sot223_def = z41.object({
4345
+ fn: z41.string(),
4346
+ num_pins: z41.number().default(4),
4347
+ w: z41.string().default("8.50mm"),
4348
+ h: z41.string().default("6.90mm"),
4349
+ pl: z41.string().default("2mm"),
4350
+ pw: z41.string().default("1.5mm"),
4351
+ p: z41.string().default("2.30mm"),
4352
+ string: z41.string().optional()
4353
+ });
4354
+ var sot223 = (raw_params) => {
4355
+ const match = raw_params.string?.match(/^sot223_(\d+)/);
4356
+ const numPins = match ? Number.parseInt(match[1], 10) : 4;
4357
+ if (numPins === 8) {
4358
+ const parameters2 = sot223_8_def.parse({
4359
+ ...raw_params,
4360
+ num_pins: numPins
4361
+ });
4362
+ return {
4363
+ circuitJson: soicWithoutParsing(parameters2),
4364
+ parameters: parameters2
4365
+ };
4366
+ }
4367
+ const parameters = sot223_def.parse({
4368
+ ...raw_params,
4369
+ num_pins: numPins
4370
+ });
4371
+ if (parameters.num_pins === 4) {
4372
+ return {
4373
+ circuitJson: sot223_4(parameters),
4374
+ parameters
4375
+ };
4376
+ }
4377
+ if (parameters.num_pins === 5) {
4378
+ return {
4379
+ circuitJson: sot223_5(parameters),
4380
+ parameters
4381
+ };
4382
+ }
4383
+ if (parameters.num_pins === 6) {
4384
+ return {
4385
+ circuitJson: sot223_6(parameters),
4386
+ parameters
4387
+ };
4388
+ }
4389
+ throw new Error("Invalid number of pins");
4390
+ };
4391
+ var get2CcwSot223Coords = (parameters) => {
4392
+ const { pn, w, h, pl, p } = parameters;
4393
+ if (pn === 1) {
4394
+ return { x: -w / 2 + 1.1, y: p };
4395
+ }
4396
+ if (pn === 2) {
4397
+ return { x: -w / 2 + 1.1, y: 0 };
4398
+ }
4399
+ if (pn === 3) {
4400
+ return { x: -w / 2 + 1.1, y: -p };
4401
+ }
4402
+ return { x: w / 2 - 1.1, y: 0 };
4403
+ };
4404
+ var sot223_4 = (parameters) => {
4405
+ const pads = [];
4406
+ for (let i = 0; i < parameters.num_pins; i++) {
4407
+ const { x, y } = get2CcwSot223Coords({
4408
+ num_pins: parameters.num_pins,
4409
+ pn: i + 1,
4410
+ w: Number.parseFloat(parameters.w),
4411
+ h: Number.parseFloat(parameters.h),
4412
+ pl: Number.parseFloat(parameters.pl),
4413
+ p: Number.parseFloat(parameters.p)
4414
+ });
4415
+ const pinWidth = i === 3 ? 3.8 : Number.parseFloat(parameters.pw);
4416
+ pads.push(rectpad(i + 1, x, y, Number.parseFloat(parameters.pl), pinWidth));
4417
+ }
4418
+ const silkscreenRefText = silkscreenRef(0, 0, 0.3);
4419
+ const width = Number.parseFloat(parameters.w) / 2 - 2.4;
4420
+ const height = Number.parseFloat(parameters.h) / 2;
4421
+ const silkscreenPath1 = {
4422
+ layer: "top",
4423
+ pcb_component_id: "",
4424
+ pcb_silkscreen_path_id: "silkscreen_path_1",
4425
+ route: [
4426
+ { x: -width, y: height },
4427
+ { x: width, y: height },
4428
+ { x: width, y: height / 2 + 0.5 }
4429
+ ],
4430
+ type: "pcb_silkscreen_path",
4431
+ stroke_width: 0.1
4432
+ };
4433
+ const silkscreenPath2 = {
4434
+ layer: "top",
4435
+ pcb_component_id: "",
4436
+ pcb_silkscreen_path_id: "silkscreen_path_2",
4437
+ route: [
4438
+ { x: -width, y: -height },
4439
+ { x: width, y: -height },
4440
+ { x: width, y: -height / 2 - 0.5 }
4441
+ ],
4442
+ type: "pcb_silkscreen_path",
4443
+ stroke_width: 0.1
4444
+ };
4445
+ return [
4446
+ ...pads,
4447
+ silkscreenPath1,
4448
+ silkscreenPath2,
4449
+ silkscreenRefText
4450
+ ];
4451
+ };
4452
+ var sot223_8_def = extendSoicDef({
4453
+ p: "0.90mm",
4454
+ w: "2.8mm",
4455
+ legsoutside: true
4456
+ });
4457
+ var get2CcwSot2235Coords = (parameters) => {
4458
+ const { p, h, pn, w } = parameters;
4459
+ if (pn === 1) {
4460
+ return { x: -w / 2 + 1.2, y: p / 2 + p };
4461
+ }
4462
+ if (pn === 2) {
4463
+ return { x: -w / 2 + 1.2, y: p / 2 };
4464
+ }
4465
+ if (pn === 3) {
4466
+ return { x: -w / 2 + 1.2, y: -p / 2 };
4467
+ }
4468
+ if (pn === 4) {
4469
+ return { x: -w / 2 + 1.2, y: -p / 2 - p };
4470
+ }
4471
+ if (pn === 5) {
4472
+ return { x: w / 2 - 1, y: 0 };
4473
+ }
4474
+ throw new Error("Invalid pin number");
4475
+ };
4476
+ var sot223_5 = (parameters) => {
4477
+ const pads = [];
4478
+ for (let i = 1; i <= parameters.num_pins; i++) {
4479
+ const { x, y } = get2CcwSot2235Coords({
4480
+ h: Number.parseFloat(parameters.h),
4481
+ p: 1.5,
4482
+ pn: i,
4483
+ w: Number.parseFloat(parameters.w)
4484
+ });
4485
+ let pinWidth = Number.parseFloat(parameters.pw);
4486
+ let pinLength = Number.parseFloat(parameters.pl);
4487
+ if (i === 5) {
4488
+ pinWidth = 3.4;
4489
+ pinLength = 1.8;
4490
+ } else {
4491
+ pinWidth = 1;
4492
+ pinLength = 2.2;
4493
+ }
4494
+ pads.push(rectpad(i, x, y, pinLength, pinWidth));
4495
+ }
4496
+ const width = Number.parseFloat(parameters.w) / 2 - 2.4;
4497
+ const height = Number.parseFloat(parameters.h) / 2;
4498
+ const silkscreenPath1 = {
4499
+ layer: "top",
4500
+ pcb_component_id: "",
4501
+ pcb_silkscreen_path_id: "silkscreen_path_1",
4502
+ route: [
4503
+ { x: -width, y: height },
4504
+ { x: width, y: height },
4505
+ { x: width, y: height / 2 + 0.5 }
4506
+ ],
4507
+ type: "pcb_silkscreen_path",
4508
+ stroke_width: 0.1
4509
+ };
4510
+ const silkscreenPath2 = {
4511
+ layer: "top",
4512
+ pcb_component_id: "",
4513
+ pcb_silkscreen_path_id: "silkscreen_path_2",
4514
+ route: [
4515
+ { x: -width, y: -height },
4516
+ { x: width, y: -height },
4517
+ { x: width, y: -height / 2 - 0.5 }
4518
+ ],
4519
+ type: "pcb_silkscreen_path",
4520
+ stroke_width: 0.1
4521
+ };
4522
+ const silkscreenRefText = silkscreenRef(0, 0, 0.3);
4523
+ return [...pads, silkscreenPath1, silkscreenPath2, silkscreenRefText];
4524
+ };
4525
+ var get2CcwSot2236Coords = (parameters) => {
4526
+ const { p, h, pn, w } = parameters;
4527
+ if (pn === 1) {
4528
+ return { x: -w / 2 + 1.2, y: 2 * p };
4529
+ }
4530
+ if (pn === 2) {
4531
+ return { x: -w / 2 + 1.2, y: p };
4532
+ }
4533
+ if (pn === 3) {
4534
+ return { x: -w / 2 + 1.2, y: 0 };
4535
+ }
4536
+ if (pn === 4) {
4537
+ return { x: -w / 2 + 1.2, y: -p };
4538
+ }
4539
+ if (pn === 5) {
4540
+ return { x: -w / 2 + 1.2, y: -2 * p };
4541
+ }
4542
+ if (pn === 6) {
4543
+ return { x: w / 2 - 1.175, y: 0 };
4544
+ }
4545
+ throw new Error("Invalid pin number");
4546
+ };
4547
+ var sot223_6 = (parameters) => {
4548
+ const pads = [];
4549
+ for (let i = 1; i <= parameters.num_pins; i++) {
4550
+ const { x, y } = get2CcwSot2236Coords({
4551
+ h: Number.parseFloat(parameters.h),
4552
+ p: 1.3,
4553
+ pn: i,
4554
+ w: 8.7
4555
+ });
4556
+ let pinWidth = Number.parseFloat(parameters.pw);
4557
+ let pinLength = Number.parseFloat(parameters.pl);
4558
+ if (i === 6) {
4559
+ pinWidth = 3.4;
4560
+ pinLength = 2.15;
4561
+ } else {
4562
+ pinWidth = 0.6;
4563
+ pinLength = 2.2;
4564
+ }
4565
+ pads.push(rectpad(i, x, y, pinLength, pinWidth));
4566
+ }
4567
+ const width = Number.parseFloat(parameters.w) / 2 - 2.4;
4568
+ const height = Number.parseFloat(parameters.h) / 2;
4569
+ const silkscreenPath1 = {
4570
+ layer: "top",
4571
+ pcb_component_id: "",
4572
+ pcb_silkscreen_path_id: "silkscreen_path_1",
4573
+ route: [
4574
+ { x: -width, y: height },
4575
+ { x: width, y: height },
4576
+ { x: width, y: height / 2 + 0.5 }
4577
+ ],
4578
+ type: "pcb_silkscreen_path",
4579
+ stroke_width: 0.1
4580
+ };
4581
+ const silkscreenPath2 = {
4582
+ layer: "top",
4583
+ pcb_component_id: "",
4584
+ pcb_silkscreen_path_id: "silkscreen_path_2",
4585
+ route: [
4586
+ { x: -width, y: -height },
4587
+ { x: width, y: -height },
4588
+ { x: width, y: -height / 2 - 0.5 }
4589
+ ],
4590
+ type: "pcb_silkscreen_path",
4591
+ stroke_width: 0.1
4592
+ };
4593
+ const silkscreenRefText = silkscreenRef(0, 0, 0.3);
4594
+ return [...pads, silkscreenPath1, silkscreenPath2, silkscreenRefText];
4595
+ };
4596
+
4313
4597
  // src/helpers/is-not-null.ts
4314
4598
  function isNotNull(value) {
4315
4599
  return value !== null;