Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default () => (
</board>
)
`,
"pcb" // or "schematic" for schematic view
"pcb" // or "schematic", "3d", or "pinout"
)

// Returns URL pointing to https://svg.tscircuit.com
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`
Expand Down
19 changes: 18 additions & 1 deletion tests/test3-svg-url.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => (
Expand All @@ -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 () => (
<board width="10mm" height="10mm">
<resistor resistance="1k" footprint="0402" name="R1" schX={3} pcbX={3} />
</board>
)
`,
"pinout",
)

expect(url).toMatchInlineSnapshot(
`"https://svg.tscircuit.com/?svg_type=pinout&code=H4sIAJsBqGcAAy2NTQ7CIBhE9z3FhFW7KlWXhUO4ckuBClF%2BAp%2FRxHh30Xb3JvMyY185FYKxq3rcCf0AIdF3wLwkVQye3pATbOIhMDjrr472JJvUtGKrr5QKNlBR2ybcGNaUKBcfm89P%2FMAQVWjVeWKo2l3E%2B%2FhB1ssG429tHv%2Bfshu%2BlSYxzJYAAAA%3D"`,
)
})