Skip to content
Closed
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
242 changes: 127 additions & 115 deletions bun.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/shared/generate-circuit-json.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ALLOWED_FILE_EXTENSIONS = [
".md",
".obj",
".kicad_mod",
".kicad_pcb",
]

type GenerateCircuitJsonOptions = {
Expand Down
22 changes: 22 additions & 0 deletions lib/shared/register-static-asset-loaders.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "node:fs"
import path from "node:path"
import { KicadToCircuitJsonConverter } from "kicad-to-circuit-json"

const STATIC_ASSET_EXTENSIONS = [
".glb",
Expand Down Expand Up @@ -57,6 +58,27 @@ export const registerStaticAssetLoaders = () => {
name: "tsci-static-assets",
setup(build) {
build.onLoad({ filter: staticAssetFilter }, (args) => {
if (args.path.endsWith(".kicad_pcb")) {
const converter = new KicadToCircuitJsonConverter()
converter.addFile(args.path, fs.readFileSync(args.path, "utf-8"))
converter.runUntilFinished()
const circuitJson = converter.getOutput()
const Board = (props: Record<string, unknown>) =>
(globalThis as any).React.createElement("board", {
...props,
circuitJson,
})
return {
exports: {
__esModule: true,
default: circuitJson,
Board,
circuitJson,
},
loader: "object",
}
}

const baseDir = baseUrl
? path.resolve(process.cwd(), baseUrl)
: process.cwd()
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@tscircuit/file-server": "^0.0.32",
"@tscircuit/image-utils": "^0.0.3",
"@tscircuit/math-utils": "0.0.36",
"@tscircuit/props": "^0.0.496",
"@tscircuit/props": "^0.0.527",
"@tscircuit/runframe": "^0.0.1938",
"@tscircuit/schematic-match-adapt": "^0.0.22",
"@types/bun": "^1.2.2",
Expand All @@ -29,7 +29,7 @@
"@types/semver": "^7.5.8",
"bun-match-svg": "^0.0.12",
"chokidar": "4.0.1",
"circuit-json": "^0.0.403",
"circuit-json": "^0.0.423",
"circuit-json-to-bom-csv": "^0.0.7",
"circuit-json-to-gerber": "^0.0.51",
"circuit-json-to-kicad": "^0.0.125",
Expand Down Expand Up @@ -68,7 +68,7 @@
"semver": "^7.6.3",
"stepts": "^0.0.3",
"tempy": "^3.1.0",
"tscircuit": "0.0.1590-libonly",
"tscircuit": "0.0.1736-libonly",
"tsx": "^4.7.1",
"typed-ky": "^0.0.4",
"zod": "^3.23.8"
Expand Down
1 change: 1 addition & 0 deletions sparkfun-boards
Submodule sparkfun-boards added at 46a6e5
Loading
Loading