circuit-to-canvas 0.0.11 → 0.0.13

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.
Files changed (40) hide show
  1. package/package.json +8 -2
  2. package/tests/elements/__snapshots__/fabrication-note-text-descenders.snap.png +0 -0
  3. package/tests/elements/__snapshots__/pcb-copper-text-knockout.snap.png +0 -0
  4. package/tests/elements/__snapshots__/pcb-fabrication-note-rect-dashed.snap.png +0 -0
  5. package/tests/elements/__snapshots__/pcb-note-rect-dashed-stroke.snap.png +0 -0
  6. package/tests/elements/__snapshots__/pcb-silkscreen.snap.png +0 -0
  7. package/tests/elements/__snapshots__/silkscreen-text-bottom.snap.png +0 -0
  8. package/tests/elements/pcb-board.test.ts +5 -2
  9. package/tests/elements/pcb-copper-pour.test.ts +3 -2
  10. package/tests/elements/pcb-copper-text.test.ts +1 -1
  11. package/tests/elements/pcb-cutout.test.ts +1 -1
  12. package/tests/elements/pcb-fabrication-note-path-custom-color.test.ts +1 -1
  13. package/tests/elements/pcb-fabrication-note-path-thick-stroke.test.ts +1 -1
  14. package/tests/elements/pcb-fabrication-note-path.test.ts +1 -1
  15. package/tests/elements/pcb-fabrication-note-rect-all-features.test.ts +1 -1
  16. package/tests/elements/pcb-fabrication-note-rect-corner-radius.test.ts +1 -1
  17. package/tests/elements/pcb-fabrication-note-rect-custom-color.test.ts +1 -1
  18. package/tests/elements/pcb-fabrication-note-rect-dashed.test.ts +1 -1
  19. package/tests/elements/pcb-fabrication-note-rect-default-color.test.ts +1 -1
  20. package/tests/elements/pcb-fabrication-note-text-descenders.test.ts +1 -1
  21. package/tests/elements/pcb-fabrication-note-text-full-charset.test.ts +1 -1
  22. package/tests/elements/pcb-fabrication-note-text-rgba-color.test.ts +1 -1
  23. package/tests/elements/pcb-fabrication-note-text-small.test.ts +1 -1
  24. package/tests/elements/pcb-hole.test.ts +1 -1
  25. package/tests/elements/pcb-note-path.test.ts +1 -1
  26. package/tests/elements/pcb-note-rect-all-features.test.ts +1 -1
  27. package/tests/elements/pcb-note-rect-dashed-stroke.test.ts +1 -1
  28. package/tests/elements/pcb-note-rect-filled-no-stroke.test.ts +1 -1
  29. package/tests/elements/pcb-note-text-anchor-alignment.test.ts +1 -1
  30. package/tests/elements/pcb-note-text-custom-color.test.ts +1 -1
  31. package/tests/elements/pcb-note-text-small.test.ts +1 -1
  32. package/tests/elements/pcb-plated-hole.test.ts +1 -1
  33. package/tests/elements/pcb-silkscreen.test.ts +8 -1
  34. package/tests/elements/pcb-smtpad.test.ts +1 -1
  35. package/tests/elements/pcb-trace.test.ts +1 -1
  36. package/tests/elements/pcb-via.test.ts +1 -1
  37. package/tests/shapes/circle.test.ts +1 -1
  38. package/tests/shapes/oval.test.ts +1 -1
  39. package/tests/shapes/pill.test.ts +1 -1
  40. package/tests/shapes/rect.test.ts +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "circuit-to-canvas",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup-node ./lib/index.ts --format esm --dts",
@@ -10,11 +10,17 @@
10
10
  },
11
11
  "devDependencies": {
12
12
  "@biomejs/biome": "^2.3.8",
13
+ "@napi-rs/canvas": "^0.1.84",
14
+ "@resvg/resvg-js": "^2.6.2",
13
15
  "@tscircuit/alphabet": "^0.0.9",
16
+ "@tscircuit/circuit-json-util": "^0.0.73",
17
+ "@tscircuit/math-utils": "^0.0.29",
14
18
  "@types/bun": "latest",
15
19
  "bun-match-svg": "^0.0.14",
16
- "canvas": "^3.2.0",
17
20
  "circuit-json": "^0.0.335",
21
+ "circuit-json-to-connectivity-map": "^0.0.23",
22
+ "circuit-to-svg": "^0.0.297",
23
+ "schematic-symbols": "^0.0.202",
18
24
  "tsup": "^8.5.1"
19
25
  },
20
26
  "peerDependencies": {
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbBoard } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -80,6 +80,9 @@ test("draw board with elements", async () => {
80
80
  center: { x: 100, y: 75 },
81
81
  width: 180,
82
82
  height: 130,
83
+ thickness: 1.6,
84
+ num_layers: 2,
85
+ material: "fr4" as const,
83
86
  },
84
87
  {
85
88
  type: "pcb_smtpad" as const,
@@ -142,7 +145,7 @@ test("draw board with elements", async () => {
142
145
  y: 75,
143
146
  outer_diameter: 10,
144
147
  hole_diameter: 5,
145
- layers: ["top", "bottom"],
148
+ layers: ["top", "bottom"] as ("top" | "bottom")[],
146
149
  },
147
150
  ]
148
151
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbCopperPour } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -79,6 +79,7 @@ test("draw copper pour with trace", async () => {
79
79
  { x: 90, y: 90 },
80
80
  { x: 10, y: 90 },
81
81
  ],
82
+ covered_with_solder_mask: false,
82
83
  },
83
84
  {
84
85
  type: "pcb_trace" as const,
@@ -107,7 +108,7 @@ test("draw copper pour with trace", async () => {
107
108
  y: 50,
108
109
  outer_diameter: 15,
109
110
  hole_diameter: 8,
110
- layers: ["top", "bottom"],
111
+ layers: ["top", "bottom"] as ("top" | "bottom")[],
111
112
  },
112
113
  ]
113
114
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbCopperText } from "circuit-json"
4
4
  import { scale } from "transformation-matrix"
5
5
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbCutout } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNotePath } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNotePath } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNotePath } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNoteRect } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNoteRect } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNoteRect } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNoteRect } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNoteRect } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNoteText } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNoteText } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNoteText } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbFabricationNoteText } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PCBHole } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbNotePath } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbNoteRect } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbNoteRect } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbNoteRect } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbNoteText } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbNoteText } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbNoteText } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbPlatedHole } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type {
4
4
  PcbSilkscreenText,
5
5
  PcbSilkscreenRect,
@@ -191,26 +191,33 @@ test("draw silkscreen on component", async () => {
191
191
  {
192
192
  type: "pcb_silkscreen_rect" as const,
193
193
  pcb_silkscreen_rect_id: "outline1",
194
+ pcb_component_id: "component1",
194
195
  layer: "top" as const,
195
196
  center: { x: 75, y: 50 },
196
197
  width: 60,
197
198
  height: 30,
199
+ stroke_width: 0.2,
198
200
  },
199
201
  // Pin 1 indicator
200
202
  {
201
203
  type: "pcb_silkscreen_circle" as const,
202
204
  pcb_silkscreen_circle_id: "pin1marker",
205
+ pcb_component_id: "component1",
203
206
  layer: "top" as const,
204
207
  center: { x: 55, y: 40 },
205
208
  radius: 3,
209
+ stroke_width: 0.2,
206
210
  },
207
211
  // Component label
208
212
  {
209
213
  type: "pcb_silkscreen_text" as const,
210
214
  pcb_silkscreen_text_id: "label1",
215
+ pcb_component_id: "component1",
211
216
  layer: "top" as const,
212
217
  text: "IC1",
213
218
  anchor_position: { x: 75, y: 50 },
219
+ anchor_alignment: "center" as const,
220
+ font: "tscircuit2024" as const,
214
221
  font_size: 8,
215
222
  },
216
223
  // SMT pads
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PcbSmtPad } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PCBTrace } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import type { PCBVia } from "circuit-json"
4
4
  import { CircuitToCanvasDrawer } from "../../lib/drawer"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import { identity } from "transformation-matrix"
4
4
  import { drawCircle } from "../../lib/drawer/shapes/circle"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import { identity } from "transformation-matrix"
4
4
  import { drawOval } from "../../lib/drawer/shapes/oval"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import { identity } from "transformation-matrix"
4
4
  import { drawPill } from "../../lib/drawer/shapes/pill"
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
- import { createCanvas } from "canvas"
2
+ import { createCanvas } from "@napi-rs/canvas"
3
3
  import { identity } from "transformation-matrix"
4
4
  import { drawRect } from "../../lib/drawer/shapes/rect"
5
5