From f22856dffc92d74eea40de0c5021f648d6cd894d Mon Sep 17 00:00:00 2001 From: ShiboSoftwareDev Date: Sun, 21 Sep 2025 16:22:18 +0200 Subject: [PATCH] support pinout svg --- README.md | 2 +- lib/index.ts | 2 +- tests/test3-svg-url.test.ts | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c6df314..2b8b853 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ export default () => ( ) `, - "pcb" // or "schematic" for schematic view + "pcb" // or "schematic", "3d", or "pinout" ) // Returns URL pointing to https://svg.tscircuit.com diff --git a/lib/index.ts b/lib/index.ts index aef92d2..3c7ba87 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -29,7 +29,7 @@ export function getUncompressedSnippetString( export function createSvgUrl( tscircuitCode: string, - svgType: "pcb" | "schematic" | "3d", + svgType: "pcb" | "schematic" | "3d" | "pinout", ) { const base64Data = getCompressedBase64SnippetString(tscircuitCode) return `https://svg.tscircuit.com/?svg_type=${svgType}&code=${encodeURIComponent(base64Data)}` diff --git a/tests/test3-svg-url.test.ts b/tests/test3-svg-url.test.ts index b762f4a..88a04c7 100644 --- a/tests/test3-svg-url.test.ts +++ b/tests/test3-svg-url.test.ts @@ -1,7 +1,7 @@ import { test, expect } from "bun:test" import { createSvgUrl } from "lib" -test("create snippets url", () => { +test("create pcb svg url", () => { const url = createSvgUrl( ` export default () => ( @@ -17,3 +17,20 @@ export default () => ( `"https://svg.tscircuit.com/?svg_type=pcb&code=H4sIAJsBqGcAAy2NTQ7CIBhE9z3FhFW7KlWXhUO4ckuBClF%2BAp%2FRxHh30Xb3JvMyY185FYKxq3rcCf0AIdF3wLwkVQye3pATbOIhMDjrr472JJvUtGKrr5QKNlBR2ybcGNaUKBcfm89P%2FMAQVWjVeWKo2l3E%2B%2FhB1ssG429tHv%2Bfshu%2BlSYxzJYAAAA%3D"`, ) }) + +test("create pinout svg url", () => { + const url = createSvgUrl( + ` +export default () => ( + + + +) +`, + "pinout", + ) + + expect(url).toMatchInlineSnapshot( + `"https://svg.tscircuit.com/?svg_type=pinout&code=H4sIAJsBqGcAAy2NTQ7CIBhE9z3FhFW7KlWXhUO4ckuBClF%2BAp%2FRxHh30Xb3JvMyY185FYKxq3rcCf0AIdF3wLwkVQye3pATbOIhMDjrr472JJvUtGKrr5QKNlBR2ybcGNaUKBcfm89P%2FMAQVWjVeWKo2l3E%2B%2FhB1ssG429tHv%2Bfshu%2BlSYxzJYAAAA%3D"`, + ) +})