Packages
A package is a circuit module distributed on npm: npm install a voltage regulator,
an MCU subsystem, or a complete reference design, and one constructor call drops the whole
sub-circuit — parts, passives, connections, and placement — onto the board. To publish your own,
see Package authoring.
using a package
Packages are installed in the hw/ directory — that's where the build runs. Import the class, construct it with a PCB and a position, and create its components like any others.
Example first
cd hw
npm install @typecad/rd-bq24210import { PCB } from '@typecad/pcb';
import { RD_BQ24210 } from '@typecad/rd-bq24210';
let typecad = new PCB('solar_charger');
let charger = new RD_BQ24210({
pcb: typecad,
x: 40,
y: 30, // where the module lands on the board
});
// wire to the module like any other component
typecad.named('VBUS').net(charger.VBUS, j1.pin(1));
typecad.create(...charger.components);Everything inside the package is reachable as public properties — read pins to wire to it, exactly like a generated component file:
Constructor options
| Option | Type | Description |
|---|---|---|
| pcb | PCB | required — the board the package lands on |
| x, y | number | required — where the module sits; every part inside is offset from it |
| reference | string | Reference prefix override |
| name | string | The KiCAD group name (defaults to the class name) |
| passiveSize | PassiveSize | Chip size the package’s built-in passives use (default ’0603’) |
| passives | PassiveFactory | Swap the passive factories out entirely |
Do not populate
Individual parts of a package can be marked DNP after construction — they stay in the schematic but drop out of the BOM and assembly:
charger.STATUS_LED.dnp = true; // keep it in the design, skip it in the BOMCustom options
Packages define their own options alongside the standard ones — a charger might take a sense resistor value, a regulator its output voltage:
// package side — options extend PackageOptions
export class RD_BQ24210 extends Package<{ isense?: number }> { ... }
// consumer side — they arrive as constructor options
let charger = new RD_BQ24210({ pcb: typecad, x: 40, y: 30, isense: 0.05 });