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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tscircuit/copper-pour-solver

v0.0.42

Published

Solves PCB copper pour regions from Circuit JSON or from a small geometry input format, returning `pcb_copper_pour`-ready B-Rep shapes.

Readme

@tscircuit/copper-pour-solver

Solves PCB copper pour regions from Circuit JSON or from a small geometry input format, returning pcb_copper_pour-ready B-Rep shapes.

Install

bun add @tscircuit/copper-pour-solver

This package expects TypeScript 5 as a peer dependency.

Basic Usage With Circuit JSON

Initialize the geometry runtime once before solving. Then convert Circuit JSON into the solver input format, run the solver, and map the returned B-Rep shapes back into pcb_copper_pour elements.

import {
  CopperPourPipelineSolver,
  convertCircuitJsonToInputProblem,
  initializeManifoldGeometry,
} from "@tscircuit/copper-pour-solver"

await initializeManifoldGeometry()

const inputProblem = convertCircuitJsonToInputProblem(circuitJson, {
  layer: "top",
  source_net_name: "GND",
  pad_margin: 0.4,
  trace_margin: 0.2,
  board_edge_margin: 0.1,
  cutout_margin: 0.2,
})

const solver = new CopperPourPipelineSolver(inputProblem)
const { brep_shapes } = solver.getOutput()

convertCircuitJsonToInputProblem reads board bounds or outline, SMT pads, plated holes, mechanical holes, vias, traces, and cutouts for the selected layer. Pads and traces connected to the selected source net are kept connected to the pour; unrelated geometry is subtracted using the configured margins.

Selecting The Pour Net

Prefer selecting by source net name or id:

const inputProblem = convertCircuitJsonToInputProblem(circuitJson, {
  layer: "top",
  source_net_name: "GND",
  pad_margin: 0.4,
  trace_margin: 0.2,
})

You can also pass the source net's stable subcircuit_connectivity_map_key directly:

const gnd = circuitJson.find(
  (element) => element.type === "source_net" && element.name === "GND",
)

const inputProblem = convertCircuitJsonToInputProblem(circuitJson, {
  layer: "top",
  subcircuit_id: gnd.subcircuit_id,
  subcircuit_connectivity_map_key: gnd.subcircuit_connectivity_map_key,
  pad_margin: 0.4,
  trace_margin: 0.2,
})

Pass subcircuit_id when selecting a net inside a subcircuit. The converter considers that subcircuit and its child subcircuits, but it does not treat matching child subcircuit_connectivity_map_key values as connected unless the Circuit JSON connectivity actually connects them. Internally, the generated globalConnectivityMap is kept separate from the scoped subcircuitConnectivityMap; scoped solver connectivity keys are prefixed with their subcircuit id.

Do not generate or pass ids from circuit-json-to-connectivity-map. The converter handles PCB connectivity internally and normalizes it to stable subcircuit_connectivity_map_key values.

Manual Input

You can skip Circuit JSON conversion and provide the solver input directly.

import {
  CopperPourPipelineSolver,
  initializeManifoldGeometry,
  type InputProblem,
} from "@tscircuit/copper-pour-solver"

await initializeManifoldGeometry()

const input: InputProblem = {
  regionsForPour: [
    {
      shape: "rect",
      layer: "top",
      bounds: { minX: -10, minY: -5, maxX: 10, maxY: 5 },
      connectivityKey: "net:GND",
      padMargin: 0.4,
      traceMargin: 0.2,
      board_edge_margin: 0.1,
    },
  ],
  pads: [
    {
      shape: "circle",
      padId: "via_1",
      layer: "top",
      connectivityKey: "net:VCC",
      x: 0,
      y: 0,
      radius: 0.5,
    },
  ],
}

const output = new CopperPourPipelineSolver(input).getOutput()

Supported input pad shapes are rect, circle, pill, trace, and polygon. Use the same connectivityKey as the pour for pads/traces that should connect to the copper island; use a different key for blockers that should be cleared.

Output

getOutput() returns:

interface PipelineOutput {
  brep_shapes: BRepShape[]
}

Each B-Rep shape is compatible with Circuit JSON copper pour data:

interface BRepShape {
  outer_ring: {
    vertices: Array<{ x: number; y: number; bulge?: number }>
  }
  inner_rings: Array<{
    vertices: Array<{ x: number; y: number; bulge?: number }>
  }>
}

Development

bun install
bun run build
bun test
bun start
bun run build:site