@tscircuit/eval 0.0.308 → 0.0.310

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.
package/lib/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./runner"
2
2
  export * from "./worker"
3
3
  export * from "./getPossibleEntrypointComponentPaths"
4
+ export * from "./getPlatformConfig"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/eval",
3
3
  "main": "dist/lib/index.js",
4
- "version": "0.0.308",
4
+ "version": "0.0.310",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "bun run build:lib && bun run build:webworker && bun run build:blob-url && bun run build:runner && bun run build:worker-wrapper",
@@ -57,7 +57,7 @@
57
57
  "@tscircuit/checks": "^0.0.71",
58
58
  "@tscircuit/circuit-json-flex": "^0.0.3",
59
59
  "@tscircuit/circuit-json-util": "^0.0.67",
60
- "@tscircuit/core": "^0.0.706",
60
+ "@tscircuit/core": "^0.0.712",
61
61
  "@tscircuit/footprinter": "^0.0.236",
62
62
  "@tscircuit/import-snippet": "^0.0.4",
63
63
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
@@ -67,7 +67,7 @@
67
67
  "@tscircuit/math-utils": "^0.0.21",
68
68
  "@tscircuit/miniflex": "^0.0.4",
69
69
  "@tscircuit/parts-engine": "^0.0.8",
70
- "@tscircuit/props": "0.0.298",
70
+ "@tscircuit/props": "0.0.311",
71
71
  "@tscircuit/schematic-autolayout": "^0.0.6",
72
72
  "@tscircuit/schematic-match-adapt": "^0.0.16",
73
73
  "@tscircuit/schematic-trace-solver": "^0.0.35",
@@ -79,10 +79,10 @@
79
79
  "@types/react-dom": "^19.1.6",
80
80
  "@types/react-reconciler": "^0.28.9",
81
81
  "bpc-graph": "^0.0.57",
82
- "bun-match-svg": "^0.0.13",
82
+ "bun-match-svg": "0.0.12",
83
83
  "calculate-elbow": "^0.0.12",
84
84
  "chokidar-cli": "^3.0.0",
85
- "circuit-json": "^0.0.245",
85
+ "circuit-json": "^0.0.246",
86
86
  "circuit-json-to-bpc": "^0.0.13",
87
87
  "circuit-json-to-connectivity-map": "^0.0.22",
88
88
  "circuit-json-to-simple-3d": "^0.0.6",
@@ -100,7 +100,7 @@
100
100
  "pkg-pr-new": "^0.0.37",
101
101
  "react": "^19.1.0",
102
102
  "react-dom": "^19.1.0",
103
- "schematic-symbols": "^0.0.195",
103
+ "schematic-symbols": "^0.0.198",
104
104
  "ts-expect": "^1.3.0",
105
105
  "tsup": "^8.2.4"
106
106
  },
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" data-software-used-string="@tscircuit/core@0.0.706"><style></style><rect class="boundary" x="0" y="0" fill="#000" width="800" height="600"/><rect class="pcb-boundary" fill="none" stroke="#fff" stroke-width="0.3" x="69.204152249135" y="139.44636678200698" width="661.5916955017301" height="321.10726643598616"/><path class="pcb-board" d="M 69.204152249135 460.55363321799314 L 730.795847750865 460.55363321799314 L 730.795847750865 139.44636678200698 L 69.204152249135 139.44636678200698 Z" fill="none" stroke="rgba(255, 255, 255, 0.5)" stroke-width="6.920415224913495"/><path class="pcb-trace" stroke="rgb(200, 52, 52)" fill="none" d="M 503.11418685121106 300.00000000000006 L 296.88581314878894 300.00000000000006" stroke-width="10.380622837370241" stroke-linecap="round" stroke-linejoin="round" shape-rendering="crispEdges" data-layer="top"/><path class="pcb-trace" stroke="rgb(200, 52, 52)" fill="none" d="M 296.88581314878894 300.00000000000006 L 296.88581314878894 300.00000000000006" stroke-width="10.380622837370241" stroke-linecap="round" stroke-linejoin="round" shape-rendering="crispEdges" data-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="484.42906574394465" y="277.8546712802769" width="37.37024221453287" height="44.29065743944637" data-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="555.0173010380622" y="277.8546712802769" width="37.37024221453287" height="44.29065743944637" data-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="207.61245674740485" y="277.8546712802769" width="37.37024221453287" height="44.29065743944637" data-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="278.20069204152253" y="277.8546712802769" width="37.37024221453287" height="44.29065743944637" data-layer="top"/><path class="pcb-silkscreen pcb-silkscreen-top" d="M 573.7024221453287 250.17301038062288 L 470.5882352941177 250.17301038062288 L 470.5882352941177 349.82698961937723 L 573.7024221453287 349.82698961937723" fill="none" stroke="#f2eda1" stroke-width="6.920415224913495" stroke-linecap="round" stroke-linejoin="round" data-pcb-component-id="pcb_component_1" data-pcb-silkscreen-path-id="pcb_silkscreen_path_0"/><path class="pcb-silkscreen pcb-silkscreen-top" d="M 250.95910034602076 273.7024221453288 L 272.22429065743944 273.7024221453288" fill="none" stroke="#f2eda1" stroke-width="8.304498269896193" stroke-linecap="round" stroke-linejoin="round" data-pcb-component-id="pcb_component_0" data-pcb-silkscreen-path-id="pcb_silkscreen_path_1"/><path class="pcb-silkscreen pcb-silkscreen-top" d="M 250.95910034602076 326.2975778546713 L 272.22429065743944 326.2975778546713" fill="none" stroke="#f2eda1" stroke-width="8.304498269896193" stroke-linecap="round" stroke-linejoin="round" data-pcb-component-id="pcb_component_0" data-pcb-silkscreen-path-id="pcb_silkscreen_path_2"/><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="27.68166089965398" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,538.4083044982699,215.5709342560554)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_component_1" stroke="none">C1</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="101.73010380622837" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,261.5916955017301,219.03114186851218)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_component_0" stroke="none">R1</text></svg>
@@ -0,0 +1,75 @@
1
+ import { CircuitRunner } from "lib/runner/CircuitRunner"
2
+ import { getPlatformConfig } from "lib/getPlatformConfig"
3
+ import { expect, test } from "bun:test"
4
+ import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
5
+
6
+ test("example19-service-like-browser-preview", async () => {
7
+ // Simulate the service code pattern with platform config
8
+ const worker = new CircuitRunner({
9
+ platform: getPlatformConfig(), // This is the key - pass platform config
10
+ })
11
+
12
+ // Simulate user code that uses kicad footprints
13
+ const userCode = `
14
+ export default () => (
15
+ <board>
16
+ <resistor name="R1" resistance="1k" footprint="kicad:Resistor_SMD.pretty/R_0402_1005Metric" pcbX={-2} />
17
+ <capacitor name="C1" capacitance="100uF" footprint="0402" pcbX={2} />
18
+ <trace from=".R1 > .pin2" to=".C1 > .pin1" />
19
+ </board>
20
+ )
21
+ `
22
+
23
+ // Execute with fsMap similar to service code
24
+ await worker.executeWithFsMap({
25
+ fsMap: {
26
+ "entrypoint.tsx": `
27
+ import UserComponents from "./UserCode.tsx";
28
+
29
+ const hasBoard = ${userCode.includes("<board").toString()};
30
+
31
+ circuit.add(
32
+ hasBoard ? (
33
+ <UserComponents />
34
+ ) : (
35
+ <board>
36
+ <UserComponents name="U1" />
37
+ </board>
38
+ )
39
+ );
40
+ `,
41
+ "UserCode.tsx": userCode,
42
+ },
43
+ entrypoint: "entrypoint.tsx",
44
+ })
45
+
46
+ await worker.renderUntilSettled()
47
+
48
+ const circuitJson = await worker.getCircuitJson()
49
+
50
+ // Verify the circuit was created successfully
51
+ expect(circuitJson).toBeDefined()
52
+ expect(Array.isArray(circuitJson)).toBe(true)
53
+ expect(circuitJson.length).toBeGreaterThan(0)
54
+
55
+ // Check that we have the expected elements
56
+ const pcb_trace = circuitJson.filter((el: any) => el.type === "pcb_trace")
57
+ expect(pcb_trace).toBeDefined()
58
+ expect(pcb_trace.length).toBe(1)
59
+
60
+ // Check that kicad footprint was processed (should have footprint elements)
61
+ const footprintElements = circuitJson.filter(
62
+ (el: any) =>
63
+ el.type === "pcb_silkscreen_text" ||
64
+ el.type === "pcb_pad" ||
65
+ el.type === "pcb_silkscreen_line",
66
+ )
67
+ expect(footprintElements.length).toBeGreaterThan(0)
68
+
69
+ // Generate SVG to verify visual output
70
+ expect(convertCircuitJsonToPcbSvg(circuitJson)).toMatchSvgSnapshot(
71
+ import.meta.path,
72
+ )
73
+
74
+ await worker.kill()
75
+ })