
Research
/Security News
Shai Hulud Strikes Again (v2)
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.
calculate-packing
Advanced tools
calculate-packing is a small TypeScript library that ships the placement / packing algorithm used by the tscircuit tool-chain for automatically laying out PCB components.
Paste PackInput and Debug Online
The solver turns a user-supplied PackInput (components, pads & strategy
settings) into a collision-free PackOutput while
minGap)networkId close togetherInternally the algorithm:
bun add calculate-packing # or npm i / yarn add
import { pack, PackInput } from "calculate-packing"
const input: PackInput = {
components: [
{
componentId: "C1",
pads: [
{
padId: "C1_1",
networkId: "GND",
type: "rect",
offset: { x: -0.6, y: 0 },
size: { x: 1.2, y: 1 },
},
{
padId: "C1_2",
networkId: "VCC",
type: "rect",
offset: { x: +0.6, y: 0 },
size: { x: 1.2, y: 1 },
},
],
},
/* …more components… */
],
minGap: 0.25,
packOrderStrategy: "largest_to_smallest",
packPlacementStrategy: "shortest_connection_along_outline",
}
const result = pack(input)
console.log(result.components) // → positioned & rotated components
See tests/ for more elaborate examples (SVG snapshots, circuit-json fixtures).
bun install # install deps
bun test # run unit & SVG snapshot tests
bunx tsc --noEmit # type-check
• lib/PackSolver – high-level packing solver
• lib/geometry – computational-geometry helpers
• lib/math – low-level math utilities
• tests/ – unit & snapshot tests
| export | purpose |
|---|---|
pack() | run the solver |
convertPackOutputToPackInput() | strip solver-only fields |
convertCircuitJsonToPackOutput() | circuit-json → PackOutput helper |
getGraphicsFromPackOutput() | build a graphics-debug scene for review |
Everything else is internal and may change without notice.
MIT – see LICENSE.
FAQs
Calculate a packing layout with support for different strategy configurations
We found that calculate-packing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.