@tscircuit/footprinter 0.0.183 → 0.0.185

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
@@ -997,7 +997,7 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
997
997
  legsoutside?: boolean | undefined;
998
998
  }>, z.ZodObject<{
999
999
  tht: z.ZodBoolean;
1000
- p: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
1000
+ p: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
1001
1001
  pw: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
1002
1002
  ph: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
1003
1003
  metric: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
@@ -1005,18 +1005,18 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
1005
1005
  w: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
1006
1006
  h: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
1007
1007
  }, "strip", z.ZodTypeAny, {
1008
- p: number;
1009
1008
  tht: boolean;
1010
1009
  w?: number | undefined;
1010
+ p?: number | undefined;
1011
1011
  pw?: number | undefined;
1012
1012
  ph?: number | undefined;
1013
1013
  metric?: number | undefined;
1014
1014
  imperial?: number | undefined;
1015
1015
  h?: number | undefined;
1016
1016
  }, {
1017
- p: string | number;
1018
1017
  tht: boolean;
1019
1018
  w?: string | number | undefined;
1019
+ p?: string | number | undefined;
1020
1020
  pw?: string | number | undefined;
1021
1021
  ph?: string | number | undefined;
1022
1022
  metric?: string | number | undefined;
@@ -1120,14 +1120,16 @@ declare const any_footprinter_def: z.ZodUnion<[z.ZodObject<{
1120
1120
  }>]>;
1121
1121
  type AnyFootprinterDefinitionOutput = z.infer<typeof any_footprinter_def>;
1122
1122
 
1123
- declare const footprintSizes: {
1123
+ type StandardSize = {
1124
1124
  imperial: string;
1125
1125
  metric: string;
1126
- Z_mm_min: number;
1127
- G_mm_min: number;
1128
- X_mm_min: number;
1129
- C_mm_ref: number;
1130
- }[];
1126
+ p_mm_min: number;
1127
+ ph_mm_min: number;
1128
+ pw_mm_min: number;
1129
+ h_mm_min: number;
1130
+ w_mm_min: number;
1131
+ };
1132
+ declare const footprintSizes: StandardSize[];
1131
1133
 
1132
1134
  type FootprinterParamsBuilder<K extends string> = {
1133
1135
  [P in K | "params" | "soup" | "circuitJson"]: P extends "params" | "soup" | "circuitJson" ? Footprinter[P] : (v?: number | string | boolean) => FootprinterParamsBuilder<K>;
package/dist/index.js CHANGED
@@ -271,111 +271,96 @@ var rectpad = (pn, x, y, w, h) => {
271
271
  import mm2 from "@tscircuit/mm";
272
272
  import { z as z2 } from "zod";
273
273
  import { length, distance } from "circuit-json";
274
-
275
- // src/helpers/silkscreenpath.ts
276
- var silkscreenpath = (route, options = {}) => {
277
- return {
278
- type: "pcb_silkscreen_path",
279
- layer: options.layer || "top",
280
- pcb_component_id: options.pcb_component_id || "",
281
- pcb_silkscreen_path_id: options.pcb_silkscreen_path_id || "",
282
- route,
283
- stroke_width: options.stroke_width || 0.1
284
- };
285
- };
286
-
287
- // src/helpers/passive-fn.ts
288
274
  var footprintSizes = [
289
275
  {
290
276
  imperial: "01005",
291
277
  metric: "0402",
292
- Z_mm_min: 0.58,
293
- G_mm_min: 0.18,
294
- X_mm_min: 0.21,
295
- C_mm_ref: 0.038
278
+ p_mm_min: 0.038,
279
+ pw_mm_min: 0.2,
280
+ ph_mm_min: 0.2,
281
+ w_mm_min: 0.58,
282
+ h_mm_min: 0.21
296
283
  },
297
284
  {
298
285
  imperial: "0201",
299
286
  metric: "0603",
300
- Z_mm_min: 0.9,
301
- G_mm_min: 0.3,
302
- X_mm_min: 0.3,
303
- C_mm_ref: 0.6
287
+ p_mm_min: 0.6,
288
+ pw_mm_min: 0.3,
289
+ ph_mm_min: 0.3,
290
+ w_mm_min: 0.9,
291
+ h_mm_min: 0.3
304
292
  },
305
293
  {
306
294
  imperial: "0402",
307
295
  metric: "1005",
308
- Z_mm_min: 1.6,
309
- G_mm_min: 0.4,
310
- X_mm_min: 0.7,
311
- C_mm_ref: 1
296
+ p_mm_min: 1,
297
+ pw_mm_min: 0.6,
298
+ ph_mm_min: 0.6,
299
+ w_mm_min: 1.6,
300
+ h_mm_min: 0.7
312
301
  },
313
302
  {
314
303
  imperial: "0603",
315
304
  metric: "1608",
316
- Z_mm_min: 2.6,
317
- G_mm_min: 0.6,
318
- X_mm_min: 1,
319
- C_mm_ref: 1.7
305
+ p_mm_min: 1.6,
306
+ pw_mm_min: 0.85,
307
+ ph_mm_min: 0.95,
308
+ w_mm_min: 2.6,
309
+ h_mm_min: 1
320
310
  },
321
311
  {
322
312
  imperial: "0805",
323
313
  metric: "2012",
324
- Z_mm_min: 3,
325
- G_mm_min: 0.6,
326
- X_mm_min: 1.2,
327
- C_mm_ref: 1.9
314
+ p_mm_min: 2.15,
315
+ pw_mm_min: 0.85,
316
+ ph_mm_min: 1.2,
317
+ w_mm_min: 3,
318
+ h_mm_min: 1.2
328
319
  },
329
320
  {
330
321
  imperial: "1206",
331
322
  metric: "3216",
332
- Z_mm_min: 4.2,
333
- G_mm_min: 1.2,
334
- X_mm_min: 1.4,
335
- C_mm_ref: 2.8
323
+ p_mm_min: 3.2,
324
+ pw_mm_min: 1,
325
+ ph_mm_min: 1.9,
326
+ w_mm_min: 4.2,
327
+ h_mm_min: 2.5
336
328
  },
337
329
  {
338
330
  imperial: "1210",
339
331
  metric: "3225",
340
- Z_mm_min: 3.2,
341
- G_mm_min: 1,
342
- X_mm_min: 2.5,
343
- C_mm_ref: 2
332
+ p_mm_min: 2.8,
333
+ pw_mm_min: 1.25,
334
+ ph_mm_min: 2.65,
335
+ w_mm_min: 4.5,
336
+ h_mm_min: 3.3
344
337
  },
345
338
  {
346
339
  imperial: "2010",
347
340
  metric: "5025",
348
- Z_mm_min: 5,
349
- G_mm_min: 1.2,
350
- X_mm_min: 2.5,
351
- C_mm_ref: 3.6
341
+ p_mm_min: 3.6,
342
+ pw_mm_min: 1.2,
343
+ ph_mm_min: 1.2,
344
+ w_mm_min: 5,
345
+ h_mm_min: 2.5
352
346
  },
353
347
  {
354
348
  imperial: "2512",
355
349
  metric: "6332",
356
- Z_mm_min: 6.3,
357
- G_mm_min: 1.2,
358
- X_mm_min: 3.2,
359
- C_mm_ref: 4.5
350
+ p_mm_min: 4.5,
351
+ pw_mm_min: 1.6,
352
+ ph_mm_min: 1.6,
353
+ w_mm_min: 6.3,
354
+ h_mm_min: 3.2
360
355
  }
361
356
  ];
362
- var metricMap = footprintSizes.reduce(
363
- (acc, s) => {
364
- acc[s.metric] = s;
365
- return acc;
366
- },
367
- {}
368
- );
369
- var imperialMap = footprintSizes.reduce(
370
- (acc, s) => {
371
- acc[s.imperial] = s;
372
- return acc;
373
- },
374
- {}
357
+ var metricMap = Object.fromEntries(footprintSizes.map((s) => [s.metric, s]));
358
+ var imperialMap = Object.fromEntries(
359
+ footprintSizes.map((s) => [s.imperial, s])
375
360
  );
376
361
  var passive_def = z2.object({
377
362
  tht: z2.boolean(),
378
- p: length,
363
+ p: length.optional(),
379
364
  pw: length.optional(),
380
365
  ph: length.optional(),
381
366
  metric: distance.optional(),
@@ -383,10 +368,6 @@ var passive_def = z2.object({
383
368
  w: length.optional(),
384
369
  h: length.optional()
385
370
  });
386
- var deriveXFromH = (h) => 0.079 * h ** 2 + 0.94 * h - 9e-3;
387
- var deriveZFromW = (w) => 1.09 * w + 0.6;
388
- var deriveGFromW = (w) => 0.59 * w - 0.31;
389
- var deriveCFromW = (w) => -0.01 * w ** 2 + 0.94 * w + 0.03;
390
371
  var passive = (params) => {
391
372
  let { tht, p, pw, ph, metric, imperial, w, h } = params;
392
373
  if (typeof w === "string") w = mm2(w);
@@ -394,37 +375,24 @@ var passive = (params) => {
394
375
  if (typeof p === "string") p = mm2(p);
395
376
  if (typeof pw === "string") pw = mm2(pw);
396
377
  if (typeof ph === "string") ph = mm2(ph);
397
- if (h > w) {
378
+ if (h !== void 0 && w !== void 0 && h > w) {
398
379
  throw new Error(
399
380
  "height cannot be greater than width (rotated footprint not yet implemented)"
400
381
  );
401
382
  }
402
383
  let sz;
403
- if (metric) {
404
- sz = metricMap[metric];
405
- }
406
- if (imperial) {
407
- sz = imperialMap[imperial];
408
- }
409
- if (!sz && w && h && !pw && !ph) {
410
- sz = {
411
- imperial: "custom",
412
- metric: "custom",
413
- Z_mm_min: deriveZFromW(w),
414
- G_mm_min: deriveGFromW(w),
415
- X_mm_min: deriveXFromH(h),
416
- C_mm_ref: deriveCFromW(w)
417
- };
418
- }
384
+ if (metric) sz = metricMap[metric];
385
+ if (imperial) sz = imperialMap[imperial];
419
386
  if (sz) {
420
- w = sz.Z_mm_min;
421
- h = sz.X_mm_min;
422
- p = sz.C_mm_ref;
423
- pw = (sz.Z_mm_min - sz.G_mm_min) / 2;
424
- ph = (sz.Z_mm_min - sz.G_mm_min) / 2;
425
- }
426
- if (pw === void 0) throw new Error("could not infer pad width");
427
- if (ph === void 0) throw new Error("could not infer pad width");
387
+ w = sz.w_mm_min;
388
+ h = sz.h_mm_min;
389
+ p = sz.p_mm_min;
390
+ pw = sz.pw_mm_min;
391
+ ph = sz.ph_mm_min;
392
+ }
393
+ if (p === void 0 || pw === void 0 || ph === void 0) {
394
+ throw new Error("Could not determine required pad dimensions (p, pw, ph)");
395
+ }
428
396
  const silkscreenLine = {
429
397
  type: "pcb_silkscreen_path",
430
398
  layer: "top",
@@ -2047,6 +2015,20 @@ var axial = (raw_params) => {
2047
2015
  // src/fn/pushbutton.ts
2048
2016
  import { length as length9 } from "circuit-json";
2049
2017
  import { z as z15 } from "zod";
2018
+
2019
+ // src/helpers/silkscreenpath.ts
2020
+ var silkscreenpath = (route, options = {}) => {
2021
+ return {
2022
+ type: "pcb_silkscreen_path",
2023
+ layer: options.layer || "top",
2024
+ pcb_component_id: options.pcb_component_id || "",
2025
+ pcb_silkscreen_path_id: options.pcb_silkscreen_path_id || "",
2026
+ route,
2027
+ stroke_width: options.stroke_width || 0.1
2028
+ };
2029
+ };
2030
+
2031
+ // src/fn/pushbutton.ts
2050
2032
  var pushbutton_def = z15.object({
2051
2033
  fn: z15.literal("pushbutton"),
2052
2034
  w: length9.default(4.5),
@@ -6415,7 +6397,7 @@ var electrolytic = (raw_params) => {
6415
6397
  const X = -(d / 2 + 0.5);
6416
6398
  const plusY = od / 2 + 1.5;
6417
6399
  const Size = 0.5;
6418
- const silkscreenpath3 = {
6400
+ const silkscreenpath2 = {
6419
6401
  type: "pcb_silkscreen_path",
6420
6402
  layer: "top",
6421
6403
  pcb_component_id: "",
@@ -6444,7 +6426,7 @@ var electrolytic = (raw_params) => {
6444
6426
  silkscreenBody2,
6445
6427
  silkscreenBody3,
6446
6428
  silkscreenBody,
6447
- silkscreenpath3,
6429
+ silkscreenpath2,
6448
6430
  silkscreenline,
6449
6431
  silkscreenRefText
6450
6432
  ],