gokul/usb3-sd-hub
Engineering draft: four-layer, computer-powered USB 3 hub with one USB-C host socket, two USB-C and two USB-A accessory sockets, and a full-size SD slot. Board and three schematic previews are available. Routing and production checks are incomplete; not fabrication ready.
- Version
- 0.1.5
- License
- MIT
- Stars
- 0
scripts/preview-compat.ts
import { readFileSync, writeFileSync } from "node:fs";
import type { AnyCircuitElement } from "circuit-json";
// Support both current CLI directory output and the registry's earlier filename.
// Both preview files contain exactly the same real root-board output.
const preview = readFileSync("dist/index/circuit.json");
const circuitJson: AnyCircuitElement[] = JSON.parse(preview.toString("utf8"));
const boards = circuitJson.filter((record) => record.type === "pcb_board");
const sheets = circuitJson.filter((record) => record.type === "schematic_sheet");
if (boards.length !== 1 || boards[0].num_layers !== 4 || sheets.length !== 3) {
throw new Error("Expected the four-layer hub and its three schematic sheets");
}
for (const name of ["J_HOST", "J_A1", "J_A2", "J_C1", "J_C2", "J_SD"]) {
if (!circuitJson.some((record) => record.type === "source_component" && record.name === name)) {
throw new Error(`Missing expected connector ${name}`);
}
}
writeFileSync("dist/index.circuit.json", preview);
console.log("Verified root board preview; wrote compatible Circuit JSON path");