@tscircuit/footprinter 0.0.31 → 0.0.33

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/README.md CHANGED
@@ -2,19 +2,11 @@
2
2
 
3
3
  Footprinter is tscircuit's DSL and micro-builder for creating footprints.
4
4
 
5
- > Footprinter is the DSL that [text-to-footprint](https://github.com/tscircuit/text-to-footprint) uses.
6
- > If you're unable to generate a particular footprint, try to see if you can produce it in footprinter.
7
- > If you can't, you'll need to add some kind of representation in the DSL before it can be generated.
8
-
9
5
  You can create very custom footprints using the `<footprint>` element, but the
10
6
  compressability is poor. `footprinter` produces very short, low parameter
11
7
  mini-programs for generating footprints, this makes it suitable for standardized
12
8
  footprints.
13
9
 
14
- > [INFO]
15
- > Compressability of the DSL is important because it allows an LLM to fit more examples into context,
16
- > and not waste output tokens on verbose elements
17
-
18
10
  Here are some example programs:
19
11
 
20
12
  ```ts
@@ -28,6 +20,15 @@ fp.dip(4).w(7.62)
28
20
  fp.dip(4).w(7.62).socket()
29
21
  ```
30
22
 
23
+ > [!NOTE]
24
+ > Footprinter is the DSL that [text-to-footprint](https://github.com/tscircuit/text-to-footprint) uses.
25
+ > If you're unable to generate a particular footprint, try to see if you can produce it in footprinter.
26
+ > If you can't, you'll need to add some kind of representation in the DSL before it can be generated.
27
+
28
+ > [!NOTE]
29
+ > Compressability of the DSL is important because it allows an LLM to fit more examples into context,
30
+ > and not waste output tokens on verbose elements
31
+
31
32
  ## Footprinter Strings
32
33
 
33
34
  A footprinter string is a string that maps to a set of builder calls.
package/dist/index.cjs CHANGED
@@ -3220,6 +3220,24 @@ __export(src_exports, {
3220
3220
  });
3221
3221
  module.exports = __toCommonJS(src_exports);
3222
3222
 
3223
+ // src/fn/index.ts
3224
+ var fn_exports = {};
3225
+ __export(fn_exports, {
3226
+ bga: () => bga,
3227
+ cap: () => cap,
3228
+ diode: () => diode,
3229
+ dip: () => dip,
3230
+ led: () => led,
3231
+ mlp: () => mlp,
3232
+ qfn: () => qfn,
3233
+ qfp: () => qfp,
3234
+ quad: () => quad,
3235
+ res: () => res,
3236
+ soic: () => soic,
3237
+ ssop: () => ssop,
3238
+ tssop: () => tssop
3239
+ });
3240
+
3223
3241
  // src/helpers/u-curve.ts
3224
3242
  var u_curve = Array.from(
3225
3243
  { length: 9 },
@@ -3649,11 +3667,11 @@ ${JSON.stringify(
3649
3667
  // src/fn/soic.ts
3650
3668
  var import_zod5 = require("zod");
3651
3669
  var import_soup3 = __toESM(require_dist(), 1);
3652
- var soic_def = import_zod5.z.object({
3670
+ var extendSoicDef = (newDefaults) => import_zod5.z.object({
3653
3671
  soic: import_zod5.z.literal(true),
3654
3672
  num_pins: import_zod5.z.number(),
3655
- w: import_soup3.length.default(import_soup3.length.parse("5.3mm")),
3656
- p: import_soup3.length.default(import_soup3.length.parse("1.27mm")),
3673
+ w: import_soup3.length.default(import_soup3.length.parse(newDefaults.w ?? "5.3mm")),
3674
+ p: import_soup3.length.default(import_soup3.length.parse(newDefaults.p ?? "1.27mm")),
3657
3675
  id: import_soup3.length.optional(),
3658
3676
  od: import_soup3.length.optional()
3659
3677
  }).transform((v) => {
@@ -3667,6 +3685,7 @@ var soic_def = import_zod5.z.object({
3667
3685
  }
3668
3686
  return v;
3669
3687
  });
3688
+ var soic_def = extendSoicDef({});
3670
3689
  var getCcwSoicCoords = (pinCount, pn, w, p) => {
3671
3690
  const ph = pinCount / 2;
3672
3691
  const isLeft = pn <= ph;
@@ -3680,7 +3699,9 @@ var getCcwSoicCoords = (pinCount, pn, w, p) => {
3680
3699
  }
3681
3700
  };
3682
3701
  var soic = (raw_params) => {
3683
- const params = soic_def.parse(raw_params);
3702
+ return soicWithoutParsing(soic_def.parse(raw_params));
3703
+ };
3704
+ var soicWithoutParsing = (params) => {
3684
3705
  const platedHoles = [];
3685
3706
  for (let i = 0; i < params.num_pins; i++) {
3686
3707
  const { x, y } = getCcwSoicCoords(
@@ -4053,6 +4074,24 @@ var mlp = (params) => {
4053
4074
  return quad(params);
4054
4075
  };
4055
4076
 
4077
+ // src/fn/ssop.ts
4078
+ var ssop_def = extendSoicDef({
4079
+ w: "3.9mm",
4080
+ p: "1.27mm"
4081
+ });
4082
+ var ssop = (raw_params) => {
4083
+ return soicWithoutParsing(ssop_def.parse(raw_params));
4084
+ };
4085
+
4086
+ // src/fn/tssop.ts
4087
+ var tssop_def = extendSoicDef({
4088
+ w: "6.1mm",
4089
+ p: "0.65mm"
4090
+ });
4091
+ var tssop = (raw_params) => {
4092
+ return soicWithoutParsing(tssop_def.parse(raw_params));
4093
+ };
4094
+
4056
4095
  // src/helpers/is-not-null.ts
4057
4096
  function isNotNull(value) {
4058
4097
  return value !== null;
@@ -4080,30 +4119,10 @@ var footprinter = () => {
4080
4119
  {},
4081
4120
  {
4082
4121
  get: (target, prop) => {
4083
- console.log(prop, target);
4084
4122
  if (prop === "soup") {
4085
- if ("dip" in target)
4086
- return () => dip(target);
4087
- if ("diode" in target)
4088
- return () => diode(target);
4089
- if ("cap" in target)
4090
- return () => cap(target);
4091
- if ("led" in target)
4092
- return () => led(target);
4093
- if ("res" in target)
4094
- return () => res(target);
4095
- if ("bga" in target)
4096
- return () => bga(target);
4097
- if ("soic" in target)
4098
- return () => soic(target);
4099
- if ("quad" in target)
4100
- return () => quad(target);
4101
- if ("qfn" in target)
4102
- return () => qfn(target);
4103
- if ("qfp" in target)
4104
- return () => qfp(target);
4105
- if ("mlp" in target)
4106
- return () => mlp(target);
4123
+ if ("fn" in target && fn_exports[target.fn]) {
4124
+ return () => fn_exports[target.fn](target);
4125
+ }
4107
4126
  return () => {
4108
4127
  throw new Error(
4109
4128
  `No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${prop}"`
@@ -4116,12 +4135,13 @@ var footprinter = () => {
4116
4135
  return (v) => {
4117
4136
  if (Object.keys(target).length === 0) {
4118
4137
  target[prop] = true;
4138
+ target.fn = prop;
4119
4139
  if (prop === "res" || prop === "cap") {
4120
4140
  if (v) {
4121
4141
  target.imperial = v;
4122
4142
  }
4123
4143
  } else {
4124
- target.num_pins = parseFloat(v);
4144
+ target.num_pins = Number.parseFloat(v);
4125
4145
  }
4126
4146
  } else {
4127
4147
  if (!v && ["w", "h", "p"].includes(prop)) {