Skip to content

Commit cb4c2c3

Browse files
Merge pull request #306 from ShiboSoftwareDev/main
feat: Add pinout SVG support
2 parents f86f8fd + c4f478c commit cb4c2c3

18 files changed

+91
-17
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This service converts TSCircuit code or pre-generated circuit JSON into various
1616
- `svg_type` (required): The type of SVG to generate
1717
- `pcb` - PCB layout view
1818
- `schematic` - Circuit schematic view
19+
- `pinout` - Pinout diagram view
1920
- `3d` - 3D visualization view
2021

2122
**Input Methods:**
@@ -95,6 +96,11 @@ curl "https://svg.tscircuit.com/?svg_type=pcb&code=YOUR_ENCODED_CODE"
9596
curl "https://svg.tscircuit.com/?svg_type=schematic&code=YOUR_ENCODED_CODE"
9697
```
9798

99+
**Pinout View:**
100+
```bash
101+
curl "https://svg.tscircuit.com/?svg_type=pinout&code=YOUR_ENCODED_CODE"
102+
```
103+
98104
**3D Visualization:**
99105
```bash
100106
curl "https://svg.tscircuit.com/?svg_type=3d&code=YOUR_ENCODED_CODE"

bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dependencies": {
77
"@tscircuit/simple-3d-svg": "^0.0.22",
88
"circuit-json-to-simple-3d": "^0.0.9",
9-
"circuit-to-svg": "^0.0.158",
9+
"circuit-to-svg": "^0.0.199",
1010
"jscad-fiber": "^0.0.85",
1111
},
1212
"devDependencies": {
@@ -292,7 +292,7 @@
292292

293293
"circuit-json-to-simple-3d": ["[email protected]", "", { "peerDependencies": { "typescript": "^5" } }, "sha512-thpCtDb9LpAQfGO+Z0hae19sxVAmJAMYM/It9UTMCtyXC3zoUHwRcp/oqtMO/ZIW+JDBhiR8AHmmtKScL2kW7Q=="],
294294

295-
"circuit-to-svg": ["[email protected].158", "", { "dependencies": { "@types/node": "^22.5.5", "bun-types": "^1.1.40", "svgson": "^5.3.1", "transformation-matrix": "^2.16.1" }, "peerDependencies": { "@tscircuit/circuit-json-util": "*", "@tscircuit/footprinter": "*", "circuit-json": "*", "schematic-symbols": "*" } }, "sha512-TdKxfJ3x+5/cT8wbyXC++jvsEWacKS0KWRcKNZ8qvz73nPcs8y5+iUUH1c0k6YkkY1aZwrjiTqYNYVtTSuySyg=="],
295+
"circuit-to-svg": ["[email protected].199", "", { "dependencies": { "@types/node": "^22.5.5", "bun-types": "^1.1.40", "calculate-elbow": "0.0.12", "svgson": "^5.3.1", "transformation-matrix": "^2.16.1" }, "peerDependencies": { "tscircuit": "*" } }, "sha512-FTYGuM9IXElYTJrZOK99YiKI3kFSaUwgcLfu/X+cGlWge8OyICPt+6J7ikwCFZXw+YgSbXqcaFbfOktrq57tSw=="],
296296

297297
"cli-cursor": ["[email protected]", "", { "dependencies": { "restore-cursor": "^5.0.0" } }, "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw=="],
298298

endpoint.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CircuitRunner } from "@tscircuit/eval/eval"
33
import {
44
convertCircuitJsonToPcbSvg,
55
convertCircuitJsonToSchematicSvg,
6+
convertCircuitJsonToPinoutSvg,
67
} from "circuit-to-svg"
78
import { convertCircuitJsonToSimple3dSvg } from "circuit-json-to-simple-3d/dist/index.js"
89
import { getHtmlForGeneratedUrlPage } from "./get-html-for-generated-url-page"
@@ -126,7 +127,7 @@ export default async (req: Request) => {
126127
// Check for both svg_type and view parameters, with svg_type taking precedence
127128
const svgType =
128129
url.searchParams.get("svg_type") || url.searchParams.get("view")
129-
if (!svgType || !["pcb", "schematic", "3d"].includes(svgType)) {
130+
if (!svgType || !["pcb", "schematic", "3d", "pinout"].includes(svgType)) {
130131
return new Response(
131132
JSON.stringify({
132133
ok: false,
@@ -142,6 +143,8 @@ export default async (req: Request) => {
142143
svgContent = convertCircuitJsonToPcbSvg(circuitJson)
143144
} else if (svgType === "schematic") {
144145
svgContent = convertCircuitJsonToSchematicSvg(circuitJson)
146+
} else if (svgType === "pinout") {
147+
svgContent = convertCircuitJsonToPinoutSvg(circuitJson)
145148
} else {
146149
// Extract 3D SVG parameters from URL and POST body (URL takes precedence)
147150
const backgroundColor =

get-html-for-generated-url-page.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const getHtmlForGeneratedUrlPage = (
1212

1313
const pcbSvgUrl = `${urlPrefix}/?svg_type=pcb&code=${encodeURIComponent(compressedCode)}`
1414
const schSvgUrl = `${urlPrefix}/?svg_type=schematic&code=${encodeURIComponent(compressedCode)}`
15+
const pinoutSvgUrl = `${urlPrefix}/?svg_type=pinout&code=${encodeURIComponent(compressedCode)}`
1516
const threeDSvgUrl = `${urlPrefix}/?svg_type=3d&code=${encodeURIComponent(compressedCode)}`
1617

1718
return `
@@ -36,6 +37,10 @@ export const getHtmlForGeneratedUrlPage = (
3637
<td>Schematic SVG URL</td>
3738
<td><a href="${schSvgUrl}">${schSvgUrl}</a></td>
3839
</tr>
40+
<tr>
41+
<td>Pinout SVG URL</td>
42+
<td><a href="${pinoutSvgUrl}">${pinoutSvgUrl}</a></td>
43+
</tr>
3944
<tr>
4045
<td>3D SVG URL</td>
4146
<td><a href="${threeDSvgUrl}">${threeDSvgUrl}</a></td>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"dependencies": {
3131
"@tscircuit/simple-3d-svg": "^0.0.22",
3232
"circuit-json-to-simple-3d": "^0.0.9",
33-
"circuit-to-svg": "^0.0.158",
33+
"circuit-to-svg": "^0.0.199",
3434
"jscad-fiber": "^0.0.85"
3535
}
3636
}

tests/__snapshots__/3d-all-params.snap.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)