@tscircuit/eval 0.0.302 → 0.0.304

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.
@@ -1,6 +1,15 @@
1
1
  import type { PlatformConfig } from "@tscircuit/props"
2
2
  import { jlcPartsEngine } from "@tscircuit/parts-engine"
3
3
 
4
+ const KICAD_FOOTPRINT_CACHE_URL = "https://kicad-mod-cache.tscircuit.com"
5
+
4
6
  export const getPlatformConfig = (): PlatformConfig => ({
5
7
  partsEngine: jlcPartsEngine,
8
+ footprintLibraryMap: {
9
+ kicad: async (footprintName: string) => {
10
+ const url = `${KICAD_FOOTPRINT_CACHE_URL}/${footprintName}.circuit.json`
11
+ const res = await fetch(url)
12
+ return { footprintCircuitJson: await res.json() }
13
+ },
14
+ },
6
15
  })
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.302",
4
+ "version": "0.0.304",
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",
@@ -0,0 +1,34 @@
1
+ import { createCircuitWebWorker } from "lib/index"
2
+ import { expect, test } from "bun:test"
3
+
4
+ test("example18-kicad-footprint-server", async () => {
5
+ const circuitWebWorker = await createCircuitWebWorker({
6
+ webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
7
+ verbose: true,
8
+ })
9
+
10
+ await circuitWebWorker.executeWithFsMap({
11
+ entrypoint: "index.tsx",
12
+ fsMap: {
13
+ "index.tsx": `
14
+ circuit.add(
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
+ })
24
+
25
+ await circuitWebWorker.renderUntilSettled()
26
+
27
+ const circuitJson = await circuitWebWorker.getCircuitJson()
28
+
29
+ const pcb_trace = circuitJson.filter((el: any) => el.type === "pcb_trace")
30
+ expect(pcb_trace).toBeDefined()
31
+ expect(pcb_trace.length).toBe(1)
32
+
33
+ await circuitWebWorker.kill()
34
+ })