npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tscircuit/footprinter

v0.0.89

Published

[Online Gallery](https://tscircuit.github.io/footprinter/) · [discord](https://tscircuit.com/join) · [main tscircuit repo](https://github.com/tscircuit/tscircuit)

Downloads

24,785

Readme

@tscircuit/footprinter

Online Gallery · discord · main tscircuit repo

Footprinter is tscircuit's DSL and micro-builder for creating footprints.

image

You can create very custom footprints using the <footprint> element, but the compressability is poor. footprinter produces very short, low parameter mini-programs for generating footprints, this makes it suitable for standardized footprints. You can use it with any component that accepts a footprint prop, e.g. <chip footprint="qfp12_p0.5" />

Here are some example footprinter strings:

0402
0603
cap0402
res0805
soic8_p1.27mm
dip16
pinrow10
tssop20_p0.5mm
sot23
qfn24_w6_h6_p0.8mm_thermalpad_startingpin(topside,rightpin)_ccw
axial_p0.2in

You can use these like so:

const circuitJson = fp.string("dip8_w0.5in").circuitJson()
const parameters = fp.string("dip8_w0.5in").parameters()

You can also programmatically build footprints like so:

import { fp } from "@tscircuit/footprinter"

fp.cap().w(0.4).h(0.2)
fp.cap().p(0.1).pw(0.1).ph(0.1) // pitch, pad width and pad height
fp.cap().metric("0402")
fp.res().imperial("01005")
fp.dip(4).w(7.62)
fp.dip(4).w(7.62).socket()

[!TIP] Footprinter is the DSL that text-to-footprint uses. If you're unable to generate a particular footprint, try to see if you can produce it in footprinter. If you can't, you'll need to add some kind of representation in the DSL before it can be generated.

[!NOTE] Compressability of the DSL is important because it allows an LLM to fit more examples into context, and not waste output tokens on verbose elements

Contributing

Watch this getting started with footprinter contribution guide!

Footprinter Strings

A footprinter string is a string that maps to a set of builder calls.

import { fp } from "@tscircuit/footprinter"

fp.string("dip4_w7.62") // same as fp.dip(4).w(7.62)
fp.string("dip4_w7.62mm") // same as fp.dip(4).w(7.62)
fp.string("dip4_w0.3in") // same as fp.dip(4).w("0.3in")

Getting JSON output from the builder

Use the .soup() function to output tscircuit soup JSON

fp.string("res0402").soup()
/*
[
  {
    type: 'pcb_smtpad',
    x: -0.5,
    y: 0,
    width: 0.6000000000000001,
    height: 0.6000000000000001,
    layer: 'top',
    shape: 'rect',
    pcb_smtpad_id: '',
    port_hints: [ '1' ]
  },
  {
    type: 'pcb_smtpad',
    x: 0.5,
    y: 0,
    width: 0.6000000000000001,
    height: 0.6000000000000001,
    layer: 'top',
    shape: 'rect',
    pcb_smtpad_id: '',
    port_hints: [ '2' ]
  }
]
*/

Generation Defaults

  • Pins are CCW starting at the top left
  • Y is upward-positive, X is rightward-positive

Slop

Slop is a "sloppy" definition, it really doesn't have enough information to draw a footprint, i.e. it's missing critical dimensions.

footprinter is extremely tolerant to Slop, because it's useful when you're iterating incrementally towards a fully constrained design, or when you're using footprinter strings as an output format for an AI.

Generally when footprinter is interpreting a sloppy definition, it will use industry best practices or otherwise "reasonable" defaults. In theory, upgrading footprinter could cause the defaults to change, which is why sloppy definitions are generally not desirable.

An example of a sloppy definition is bga64. It's very underconstrained and unlikely to be correct (what's the pitch? pad size?). tscircuit strict mode or a linter will eventually error if it sees these.

Adding a new footprint function

You can add new footprint functions by introducing a new function in the src/fn directory. You'll also need to export it from the footprint function index file

After you've written the function, you can introduce a quick test, e.g. soic.test.ts Currently it's not possible to see if a given definition is sloppy.

To run tests, just run npx ava ./tests/soic.test.ts or whatever your test file is.

You'll sometimes see this logSoup function- this makes some debug output appear at https://debug.tscircuit.com. Make sure to hit "pcb" and "pcb_renderer" after the design.