Skip to content

Commit d5c8e1e

Browse files
feat: Add simulationExperimentId for schsim SVGs
1 parent 00acfe4 commit d5c8e1e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type CreateSvgUrlOptions = {
99
pngHeight?: number
1010
pngDensity?: number
1111
entrypoint?: string
12+
simulationExperimentId?: string
1213
}
1314

1415
export function getCompressedBase64SnippetString(text: string) {
@@ -71,6 +72,9 @@ export function createSvgUrl(
7172
if (options.pngDensity !== undefined) {
7273
search.set("png_density", String(options.pngDensity))
7374
}
75+
if (options.simulationExperimentId) {
76+
search.set("simulation_experiment_id", options.simulationExperimentId)
77+
}
7478

7579
const query = search.toString()
7680
return `https://svg.tscircuit.com/?${query}`

tests/test3-svg-url.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,22 @@ export default () => (
117117
`"https://svg.tscircuit.com/?svg_type=schsim&code=H4sIAJsBqGcAAy2NTQ7CIBhE9z3FhFW7KlWXhUO4ckuBClF%2BAp%2FRxHh30Xb3JvMyY185FYKxq3rcCf0AIdF3wLwkVQye3pATbOIhMDjrr472JJvUtGKrr5QKNlBR2ybcGNaUKBcfm89P%2FMAQVWjVeWKo2l3E%2B%2FhB1ssG429tHv%2Bfshu%2BlSYxzJYAAAA%3D"`,
118118
)
119119
})
120+
121+
test("create schsim svg url with simulation experiment id", () => {
122+
const url = createSvgUrl(
123+
`
124+
export default () => (
125+
<board width="10mm" height="10mm">
126+
<resistor resistance="1k" footprint="0402" name="R1" schX={3} pcbX={3} />
127+
</board>
128+
)
129+
`,
130+
"schsim",
131+
{
132+
simulationExperimentId: "my-exp-1",
133+
},
134+
)
135+
136+
const parsed = new URL(url)
137+
expect(parsed.searchParams.get("simulation_experiment_id")).toBe("my-exp-1")
138+
})

0 commit comments

Comments
 (0)