@tscircuit/cli 0.1.25 → 0.1.27

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/bun.lock CHANGED
@@ -4,8 +4,9 @@
4
4
  "": {
5
5
  "name": "@tscircuit/cli",
6
6
  "dependencies": {
7
+ "@tscircuit/eval": "^0.0.96",
7
8
  "@tscircuit/file-server": "^0.0.13",
8
- "@tscircuit/runframe": "^0.0.47",
9
+ "@tscircuit/runframe": "^0.0.167",
9
10
  "chokidar": "4.0.1",
10
11
  "commander": "^12.1.0",
11
12
  "configstore": "^7.0.0",
@@ -503,7 +504,7 @@
503
504
 
504
505
  "@tscircuit/core": ["@tscircuit/core@0.0.249", "", { "dependencies": { "@lume/kiwi": "^0.4.3", "@tscircuit/footprinter": "^0.0.95", "@tscircuit/infgrid-ijump-astar": "^0.0.26", "@tscircuit/math-utils": "^0.0.5", "@tscircuit/props": "^0.0.123", "@tscircuit/schematic-autolayout": "^0.0.6", "@tscircuit/soup-util": "^0.0.41", "circuit-json": "^0.0.124", "circuit-json-to-connectivity-map": "^0.0.17", "format-si-unit": "^0.0.2", "nanoid": "^5.0.7", "performance-now": "^2.1.0", "react": "^18.3.1", "react-reconciler": "^0.29.2", "schematic-symbols": "^0.0.111", "transformation-matrix": "^2.16.1", "zod": "^3.23.8" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-maLezJD+Zo0yc6xFC/TpxQoEoIffWSExGumZb21v/CjIjQ8+c5zDtEb5mVCPxFaryvf0pFhJ75TtOfQ4YHaCAg=="],
505
506
 
506
- "@tscircuit/eval-webworker": ["@tscircuit/eval-webworker@0.0.45", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-qUs73v7sPgEJdeeMQG/DqX7zJLe8FTL9H5aR27XJ0+4LiPKAt+WlwOgIVDSZZQ3AjD8WUFchdO3694c58FXIxg=="],
507
+ "@tscircuit/eval": ["@tscircuit/eval@0.0.96", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-lzyXdMVhtlrceSRYAgYFFFnZy8trSHt330Tc04scyHLbEeK0yLG/EhiqmPQ+pZXsfEwOoJW0leFfFQjiulhktw=="],
507
508
 
508
509
  "@tscircuit/fake-snippets": ["@tscircuit/fake-snippets@0.0.5", "", { "dependencies": { "@babel/preset-react": "^7.25.9", "@babel/preset-typescript": "^7.26.0", "@codemirror/autocomplete": "^6.18.1", "@codemirror/lang-javascript": "^6.2.2", "@codemirror/lang-json": "^6.0.1", "@codemirror/lint": "^6.8.2", "@codemirror/state": "^6.4.1", "@codemirror/view": "^6.34.1", "@hookform/resolvers": "^3.9.0", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-aspect-ratio": "^1.1.0", "@radix-ui/react-avatar": "^1.1.0", "@radix-ui/react-checkbox": "^1.1.1", "@radix-ui/react-collapsible": "^1.1.0", "@radix-ui/react-context-menu": "^2.2.1", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-hover-card": "^1.1.1", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-menubar": "^1.1.1", "@radix-ui/react-navigation-menu": "^1.2.0", "@radix-ui/react-popover": "^1.1.1", "@radix-ui/react-progress": "^1.1.0", "@radix-ui/react-radio-group": "^1.2.0", "@radix-ui/react-scroll-area": "^1.1.0", "@radix-ui/react-select": "^2.1.1", "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slider": "^1.2.0", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-switch": "^1.1.0", "@radix-ui/react-tabs": "^1.1.0", "@radix-ui/react-toast": "^1.2.1", "@radix-ui/react-toggle": "^1.1.0", "@radix-ui/react-toggle-group": "^1.1.0", "@radix-ui/react-tooltip": "^1.1.2", "@tscircuit/3d-viewer": "^0.0.113", "@tscircuit/footprinter": "^0.0.102", "@tscircuit/layout": "^0.0.29", "@tscircuit/math-utils": "^0.0.10", "@tscircuit/mm": "^0.0.8", "@tscircuit/pcb-viewer": "^1.11.12", "@tscircuit/props": "^0.0.138", "@tscircuit/schematic-viewer": "^1.4.3", "@types/file-saver": "^2.0.7", "@types/ms": "^0.7.34", "@typescript/ata": "^0.9.7", "@valtown/codemirror-codeium": "^1.1.1", "@valtown/codemirror-ts": "^2.2.0", "@vercel/analytics": "^1.4.1", "change-case": "^5.4.4", "circuit-json": "^0.0.135", "circuit-json-to-bom-csv": "^0.0.6", "circuit-json-to-gerber": "^0.0.16", "circuit-json-to-pnp-csv": "^0.0.6", "circuit-json-to-readable-netlist": "^0.0.7", "circuit-json-to-tscircuit": "^0.0.4", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "cmdk": "^1.0.4", "codemirror": "^6.0.1", "country-list": "^2.3.0", "date-fns": "^4.1.0", "dsn-converter": "^0.0.60", "easyeda": "^0.0.62", "embla-carousel-react": "^8.3.0", "extract-codefence": "^0.0.4", "fflate": "^0.8.2", "file-saver": "^2.0.5", "immer": "^10.1.1", "input-otp": "^1.2.4", "jose": "^5.9.3", "jscad-electronics": "^0.0.24", "jszip": "^3.10.1", "kicad-converter": "^0.0.16", "lucide-react": "^0.445.0", "ms": "^2.1.3", "next-themes": "^0.3.0", "posthog-js": "^1.203.2", "react-cookie-consent": "^9.0.0", "react-day-picker": "8.10.1", "react-dom": "^18.3.1", "react-helmet": "^6.1.0", "react-hook-form": "^7.53.0", "react-intersection-observer": "^9.14.1", "react-query": "^3.39.3", "react-resizable-panels": "^2.1.3", "recharts": "^2.12.7", "rollup-plugin-visualizer": "^5.12.0", "sitemap": "^8.0.0", "sonner": "^1.5.0", "states-us": "^1.1.1", "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", "use-async-memo": "^1.2.5", "use-mouse-matrix-transform": "^1.3.0", "vaul": "^0.9.9", "vite-plugin-vercel": "^9.0.4", "wouter": "^3.3.5" } }, "sha512-0Phjn+E1T0CW4pgjhtb0eMxqfYMgeBRpnGGxtiGQzb3BwdNQuEqGFTp7MXn0PVmR0FEgglatb/NdUfHUN3HQkw=="],
509
510
 
@@ -529,7 +530,7 @@
529
530
 
530
531
  "@tscircuit/routing": ["@tscircuit/routing@1.3.5", "", { "dependencies": { "bs58": "^5.0.0", "pathfinding": "^0.4.18", "react-error-boundary": "^4.0.11" } }, "sha512-6qHGsKC731TbeaqiQToHS5Zao+93nv99LjbpI479Bqz8Avc8CAUax9QnhMhJ5KvYQv5zLtjv2ywezzRxZf09ZA=="],
531
532
 
532
- "@tscircuit/runframe": ["@tscircuit/runframe@0.0.47", "", { "dependencies": { "@radix-ui/react-dropdown-menu": "^2.1.2", "@radix-ui/react-icons": "^1.3.2", "@radix-ui/react-tabs": "^1.1.1", "@tscircuit/3d-viewer": "^0.0.77", "@tscircuit/assembly-viewer": "^0.0.1", "@tscircuit/core": "^0.0.249", "@tscircuit/eval-webworker": "^0.0.45", "@tscircuit/file-server": "^0.0.12", "@tscircuit/pcb-viewer": "^1.10.22", "@tscircuit/props": "^0.0.124", "@tscircuit/schematic-viewer": "2.0.9", "circuit-to-svg": "^0.0.99", "comlink": "^4.4.2", "cssnano": "^7.0.6", "lucide-react": "^0.468.0", "react-cosmos-plugin-vite": "^6.2.0", "schematic-symbols": "^0.0.111", "tailwind-merge": "^2.5.5", "tailwindcss-animate": "^1.0.7" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-qg7dCyEfiI+UZKDlYkFweeKvpuNcDA7kCmWy45CAYWFIQGSjTvb3y1dyFb6W4eb2gFdjiyCYysfdC5JeN9YqQw=="],
533
+ "@tscircuit/runframe": ["@tscircuit/runframe@0.0.167", "", { "dependencies": { "@radix-ui/react-dropdown-menu": "^2.1.4", "@radix-ui/react-icons": "^1.3.2", "@radix-ui/react-slot": "^1.1.1", "@radix-ui/react-tabs": "^1.1.2", "@tscircuit/3d-viewer": "^0.0.134", "@tscircuit/assembly-viewer": "^0.0.1", "@tscircuit/core": "^0.0.311", "@tscircuit/eval": "^0.0.96", "@tscircuit/file-server": "^0.0.13", "@tscircuit/pcb-viewer": "^1.11.29", "@tscircuit/props": "^0.0.147", "@tscircuit/schematic-viewer": "2.0.9", "circuit-to-svg": "^0.0.102", "clsx": "^2.1.1", "comlink": "^4.4.2", "cssnano": "^7.0.6", "jscad-fiber": "^0.0.77", "lucide-react": "^0.473.0", "react-cosmos-plugin-vite": "^6.2.0", "schematic-symbols": "^0.0.111", "tailwind-merge": "^2.6.0", "tailwindcss-animate": "^1.0.7" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-oCayPdLkx76KEI8N8nKdoGYzxS3ZEeIwtNRWwt8OgCA9r0h+ZUPC9wgpeEEDY1DiH+mORJCeRU9cNFyukGjIXQ=="],
533
534
 
534
535
  "@tscircuit/schematic-autolayout": ["@tscircuit/schematic-autolayout@0.0.6", "", { "dependencies": { "@tscircuit/soup-util": "^0.0.38", "transformation-matrix": "^2.16.1" } }, "sha512-34cQxtlSylBKyHkzaMBCynaWJgN9c/mWm7cz63StTYIafKmfFs383K8Xoc4QX8HXCvVrHYl1aK15onZua9MxeA=="],
535
536
 
@@ -761,7 +762,7 @@
761
762
 
762
763
  "circuit-json-to-tscircuit": ["circuit-json-to-tscircuit@0.0.4", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-LpHbOwdPE4+CooWPAPoKXWs4vxTrjJgu/avnxE3AqGwCD9r0ZnT73mEAB9oQi6T1i7T53zdkSR6y+zpsyCSE7g=="],
763
764
 
764
- "circuit-to-svg": ["circuit-to-svg@0.0.99", "", { "dependencies": { "@tscircuit/footprinter": "^0.0.91", "@tscircuit/routing": "^1.3.5", "@tscircuit/soup-util": "^0.0.41", "@types/node": "^22.5.5", "bun-types": "^1.1.40", "svgson": "^5.3.1", "transformation-matrix": "^2.16.1" }, "peerDependencies": { "circuit-json": "*", "schematic-symbols": "*" } }, "sha512-6p3LNcoA5X/OBtMOcVpvfJ7Ml7cHWIDdLE3u5QBZ1RpLE0wEXXd6sexVofBwPZl25huTBvY+0iRBvuhqJajbhw=="],
765
+ "circuit-to-svg": ["circuit-to-svg@0.0.102", "", { "dependencies": { "@tscircuit/footprinter": "^0.0.91", "@tscircuit/routing": "^1.3.5", "@tscircuit/soup-util": "^0.0.41", "@types/node": "^22.5.5", "bun-types": "^1.1.40", "svgson": "^5.3.1", "transformation-matrix": "^2.16.1" }, "peerDependencies": { "circuit-json": "*", "schematic-symbols": "*" } }, "sha512-PYjAtv9ZIbmsncbzC9DPcdzsx/iMjdoURA6umaz6BKPM9YzHD/UFYbMXlRDRhvJJN3UjFIub2qHoESCvbOq1sQ=="],
765
766
 
766
767
  "class-variance-authority": ["class-variance-authority@0.7.1", "", { "dependencies": { "clsx": "^2.1.1" } }, "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg=="],
767
768
 
@@ -1151,7 +1152,7 @@
1151
1152
 
1152
1153
  "jscad-electronics": ["jscad-electronics@0.0.24", "", { "dependencies": { "@tscircuit/footprinter": "^0.0.87", "circuit-json": "^0.0.92" } }, "sha512-fBBEmOGWy5cCS8ZdL308YoXt8ZysjGN1FgJH7n5w9fcZ26k8sdiKfGu5yRG8becBxe+q88WNUis9T5+UOO3CUw=="],
1153
1154
 
1154
- "jscad-fiber": ["jscad-fiber@0.0.76", "", { "dependencies": { "color": "^4.2.3", "lucide-react": "^0.456.0", "react-code-blocks": "^0.1.6", "react-reconciler": "^0.29.2" }, "peerDependencies": { "@jscad/modeling": "*", "@react-three/fiber": "*", "react": "*", "three": "*" } }, "sha512-AOZifUSZ0yYMxBObJzKMO7OdrUbbiH8FS8h9crgSE0Z6j1AE4+rED09RoUXLjA9rusPkWaSTt2KDcaN/PRemUg=="],
1155
+ "jscad-fiber": ["jscad-fiber@0.0.77", "", { "dependencies": { "color": "^4.2.3", "lucide-react": "^0.456.0", "react-code-blocks": "^0.1.6", "react-reconciler": "^0.29.2" }, "peerDependencies": { "@jscad/modeling": "*", "@react-three/fiber": "*", "react": "*", "three": "*" } }, "sha512-ugLAqTMr41jHK9cXRVkMKOPrUDMGc8gN3G69XG1zk62xpRMmEv0WaS1nnAgj5r9FZmK9FeRWKIR03zN+yq7IZQ=="],
1155
1156
 
1156
1157
  "jscad-planner": ["jscad-planner@0.0.11", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-Km3hBQnT8TSfU7sOr2pkK/ckjLXRv4aVGmY4tADhBQugDYHeEgj2G5KQMgF9mK4H66MuW89cHNiOU1p2MfWK1Q=="],
1157
1158
 
@@ -1891,6 +1892,8 @@
1891
1892
 
1892
1893
  "@tscircuit/3d-viewer/jscad-electronics": ["jscad-electronics@0.0.23", "", { "dependencies": { "@tscircuit/footprinter": "^0.0.87", "circuit-json": "^0.0.92" } }, "sha512-FRSJOLSvyofg1kLMnZ79MYeX+7XTzeOcpHPY1cBJgITZkVK5olwnD8M/2Odi1Lw1o5rTtXddNvypOqmgfcT//Q=="],
1893
1894
 
1895
+ "@tscircuit/3d-viewer/jscad-fiber": ["jscad-fiber@0.0.76", "", { "dependencies": { "color": "^4.2.3", "lucide-react": "^0.456.0", "react-code-blocks": "^0.1.6", "react-reconciler": "^0.29.2" }, "peerDependencies": { "@jscad/modeling": "*", "@react-three/fiber": "*", "react": "*", "three": "*" } }, "sha512-AOZifUSZ0yYMxBObJzKMO7OdrUbbiH8FS8h9crgSE0Z6j1AE4+rED09RoUXLjA9rusPkWaSTt2KDcaN/PRemUg=="],
1896
+
1894
1897
  "@tscircuit/builder/@lume/kiwi": ["@lume/kiwi@0.1.0", "", {}, "sha512-iB+oaYyaVK1hQ0cODubnoSDg4gGYL9cp/4ad7G1b9Z0/IqehPztp5qE3KP2mV9Ns0UYmzwvtkEhTCmKUuhorbg=="],
1895
1898
 
1896
1899
  "@tscircuit/builder/@tscircuit/layout": ["@tscircuit/layout@0.0.25", "", { "dependencies": { "transformation-matrix": "^2.16.1" }, "peerDependencies": { "@tscircuit/manual-edit-events": "*", "@tscircuit/schematic-autolayout": "*", "@tscircuit/soup": "*", "@tscircuit/soup-util": "*", "zod": "*" } }, "sha512-Mk7LveFUkvV7X5+DjX3aAKClkvPOcIEiPz6knIxay3VZCMJw7sSX1QJVa6VJiUiaV51uFohqvwymLhYOaW/kAg=="],
@@ -1917,15 +1920,15 @@
1917
1920
 
1918
1921
  "@tscircuit/react-fiber/@tscircuit/soup": ["@tscircuit/soup@0.0.34", "", { "dependencies": { "convert-units": "^2.3.4", "zod": "^3.23.6" } }, "sha512-Xz0bwDE5FiF8qXaG0LZ5UEx7HeKX3FLvKhqq02l+iyzmoSBiwhlf8U4Z2WI+XtY63KSyqlv8r0ixNrtWrlWucQ=="],
1919
1922
 
1920
- "@tscircuit/runframe/@tscircuit/3d-viewer": ["@tscircuit/3d-viewer@0.0.77", "", { "dependencies": { "@jscad/modeling": "^2.12.2", "@jscad/regl-renderer": "^2.6.9", "@jscad/stl-serializer": "^2.1.17", "@react-three/drei": "^9.115.0", "@react-three/fiber": "^8.16.8", "@tscircuit/core": "^0.0.247", "@tscircuit/props": "^0.0.124", "@tscircuit/react-fiber": "^1.1.29", "@tscircuit/soup": "^0.0.69", "@tscircuit/soup-util": "^0.0.26", "@types/three": "^0.165.0", "jscad-electronics": "^0.0.23", "jscad-fiber": "^0.0.76", "jscad-planner": "^0.0.11", "react": "^18.3.1", "react-dom": "^18.3.1", "react-use-gesture": "^9.1.3", "three": "^0.165.0", "three-stdlib": "^2.30.3" } }, "sha512-iDg6ZvhQOHfsbl3VJ9Fxwj9P69SNpjUU+QG1RG3ri3MG6cMjuOHmBoKTjQiisImzrpO1PuMvgzhkpXRKgB3U0Q=="],
1923
+ "@tscircuit/runframe/@tscircuit/3d-viewer": ["@tscircuit/3d-viewer@0.0.134", "", { "dependencies": { "@jscad/regl-renderer": "^2.6.12", "@jscad/stl-serializer": "^2.1.20", "@react-three/drei": "^9.121.4", "@react-three/fiber": "^8.17.14", "@tscircuit/core": "^0.0.311", "@tscircuit/props": "^0.0.147", "@tscircuit/react-fiber": "^1.2.0", "@tscircuit/soup-util": "^0.0.41", "jscad-electronics": "^0.0.23", "jscad-fiber": "^0.0.77", "jscad-planner": "^0.0.12", "react": "^18.3.1", "react-dom": "^18.3.1", "react-use-gesture": "^9.1.3" }, "peerDependencies": { "three": "*" } }, "sha512-wsGUIfyngEz29Xfb277rfcLlvUhEAss0n9ETkyaWhDuRrDoTRAzJfCgXwxEKthL+5pPVipj+Zj0fSx/WyqvjQw=="],
1921
1924
 
1922
- "@tscircuit/runframe/@tscircuit/file-server": ["@tscircuit/file-server@0.0.12", "", { "dependencies": { "winterspec": "^0.0.86", "zod": "^3.23.8", "zustand": "^4.5.5", "zustand-hoist": "^2.0.1" }, "peerDependencies": { "typescript": "^5.0.0" }, "bin": { "file-server": "dist/cli.js" } }, "sha512-HU/CY/b/K1Phqccq6rebluYIHDpTm5HPy4XhU4XelYMZYDvvexgthm3yFI0oFrWH0gOsNQFHfQTymU1Sej+FUA=="],
1925
+ "@tscircuit/runframe/@tscircuit/core": ["@tscircuit/core@0.0.311", "", { "dependencies": { "@lume/kiwi": "^0.4.3", "@tscircuit/footprinter": "^0.0.97", "@tscircuit/infgrid-ijump-astar": "^0.0.33", "@tscircuit/math-utils": "^0.0.9", "@tscircuit/props": "^0.0.145", "@tscircuit/schematic-autolayout": "^0.0.6", "@tscircuit/soup-util": "^0.0.41", "circuit-json": "^0.0.136", "circuit-json-to-connectivity-map": "^0.0.17", "format-si-unit": "^0.0.3", "nanoid": "^5.0.7", "performance-now": "^2.1.0", "react-reconciler": "^0.31.0", "react-reconciler-18": "npm:react-reconciler@0.29.2", "schematic-symbols": "^0.0.119", "transformation-matrix": "^2.16.1", "zod": "^3.23.8" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-f2WjQT6s1UWM4yDIgfqnCBEEROxRzv3CoIixXR249jKAeTrhSnp7Ibhly2NV/uerOtNtFEaw8ZItscPyMzA6mw=="],
1923
1926
 
1924
- "@tscircuit/runframe/@tscircuit/props": ["@tscircuit/props@0.0.124", "", { "peerDependencies": { "@tscircuit/layout": "*", "circuit-json": "*", "react": "*", "zod": "*" } }, "sha512-4lb1I9YxwZ3LKlGqynMK68zT+lKOcdL/D+scwss5AbSkj8pVUhht97hnboAz6Ys3z5zCSDsJvVMoZM/k4d+dNA=="],
1927
+ "@tscircuit/runframe/@tscircuit/props": ["@tscircuit/props@0.0.147", "", { "peerDependencies": { "@tscircuit/layout": "*", "circuit-json": "*", "react": "*", "zod": "*" } }, "sha512-psCDw8wrB4d1EB9Ap3uerzuUkWQEp/gjw4nW9afO+1pzLTLcrf0QnBNbL78e3KdhAd9GyCme/3HSHPmXlvLkLg=="],
1925
1928
 
1926
1929
  "@tscircuit/runframe/@tscircuit/schematic-viewer": ["@tscircuit/schematic-viewer@2.0.9", "", { "dependencies": { "debug": "^4.4.0", "performance-now": "^2.1.0", "use-mouse-matrix-transform": "^1.2.2" }, "peerDependencies": { "@tscircuit/core": "*", "@tscircuit/props": "*", "circuit-to-svg": "*", "typescript": "^5.0.0" } }, "sha512-Dc5MAj94+TX91jDMn0FqARxcYcVCfMwB8OeRpoWIWQxET2h1dBhWH2eEJ88pM8+uF/dg9ZU4JepvuJ8u6YuyHg=="],
1927
1930
 
1928
- "@tscircuit/runframe/lucide-react": ["lucide-react@0.468.0", "", { "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc" } }, "sha512-6koYRhnM2N0GGZIdXzSeiNwguv1gt/FAjZOiPl76roBi3xKEXa4WmfpxgQwTTL4KipXjefrnf3oV4IsYhi4JFA=="],
1931
+ "@tscircuit/runframe/lucide-react": ["lucide-react@0.473.0", "", { "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-KW6u5AKeIjkvrxXZ6WuCu9zHE/gEYSXCay+Gre2ZoInD0Je/e3RBtP4OHpJVJ40nDklSvjVKjgH7VU8/e2dzRw=="],
1929
1932
 
1930
1933
  "@tscircuit/schematic-autolayout/@tscircuit/soup-util": ["@tscircuit/soup-util@0.0.38", "", { "dependencies": { "parsel-js": "^1.1.2" }, "peerDependencies": { "circuit-json": "*", "transformation-matrix": "*", "zod": "*" } }, "sha512-GdcuFxk+qnJZv+eI7ZoJ1MJEseFgRyaztMtQ/OXA2SUnxyPEH0UTy9vkhKTm+8GTePryEgdXcc65TgUyrr44ww=="],
1931
1934
 
@@ -2093,6 +2096,8 @@
2093
2096
 
2094
2097
  "@tscircuit/3d-viewer/jscad-electronics/circuit-json": ["circuit-json@0.0.92", "", { "dependencies": { "nanoid": "^5.0.7", "zod": "^3.23.6" } }, "sha512-cEqFxLadAxS+tm7y5/llS4FtqN3QbzjBNubely7vFo8w05sZnGRCcLzZwKL7rC7He1CqqyFynD4MdeL+F/PjBQ=="],
2095
2098
 
2099
+ "@tscircuit/3d-viewer/jscad-fiber/lucide-react": ["lucide-react@0.456.0", "", { "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc" } }, "sha512-DIIGJqTT5X05sbAsQ+OhA8OtJYyD4NsEMCA/HQW/Y6ToPQ7gwbtujIoeAaup4HpHzV35SQOarKAWH8LYglB6eA=="],
2100
+
2096
2101
  "@tscircuit/pcb-viewer/circuit-json-to-connectivity-map/@tscircuit/math-utils": ["@tscircuit/math-utils@0.0.9", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-sPzfXndijet8z29X6f5vnSZddiso2tRg7m6rB+268bVj60mxnxUMD14rKuMlLn6n84fMOpD/X7pRTZUfi6M+Tg=="],
2097
2102
 
2098
2103
  "@tscircuit/pcb-viewer/circuit-to-svg/@tscircuit/footprinter": ["@tscircuit/footprinter@0.0.57", "", { "dependencies": { "@tscircuit/mm": "^0.0.7", "zod": "^3.23.8" }, "peerDependencies": { "@tscircuit/soup": "*" } }, "sha512-aLUuh3LqeDusjTzp6nyOqss6Et4adTVeCGJpvvq3dosuyfdk5L79l64jdNFK0Bf5fps1SJAHISpPC4nDSJEVfw=="],
@@ -2103,11 +2108,25 @@
2103
2108
 
2104
2109
  "@tscircuit/pcb-viewer/circuit-to-svg/schematic-symbols": ["schematic-symbols@0.0.17", "", { "peerDependencies": { "typescript": "^5.5.4" } }, "sha512-xs/A1MNFZphcYRpTQVWm1OUA4bvWhw9LViKSTxEe0nQEbbfZgMS7hCt+DF6SYDgT8cec9hD4JAQMHh5Cz4om1Q=="],
2105
2110
 
2106
- "@tscircuit/runframe/@tscircuit/3d-viewer/@tscircuit/core": ["@tscircuit/core@0.0.247", "", { "dependencies": { "@lume/kiwi": "^0.4.3", "@tscircuit/footprinter": "^0.0.95", "@tscircuit/infgrid-ijump-astar": "^0.0.26", "@tscircuit/math-utils": "^0.0.5", "@tscircuit/props": "^0.0.123", "@tscircuit/schematic-autolayout": "^0.0.6", "@tscircuit/soup-util": "^0.0.41", "circuit-json": "^0.0.124", "circuit-json-to-connectivity-map": "^0.0.17", "format-si-unit": "^0.0.2", "nanoid": "^5.0.7", "performance-now": "^2.1.0", "react": "^18.3.1", "react-reconciler": "^0.29.2", "schematic-symbols": "^0.0.111", "transformation-matrix": "^2.16.1", "zod": "^3.23.8" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-BaF8YFQc1PzV82VNDTpH8C2qxbVfQV26h0QrHv3UcVjnsZxxlqLAbtSOae8GPcv2avs3z33wBHxrG8k8YBYmTw=="],
2111
+ "@tscircuit/runframe/@tscircuit/3d-viewer/jscad-electronics": ["jscad-electronics@0.0.23", "", { "dependencies": { "@tscircuit/footprinter": "^0.0.87", "circuit-json": "^0.0.92" } }, "sha512-FRSJOLSvyofg1kLMnZ79MYeX+7XTzeOcpHPY1cBJgITZkVK5olwnD8M/2Odi1Lw1o5rTtXddNvypOqmgfcT//Q=="],
2107
2112
 
2108
- "@tscircuit/runframe/@tscircuit/3d-viewer/@tscircuit/soup-util": ["@tscircuit/soup-util@0.0.26", "", { "dependencies": { "@tscircuit/soup": "*", "parsel-js": "^1.1.2", "transformation-matrix": "*" }, "peerDependencies": { "zod": "*" } }, "sha512-+rZ90pzVUsb/vhmU0RivO9ftBi9fuf8AGfYsUf52u5MwnOtt6/YEROFZIKitsPI7YWhbNIzJjW4igISzwypRaw=="],
2113
+ "@tscircuit/runframe/@tscircuit/3d-viewer/jscad-planner": ["jscad-planner@0.0.12", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-yLXgTn/eSjuqIXe0WU+GYh1fQCGIumNbdKIM9SXmXMqGqdmZRwqkr6r8by/9UOitPCyLLzkiD5UMLzp9jpZmKw=="],
2109
2114
 
2110
- "@tscircuit/runframe/@tscircuit/3d-viewer/jscad-electronics": ["jscad-electronics@0.0.23", "", { "dependencies": { "@tscircuit/footprinter": "^0.0.87", "circuit-json": "^0.0.92" } }, "sha512-FRSJOLSvyofg1kLMnZ79MYeX+7XTzeOcpHPY1cBJgITZkVK5olwnD8M/2Odi1Lw1o5rTtXddNvypOqmgfcT//Q=="],
2115
+ "@tscircuit/runframe/@tscircuit/core/@tscircuit/footprinter": ["@tscircuit/footprinter@0.0.97", "", { "dependencies": { "@tscircuit/mm": "^0.0.8", "zod": "^3.23.8" }, "peerDependencies": { "circuit-json": "*" } }, "sha512-LeqjpXqPwR++kcshlfe0E3IOsv0Y9BVRjIllDaHFA2OM+gJ91z/SS3CdweXB+qtF4t9G+8MLKf4nU5L1HDGjmg=="],
2116
+
2117
+ "@tscircuit/runframe/@tscircuit/core/@tscircuit/infgrid-ijump-astar": ["@tscircuit/infgrid-ijump-astar@0.0.33", "", {}, "sha512-tmX4Esp+HqyIGCUD43steVUH8pKRuyBNs21r4NlApGGLu+K1XSrK9FinhVJyMiEsuwJdajLnMTzmVt8vSYSafA=="],
2118
+
2119
+ "@tscircuit/runframe/@tscircuit/core/@tscircuit/math-utils": ["@tscircuit/math-utils@0.0.9", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-sPzfXndijet8z29X6f5vnSZddiso2tRg7m6rB+268bVj60mxnxUMD14rKuMlLn6n84fMOpD/X7pRTZUfi6M+Tg=="],
2120
+
2121
+ "@tscircuit/runframe/@tscircuit/core/@tscircuit/props": ["@tscircuit/props@0.0.145", "", { "peerDependencies": { "@tscircuit/layout": "*", "circuit-json": "*", "react": "*", "zod": "*" } }, "sha512-4/rap4gR2zxjLFvhxYNIpP9J/2DJF6pioquu5urOMvhWLwGDkGmWzH1FoJ307IirH9/4DHNbj4Mqh6GwjCOjPA=="],
2122
+
2123
+ "@tscircuit/runframe/@tscircuit/core/circuit-json": ["circuit-json@0.0.136", "", { "dependencies": { "nanoid": "^5.0.7", "zod": "^3.23.6" } }, "sha512-wCZr8QnMW0RxGIwA3Yk1VPElK2d+BFc2mZkh2hfWxSFqdgIcjybr5Eacrk5auyg9K+0hCGdWTIyF4qEOc8fRbQ=="],
2124
+
2125
+ "@tscircuit/runframe/@tscircuit/core/format-si-unit": ["format-si-unit@0.0.3", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-rhw1g1mOoLV497FtKNbzBPE4fJXfWRmIEPRO0DKXpEPvS54vRLjG8e1jE4vOcjZg4bsoOPJkM9jB6yGk+0XKmQ=="],
2126
+
2127
+ "@tscircuit/runframe/@tscircuit/core/react-reconciler": ["react-reconciler@0.31.0", "", { "dependencies": { "scheduler": "^0.25.0" }, "peerDependencies": { "react": "^19.0.0" } }, "sha512-7Ob7Z+URmesIsIVRjnLoDGwBEG/tVitidU0nMsqX/eeJaLY89RISO/10ERe0MqmzuKUUB1rmY+h1itMbUHg9BQ=="],
2128
+
2129
+ "@tscircuit/runframe/@tscircuit/core/schematic-symbols": ["schematic-symbols@0.0.119", "", { "peerDependencies": { "typescript": "^5.5.4" } }, "sha512-99zCCgIBXMdcxz4qfVK8UAQhzmocMAMZ21adJVws6zOYsGvlJxEcmp/6iisp/Yj7PcPhwLLlddZbHPIEEHdNhw=="],
2111
2130
 
2112
2131
  "@tscircuit/schematic-viewer/@tscircuit/core/@tscircuit/footprinter": ["@tscircuit/footprinter@0.0.77", "", { "dependencies": { "@tscircuit/mm": "^0.0.8", "zod": "^3.23.8" }, "peerDependencies": { "@tscircuit/soup": "*", "circuit-json": "*" } }, "sha512-/ZuN3gfH61SgwASfZO+oOclCD2E15/hB3SKPr3i8tENGcyXP+5U8naqP7T7tkI621FHdCzV1iSykdgNdQYz/xQ=="],
2113
2132
 
@@ -2231,14 +2250,12 @@
2231
2250
 
2232
2251
  "@tscircuit/pcb-viewer/circuit-to-svg/@tscircuit/footprinter/@tscircuit/mm": ["@tscircuit/mm@0.0.7", "", { "dependencies": { "convert-units": "^2.3.4" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-5lZjeOsrkQDnMd4OEuXQYC8k+zuWCbX9Ruq69JhcvLu18FUen3pPjBxmFyF2DGZYxaTrKUpUdZvoTr49TISN2g=="],
2233
2252
 
2234
- "@tscircuit/runframe/@tscircuit/3d-viewer/@tscircuit/core/@tscircuit/props": ["@tscircuit/props@0.0.123", "", { "peerDependencies": { "@tscircuit/layout": "*", "circuit-json": "*", "react": "*", "zod": "*" } }, "sha512-tW4cXfpAL9gYFVqXANutxg9FNb0/TFnsPpbMB+rwOdw6RiCrDtJUKQHYxB+nlYE3AUMb45vG5XSgvB97BFXMvA=="],
2235
-
2236
- "@tscircuit/runframe/@tscircuit/3d-viewer/@tscircuit/core/@tscircuit/soup-util": ["@tscircuit/soup-util@0.0.41", "", { "dependencies": { "parsel-js": "^1.1.2" }, "peerDependencies": { "circuit-json": "*", "transformation-matrix": "*", "zod": "*" } }, "sha512-47JKWBUKkRVHhad0HhBbdOJxB6v/eiac46beiKRBMlJqiZ1gPGI276v9iZfpF7c4hXR69cURcgiwuA5vowrFEg=="],
2237
-
2238
2253
  "@tscircuit/runframe/@tscircuit/3d-viewer/jscad-electronics/@tscircuit/footprinter": ["@tscircuit/footprinter@0.0.87", "", { "dependencies": { "@tscircuit/mm": "^0.0.8", "zod": "^3.23.8" }, "peerDependencies": { "@tscircuit/soup": "*", "circuit-json": "*" } }, "sha512-SSsbC/G9kPf63Eke0EuF7l9V2pLCTWTNmLhGMglQmXfNUogDE6QCRjLHmgYrl2ignB+dIW9JbkKiqVFhXugFEw=="],
2239
2254
 
2240
2255
  "@tscircuit/runframe/@tscircuit/3d-viewer/jscad-electronics/circuit-json": ["circuit-json@0.0.92", "", { "dependencies": { "nanoid": "^5.0.7", "zod": "^3.23.6" } }, "sha512-cEqFxLadAxS+tm7y5/llS4FtqN3QbzjBNubely7vFo8w05sZnGRCcLzZwKL7rC7He1CqqyFynD4MdeL+F/PjBQ=="],
2241
2256
 
2257
+ "@tscircuit/runframe/@tscircuit/core/react-reconciler/scheduler": ["scheduler@0.25.0", "", {}, "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA=="],
2258
+
2242
2259
  "@tscircuit/schematic-viewer/@tscircuit/core/circuit-to-svg/@tscircuit/footprinter": ["@tscircuit/footprinter@0.0.57", "", { "dependencies": { "@tscircuit/mm": "^0.0.7", "zod": "^3.23.8" }, "peerDependencies": { "@tscircuit/soup": "*" } }, "sha512-aLUuh3LqeDusjTzp6nyOqss6Et4adTVeCGJpvvq3dosuyfdk5L79l64jdNFK0Bf5fps1SJAHISpPC4nDSJEVfw=="],
2243
2260
 
2244
2261
  "@tscircuit/schematic-viewer/@tscircuit/core/circuit-to-svg/@tscircuit/soup-util": ["@tscircuit/soup-util@0.0.28", "", { "dependencies": { "parsel-js": "^1.1.2" }, "peerDependencies": { "@tscircuit/soup": "*", "transformation-matrix": "*", "zod": "*" } }, "sha512-AEImLyTmx/lPQCH6sFj6QOQk++Oyz3Dbtz0gIo1rdgpK6M4jJmoQjeUfMi93KsrSCrryAXt7D0oezTlC6u+c6w=="],
@@ -2,53 +2,8 @@ import type { Command } from "commander"
2
2
  import { getKy } from "lib/registry-api/get-ky"
3
3
  import * as fs from "node:fs"
4
4
  import * as path from "node:path"
5
- import { execSync } from "node:child_process"
6
-
7
- // Detect the package manager being used in the project
8
- const detectPackageManager = (): string => {
9
- const userAgent = process.env.npm_config_user_agent || ""
10
- if (userAgent.startsWith("yarn")) return "yarn"
11
- if (userAgent.startsWith("pnpm")) return "pnpm"
12
- if (userAgent.startsWith("bun")) return "bun"
13
-
14
- if (fs.existsSync("yarn.lock")) return "yarn"
15
- if (fs.existsSync("pnpm-lock.yaml")) return "pnpm"
16
- if (fs.existsSync("bun.lockb")) return "bun"
17
-
18
- return "npm" // Default to npm
19
- }
20
-
21
- // Generate a React-compatible tsconfig.json
22
- const generateTsConfig = (dir: string) => {
23
- const tsconfigPath = path.join(dir, "tsconfig.json")
24
- const tsconfigContent = JSON.stringify(
25
- {
26
- compilerOptions: {
27
- target: "ES6",
28
- module: "ESNext",
29
- jsx: "react-jsx",
30
- outDir: "dist",
31
- strict: true,
32
- esModuleInterop: true,
33
- moduleResolution: "node",
34
- skipLibCheck: true,
35
- forceConsistentCasingInFileNames: true,
36
- resolveJsonModule: true,
37
- sourceMap: true,
38
- allowSyntheticDefaultImports: true,
39
- experimentalDecorators: true,
40
- },
41
- },
42
- null,
43
- 2,
44
- )
45
- if (!fs.existsSync(tsconfigPath)) {
46
- fs.writeFileSync(tsconfigPath, tsconfigContent.trimStart())
47
- console.log(`Created: ${tsconfigPath}`)
48
- } else {
49
- console.log(`Skipped: ${tsconfigPath} already exists`)
50
- }
51
- }
5
+ import { setupTsciProject } from "lib/shared/setup-tsci-packages"
6
+ import { generateTsConfig } from "lib/shared/generate-ts-config"
52
7
 
53
8
  export const registerClone = (program: Command) => {
54
9
  program
@@ -56,120 +11,92 @@ export const registerClone = (program: Command) => {
56
11
  .description("Clone a snippet from the registry")
57
12
  .argument("<snippet>", "Snippet to clone (e.g. author/snippetName)")
58
13
  .action(async (snippetPath: string) => {
59
- let author: string
60
- let snippetName: string
61
- if (!snippetPath.startsWith("@tsci/") && snippetPath.includes("/")) {
62
- ;[author, snippetName] = snippetPath.split("/")
63
- } else {
64
- const trimmedPath = snippetPath.replace("@tsci/", "")
65
- const firstDotIndex = trimmedPath.indexOf(".")
66
- author = trimmedPath.slice(0, firstDotIndex)
67
- snippetName = trimmedPath.slice(firstDotIndex + 1)
68
- }
69
-
70
- if (!author || !snippetName) {
14
+ const match = snippetPath.match(/^(?:@tsci\/)?([^/.]+)[/.](.+)$/)
15
+ if (!match) {
71
16
  console.error(
72
- "Invalid snippet path. Use format: author/snippetName, author.snippetName or @tsci/author.snippetName",
17
+ "Invalid snippet path. Use format: author/snippetName, author.snippetName, or @tsci/author.snippetName",
73
18
  )
74
19
  process.exit(1)
75
20
  }
76
21
 
77
- const ky = getKy()
22
+ const [, author, snippetName] = match
23
+ console.log(`Cloning ${author}/${snippetName}...`)
78
24
 
25
+ const ky = getKy()
26
+ let packageFileList
79
27
  try {
80
- console.log(`Cloning ${author}/${snippetName}...`)
81
-
82
- const packageFileList = await ky
83
- .post<{
84
- package_files: Array<{
85
- package_file_id: string
86
- package_release_id: string
87
- file_path: string
88
- created_at: string
89
- }>
90
- }>("package_files/list", {
91
- json: {
92
- package_name: `${author}/${snippetName}`,
93
- use_latest_version: true,
28
+ packageFileList = await ky
29
+ .post<{ package_files: Array<{ file_path: string }> }>(
30
+ "package_files/list",
31
+ {
32
+ json: {
33
+ package_name: `${author}/${snippetName}`,
34
+ use_latest_version: true,
35
+ },
94
36
  },
95
- })
37
+ )
96
38
  .json()
39
+ } catch (error) {
40
+ console.error(
41
+ "Failed to fetch package files:",
42
+ error instanceof Error ? error.message : error,
43
+ )
44
+ process.exit(1)
45
+ }
97
46
 
98
- // Create directory if it doesn't exist
99
- const dirPath = `./${author}.${snippetName}`
100
- if (!fs.existsSync(dirPath)) {
101
- fs.mkdirSync(dirPath)
102
- }
47
+ const dirPath = path.resolve(`${author}.${snippetName}`)
48
+ fs.mkdirSync(dirPath, { recursive: true })
103
49
 
104
- // Download each file that doesn't start with dist/
105
- for (const fileInfo of packageFileList.package_files) {
106
- const filePath = fileInfo.file_path.startsWith("/")
107
- ? fileInfo.file_path.slice(1)
108
- : fileInfo.file_path
50
+ for (const fileInfo of packageFileList.package_files) {
51
+ const filePath = fileInfo.file_path.replace(/^\/|dist\//g, "")
52
+ if (!filePath) continue
109
53
 
110
- if (filePath.startsWith("dist/")) continue
54
+ const fullPath = path.join(dirPath, filePath)
55
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true })
111
56
 
57
+ try {
112
58
  const fileContent = await ky
113
- .post<{
114
- package_file: {
115
- content_text: string
116
- }
117
- }>("package_files/get", {
118
- json: {
119
- package_name: `${author}/${snippetName}`,
120
- file_path: fileInfo.file_path,
59
+ .post<{ package_file: { content_text: string } }>(
60
+ "package_files/get",
61
+ {
62
+ json: {
63
+ package_name: `${author}/${snippetName}`,
64
+ file_path: fileInfo.file_path,
65
+ },
121
66
  },
122
- })
67
+ )
123
68
  .json()
124
69
 
125
- const fullPath = path.join(dirPath, filePath)
126
- const dirName = path.dirname(fullPath)
70
+ let fileText = fileContent.package_file.content_text
127
71
 
128
- // Create nested directories if they don't exist
129
- if (!fs.existsSync(dirName)) {
130
- fs.mkdirSync(dirName, { recursive: true })
72
+ // Ensure all .tsx files contain "import '@tscircuit/core';"
73
+ if (
74
+ filePath.endsWith(".tsx") &&
75
+ !fileText.includes("@tscircuit/core")
76
+ ) {
77
+ fileText = `import "@tscircuit/core";\n\n${fileText}`
131
78
  }
132
79
 
133
- fs.writeFileSync(fullPath, fileContent.package_file.content_text)
80
+ fs.writeFileSync(fullPath, fileText)
81
+ } catch (error) {
82
+ console.warn(
83
+ `Skipping ${filePath} due to error:`,
84
+ error instanceof Error ? error.message : error,
85
+ )
134
86
  }
87
+ }
135
88
 
136
- const npmrcPath = path.join(dirPath, ".npmrc")
137
- fs.writeFileSync(npmrcPath, "@tsci:registry=https://npm.tscircuit.com")
138
-
139
- // Generate tsconfig.json
140
- generateTsConfig(dirPath)
141
-
142
- // Detect package manager and install dependencies
143
- const packageManager = detectPackageManager()
144
- console.log(`Detected package manager: ${packageManager}`)
89
+ fs.writeFileSync(
90
+ path.join(dirPath, ".npmrc"),
91
+ "@tsci:registry=https://npm.tscircuit.com",
92
+ )
145
93
 
146
- // Install deps using the detected package manager
147
- const dependencies = "@types/react @tscircuit/core"
148
- try {
149
- console.log("Installing dependencies...")
150
- const installCommand =
151
- packageManager === "yarn"
152
- ? `cd ${dirPath} && yarn add -D ${dependencies}`
153
- : packageManager === "pnpm"
154
- ? `cd ${dirPath} && pnpm add -D ${dependencies}`
155
- : packageManager === "bun"
156
- ? `cd ${dirPath} && bun add -D ${dependencies}`
157
- : `cd ${dirPath} && npm install -D ${dependencies}`
158
- execSync(installCommand, { stdio: "inherit" })
159
- console.log("Dependencies installed successfully.")
160
- } catch (error) {
161
- console.error("Failed to install dependencies:", error)
162
- }
94
+ generateTsConfig(dirPath)
95
+ setupTsciProject(dirPath)
163
96
 
164
- console.log(`Successfully cloned to ./${author}.${snippetName}/`)
165
- console.log(`Run "cd ${dirPath} && tsci dev" to start developing.`)
166
- } catch (error) {
167
- if (error instanceof Error) {
168
- console.error("Failed to clone snippet:", error.message)
169
- } else {
170
- console.error("Failed to clone snippet:", error)
171
- }
172
- process.exit(1)
173
- }
97
+ console.log(`Successfully cloned to ${dirPath}/`)
98
+ console.log(
99
+ `Run "cd ${path.dirname(dirPath)} && tsci dev" to start developing.`,
100
+ )
174
101
  })
175
102
  }
@@ -1,6 +1,6 @@
1
1
  import type { Command } from "commander"
2
- import { createCircuitWebWorker } from "@tscircuit/eval-webworker"
3
- import webWorkerBundleUrl from "@tscircuit/eval-webworker/blob-url"
2
+ import { createCircuitWebWorker } from "@tscircuit/eval"
3
+ import webWorkerBundleUrl from "@tscircuit/eval/blob-url"
4
4
  import { getVirtualFileSystemFromDirPath } from "make-vfs"
5
5
  import path from "node:path"
6
6
  import fs from "node:fs"
@@ -1,136 +1,70 @@
1
1
  import type { Command } from "commander"
2
2
  import * as fs from "node:fs"
3
3
  import * as path from "node:path"
4
- import { execSync } from "node:child_process"
5
-
6
- // Detect the package manager being used in the project
7
- const detectPackageManager = (): string => {
8
- const userAgent = process.env.npm_config_user_agent || ""
9
- if (userAgent.startsWith("yarn")) return "yarn"
10
- if (userAgent.startsWith("pnpm")) return "pnpm"
11
- if (userAgent.startsWith("bun")) return "bun"
12
-
13
- if (fs.existsSync("yarn.lock")) return "yarn"
14
- if (fs.existsSync("pnpm-lock.yaml")) return "pnpm"
15
- if (fs.existsSync("bun.lockb")) return "bun"
16
-
17
- return "npm" // Default to npm
18
- }
19
-
20
- // Generate a React-compatible tsconfig.json
21
- const generateTsConfig = (dir: string) => {
22
- const tsconfigPath = path.join(dir, "tsconfig.json")
23
- const tsconfigContent = JSON.stringify(
24
- {
25
- compilerOptions: {
26
- target: "ES6",
27
- module: "ESNext",
28
- jsx: "react-jsx",
29
- outDir: "dist",
30
- strict: true,
31
- esModuleInterop: true,
32
- moduleResolution: "node",
33
- skipLibCheck: true,
34
- forceConsistentCasingInFileNames: true,
35
- resolveJsonModule: true,
36
- sourceMap: true,
37
- allowSyntheticDefaultImports: true,
38
- experimentalDecorators: true,
39
- },
40
- },
41
- null,
42
- 2,
43
- )
44
- if (!fs.existsSync(tsconfigPath)) {
45
- fs.writeFileSync(tsconfigPath, tsconfigContent.trimStart())
46
- console.log(`Created: ${tsconfigPath}`)
47
- } else {
48
- console.log(`Skipped: ${tsconfigPath} already exists`)
49
- }
50
- }
4
+ import { setupTsciProject } from "lib/shared/setup-tsci-packages"
5
+ import { generateTsConfig } from "lib/shared/generate-ts-config"
6
+ import { writeFileIfNotExists } from "lib/shared/write-file-if-not-exists"
51
7
 
52
8
  export const registerInit = (program: Command) => {
53
9
  program
54
10
  .command("init")
55
- .description("Initialize a new TSCircuit project in the current directory")
56
- .action(() => {
57
- const currentDir = process.cwd()
58
- const indexFilePath = path.join(currentDir, "index.tsx")
59
- const npmrcFilePath = path.join(currentDir, ".npmrc")
11
+ .description(
12
+ "Initialize a new TSCircuit project in the specified directory (or current directory if none is provided)",
13
+ )
14
+ .argument(
15
+ "[directory]",
16
+ "Directory name (optional, defaults to current directory)",
17
+ )
18
+ .action((directory?: string) => {
19
+ const projectDir = directory
20
+ ? path.resolve(process.cwd(), directory)
21
+ : process.cwd()
22
+
23
+ // Ensure the directory exists
24
+ fs.mkdirSync(projectDir, { recursive: true })
60
25
 
61
- // Content for index.tsx
62
- const indexContent = `
63
- import "@tscircuit/core"
26
+ // Create essential project files
27
+ writeFileIfNotExists(
28
+ path.join(projectDir, "index.tsx"),
29
+ `
30
+ import "@tscircuit/core";
64
31
 
65
32
  export default () => (
66
33
  <board width="10mm" height="10mm">
67
- <resistor
68
- resistance="1k"
69
- footprint="0402"
70
- name="R1"
71
- schX={3}
72
- pcbX={3}
73
- />
74
- <capacitor
75
- capacitance="1000pF"
76
- footprint="0402"
77
- name="C1"
78
- schX={-3}
79
- pcbX={-3}
80
- />
34
+ <resistor resistance="1k" footprint="0402" name="R1" schX={3} pcbX={3} />
35
+ <capacitor capacitance="1000pF" footprint="0402" name="C1" schX={-3} pcbX={-3} />
81
36
  <trace from=".R1 > .pin1" to=".C1 > .pin1" />
82
37
  </board>
83
38
  );
84
- `.trim()
39
+ `,
40
+ )
85
41
 
86
- // Content for .npmrc
87
- const npmrcContent = `
42
+ writeFileIfNotExists(
43
+ path.join(projectDir, ".npmrc"),
44
+ `
88
45
  @tsci:registry=https://npm.tscircuit.com
89
- `.trim()
90
-
91
- // Create index.tsx if it doesn't exist
92
- if (!fs.existsSync(indexFilePath)) {
93
- fs.writeFileSync(indexFilePath, indexContent.trimStart())
94
- console.log(`Created: ${indexFilePath}`)
95
- } else {
96
- console.log(`Skipped: ${indexFilePath} already exists`)
97
- }
98
-
99
- // Create .npmrc if it doesn't exist
100
- if (!fs.existsSync(npmrcFilePath)) {
101
- fs.writeFileSync(npmrcFilePath, npmrcContent.trimStart())
102
- console.log(`Created: ${npmrcFilePath}`)
103
- } else {
104
- console.log(`Skipped: ${npmrcFilePath} already exists`)
105
- }
106
-
107
- // Detect the package manager
108
- const packageManager = detectPackageManager()
109
- console.log(`Detected package manager: ${packageManager}`)
46
+ `,
47
+ )
110
48
 
111
- // Install deps using the detected package manager
112
- const dependencies = "@types/react @tscircuit/core"
49
+ // Setup project dependencies
113
50
  try {
114
- console.log("Installing dependencies...")
115
- const installCommand =
116
- packageManager === "yarn"
117
- ? `yarn add -D ${dependencies}`
118
- : packageManager === "pnpm"
119
- ? `pnpm add -D ${dependencies}`
120
- : packageManager === "bun"
121
- ? `bun add -D ${dependencies}`
122
- : `npm install -D ${dependencies}`
123
- execSync(installCommand, { stdio: "inherit" })
124
- console.log("Dependencies installed successfully.")
51
+ setupTsciProject(projectDir)
125
52
  } catch (error) {
126
53
  console.error("Failed to install dependencies:", error)
54
+ process.exit(1)
127
55
  }
128
56
 
129
57
  // Generate tsconfig.json
130
- generateTsConfig(currentDir)
58
+ try {
59
+ generateTsConfig(projectDir)
60
+ } catch (error) {
61
+ console.error("Failed to generate tsconfig.json:", error)
62
+ process.exit(1)
63
+ }
131
64
 
132
- console.log(
133
- `Initialization complete. Run "tsci dev" to start developing.`,
65
+ console.info(
66
+ `🎉 Initialization complete! Run ${directory ? `"cd ${directory}" & ` : ""}"tsci dev" to start developing.`,
134
67
  )
68
+ process.exit(0)
135
69
  })
136
70
  }