@tscircuit/fake-snippets 0.0.1

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.
Files changed (396) hide show
  1. package/.github/CODEOWNERS +1 -0
  2. package/.github/workflows/bun-formatcheck.yml +26 -0
  3. package/.github/workflows/bun-test.yml +28 -0
  4. package/.github/workflows/bun-typecheck.yml +26 -0
  5. package/.github/workflows/bundle-size-analysis.yml +79 -0
  6. package/.github/workflows/playwright-test.yml +37 -0
  7. package/.github/workflows/stale.yml +40 -0
  8. package/.github/workflows/update-snapshots.yml +49 -0
  9. package/CONTRIBUTING.md +59 -0
  10. package/LICENSE +21 -0
  11. package/README.md +113 -0
  12. package/biome.json +60 -0
  13. package/bun-tests/fake-snippets-api/fixtures/get-circuit-json.ts +148 -0
  14. package/bun-tests/fake-snippets-api/fixtures/get-test-server.ts +96 -0
  15. package/bun-tests/fake-snippets-api/fixtures/start-server.ts +44 -0
  16. package/bun-tests/fake-snippets-api/routes/accounts/get_account_balance.test.ts +18 -0
  17. package/bun-tests/fake-snippets-api/routes/health.test.ts +9 -0
  18. package/bun-tests/fake-snippets-api/routes/order_files/get.test.ts +48 -0
  19. package/bun-tests/fake-snippets-api/routes/order_files/upload.test.ts +77 -0
  20. package/bun-tests/fake-snippets-api/routes/orders/create.test.ts +19 -0
  21. package/bun-tests/fake-snippets-api/routes/orders/get.test.ts +38 -0
  22. package/bun-tests/fake-snippets-api/routes/orders/list.test.ts +30 -0
  23. package/bun-tests/fake-snippets-api/routes/orders/update.test.ts +46 -0
  24. package/bun-tests/fake-snippets-api/routes/snippets/add_star.test.ts +114 -0
  25. package/bun-tests/fake-snippets-api/routes/snippets/create.test.ts +28 -0
  26. package/bun-tests/fake-snippets-api/routes/snippets/delete.test.ts +106 -0
  27. package/bun-tests/fake-snippets-api/routes/snippets/download.test.ts +90 -0
  28. package/bun-tests/fake-snippets-api/routes/snippets/generate_from_jlcpcb.test.ts +25 -0
  29. package/bun-tests/fake-snippets-api/routes/snippets/get_image.test.ts +113 -0
  30. package/bun-tests/fake-snippets-api/routes/snippets/images.test.ts +112 -0
  31. package/bun-tests/fake-snippets-api/routes/snippets/list.test.ts +62 -0
  32. package/bun-tests/fake-snippets-api/routes/snippets/list_newest.test.ts +48 -0
  33. package/bun-tests/fake-snippets-api/routes/snippets/list_trending.test.ts +69 -0
  34. package/bun-tests/fake-snippets-api/routes/snippets/remove_star.test.ts +110 -0
  35. package/bun-tests/fake-snippets-api/routes/snippets/search.test.ts +75 -0
  36. package/bun-tests/fake-snippets-api/routes/snippets/star-count.test.ts +44 -0
  37. package/bun-tests/fake-snippets-api/routes/snippets/update.test.ts +116 -0
  38. package/bun-tests/parts-engine.test.ts +18 -0
  39. package/bun.lockb +0 -0
  40. package/bunfig.toml +2 -0
  41. package/components.json +20 -0
  42. package/dist/assets/editor_example_1-1000w.webp +0 -0
  43. package/dist/assets/editor_example_1-1200w.webp +0 -0
  44. package/dist/assets/editor_example_1-1600w.webp +0 -0
  45. package/dist/assets/editor_example_1-2000w.webp +0 -0
  46. package/dist/assets/editor_example_1-400w.webp +0 -0
  47. package/dist/assets/editor_example_1-600w.webp +0 -0
  48. package/dist/assets/editor_example_1-800w.webp +0 -0
  49. package/dist/assets/editor_example_1_more_square-1000w.webp +0 -0
  50. package/dist/assets/editor_example_1_more_square-1200w.webp +0 -0
  51. package/dist/assets/editor_example_1_more_square-1600w.webp +0 -0
  52. package/dist/assets/editor_example_1_more_square-2000w.webp +0 -0
  53. package/dist/assets/editor_example_1_more_square-400w.webp +0 -0
  54. package/dist/assets/editor_example_1_more_square-600w.webp +0 -0
  55. package/dist/assets/editor_example_1_more_square-800w.webp +0 -0
  56. package/dist/assets/editor_example_2-1000w.webp +0 -0
  57. package/dist/assets/editor_example_2-1200w.webp +0 -0
  58. package/dist/assets/editor_example_2-1600w.webp +0 -0
  59. package/dist/assets/editor_example_2-2000w.webp +0 -0
  60. package/dist/assets/editor_example_2-400w.webp +0 -0
  61. package/dist/assets/editor_example_2-600w.webp +0 -0
  62. package/dist/assets/editor_example_2-800w.webp +0 -0
  63. package/dist/assets/example_schematic-1000w.webp +0 -0
  64. package/dist/assets/example_schematic-1200w.webp +0 -0
  65. package/dist/assets/example_schematic-1600w.webp +0 -0
  66. package/dist/assets/example_schematic-2000w.webp +0 -0
  67. package/dist/assets/example_schematic-400w.webp +0 -0
  68. package/dist/assets/example_schematic-600w.webp +0 -0
  69. package/dist/assets/example_schematic-800w.webp +0 -0
  70. package/dist/bundle.js +3270 -0
  71. package/dist/robots.txt +9 -0
  72. package/dist/sitemap.xml +118 -0
  73. package/docs/CIRCUIT_JSON_SOURCE_COMPONENT_OVERVIEW.md +151 -0
  74. package/fake-snippets-api/README.md +6 -0
  75. package/fake-snippets-api/biome.json +47 -0
  76. package/fake-snippets-api/bun.lockb +0 -0
  77. package/fake-snippets-api/lib/db/autoload-dev-snippets.ts +84 -0
  78. package/fake-snippets-api/lib/db/autoload-snippets.json +24 -0
  79. package/fake-snippets-api/lib/db/db-client.ts +343 -0
  80. package/fake-snippets-api/lib/db/schema.ts +112 -0
  81. package/fake-snippets-api/lib/db/seed.ts +1608 -0
  82. package/fake-snippets-api/lib/middleware/with-ctx-error.ts +26 -0
  83. package/fake-snippets-api/lib/middleware/with-db.ts +15 -0
  84. package/fake-snippets-api/lib/middleware/with-error-handling.ts +24 -0
  85. package/fake-snippets-api/lib/middleware/with-optional-session-auth.ts +34 -0
  86. package/fake-snippets-api/lib/middleware/with-request-logging.ts +54 -0
  87. package/fake-snippets-api/lib/middleware/with-session-auth.ts +39 -0
  88. package/fake-snippets-api/lib/middleware/with-winter-spec.ts +24 -0
  89. package/fake-snippets-api/next-env.d.ts +5 -0
  90. package/fake-snippets-api/routes/api/accounts/get.ts +21 -0
  91. package/fake-snippets-api/routes/api/accounts/get_account_balance.ts +22 -0
  92. package/fake-snippets-api/routes/api/accounts/update.ts +32 -0
  93. package/fake-snippets-api/routes/api/ai/[...anyroute].ts +31 -0
  94. package/fake-snippets-api/routes/api/ai.ts +2 -0
  95. package/fake-snippets-api/routes/api/aistream/[...anyroute].ts +65 -0
  96. package/fake-snippets-api/routes/api/health.ts +9 -0
  97. package/fake-snippets-api/routes/api/internal/sessions/create_without_auth.ts +63 -0
  98. package/fake-snippets-api/routes/api/order_files/get.ts +28 -0
  99. package/fake-snippets-api/routes/api/order_files/upload.ts +43 -0
  100. package/fake-snippets-api/routes/api/orders/create.ts +41 -0
  101. package/fake-snippets-api/routes/api/orders/get.ts +28 -0
  102. package/fake-snippets-api/routes/api/orders/list.ts +15 -0
  103. package/fake-snippets-api/routes/api/orders/update.ts +50 -0
  104. package/fake-snippets-api/routes/api/snippets/add_star.ts +42 -0
  105. package/fake-snippets-api/routes/api/snippets/create.ts +55 -0
  106. package/fake-snippets-api/routes/api/snippets/delete.ts +41 -0
  107. package/fake-snippets-api/routes/api/snippets/download.ts +148 -0
  108. package/fake-snippets-api/routes/api/snippets/generate_from_jlcpcb.ts +55 -0
  109. package/fake-snippets-api/routes/api/snippets/get.ts +50 -0
  110. package/fake-snippets-api/routes/api/snippets/get_image.ts +65 -0
  111. package/fake-snippets-api/routes/api/snippets/images/[author]/[snippet_name]/[typeFormat].ts +74 -0
  112. package/fake-snippets-api/routes/api/snippets/list.ts +28 -0
  113. package/fake-snippets-api/routes/api/snippets/list_newest.ts +13 -0
  114. package/fake-snippets-api/routes/api/snippets/list_trending.ts +21 -0
  115. package/fake-snippets-api/routes/api/snippets/remove_star.ts +42 -0
  116. package/fake-snippets-api/routes/api/snippets/search.ts +18 -0
  117. package/fake-snippets-api/routes/api/snippets/update.ts +86 -0
  118. package/favicon.ico +0 -0
  119. package/index.html +23 -0
  120. package/landing.html +23 -0
  121. package/package.json +164 -0
  122. package/playwright-tests/ai-page.spec.ts +19 -0
  123. package/playwright-tests/cmd-click.spec.ts +43 -0
  124. package/playwright-tests/dashboard-page.spec.ts +10 -0
  125. package/playwright-tests/editor-page.spec.ts +15 -0
  126. package/playwright-tests/files-dialog.spec.ts +19 -0
  127. package/playwright-tests/footprint-dialog/footprint-dialog.spec.ts +27 -0
  128. package/playwright-tests/footprint-dialog/footprint-insertion.spec.ts +38 -0
  129. package/playwright-tests/footprint-dialog/footprint-preview.spec.ts +34 -0
  130. package/playwright-tests/footprint-dialog/footprint-selection.spec.ts +29 -0
  131. package/playwright-tests/handle-manual-edits.spec.ts +55 -0
  132. package/playwright-tests/home-page.spec.ts +10 -0
  133. package/playwright-tests/images.spec.ts +17 -0
  134. package/playwright-tests/manual-edits.spec.ts +89 -0
  135. package/playwright-tests/preview-page.spec.ts +14 -0
  136. package/playwright-tests/quickstart-page.spec.ts +10 -0
  137. package/playwright-tests/search-links.spec.ts +21 -0
  138. package/playwright-tests/search.spec.ts +27 -0
  139. package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-lg.png +0 -0
  140. package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-md.png +0 -0
  141. package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-xs.png +0 -0
  142. package/playwright-tests/snapshots/cmd-click.spec.ts-underlined-imports.png +0 -0
  143. package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-lg.png +0 -0
  144. package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-md.png +0 -0
  145. package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-xs.png +0 -0
  146. package/playwright-tests/snapshots/editor-page.spec.ts-editor-with-snippet.png +0 -0
  147. package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-lg.png +0 -0
  148. package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-md.png +0 -0
  149. package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-xs.png +0 -0
  150. package/playwright-tests/snapshots/files-dialog.spec.ts-view-snippet-files.png +0 -0
  151. package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-lg.png +0 -0
  152. package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-md.png +0 -0
  153. package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-xs.png +0 -0
  154. package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-lg.png +0 -0
  155. package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-md.png +0 -0
  156. package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-xs.png +0 -0
  157. package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-lg.png +0 -0
  158. package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-md.png +0 -0
  159. package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-xs.png +0 -0
  160. package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-lg.png +0 -0
  161. package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-md.png +0 -0
  162. package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-xs.png +0 -0
  163. package/playwright-tests/snapshots/handle-manual-edits.spec.ts-handle-manual-edits.png +0 -0
  164. package/playwright-tests/snapshots/home-page.spec.ts-Home-page-lg.png +0 -0
  165. package/playwright-tests/snapshots/home-page.spec.ts-Home-page-md.png +0 -0
  166. package/playwright-tests/snapshots/home-page.spec.ts-Home-page-xs.png +0 -0
  167. package/playwright-tests/snapshots/images.spec.ts-pcb-image.png +0 -0
  168. package/playwright-tests/snapshots/images.spec.ts-schematic-image.png +0 -0
  169. package/playwright-tests/snapshots/manual-edits.spec.ts-editor-manual-edits.png +0 -0
  170. package/playwright-tests/snapshots/manual-edits.spec.ts-manual-edits-view.png +0 -0
  171. package/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-pcb.png +0 -0
  172. package/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-schematic.png +0 -0
  173. package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagelg.png +0 -0
  174. package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagemd.png +0 -0
  175. package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagexs.png +0 -0
  176. package/playwright-tests/snapshots/search-links.spec.ts-search-links.png +0 -0
  177. package/playwright-tests/snapshots/search.spec.ts-search-lg.png +0 -0
  178. package/playwright-tests/snapshots/search.spec.ts-search-md.png +0 -0
  179. package/playwright-tests/snapshots/search.spec.ts-search-xs.png +0 -0
  180. package/playwright-tests/snapshots/star.spec.ts-remove-star-button.png +0 -0
  181. package/playwright-tests/snapshots/star.spec.ts-star-button.png +0 -0
  182. package/playwright-tests/snapshots/update-description.spec.ts-update-description.png +0 -0
  183. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-lg.png +0 -0
  184. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-md.png +0 -0
  185. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-xs.png +0 -0
  186. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-lg.png +0 -0
  187. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-md.png +0 -0
  188. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-xs.png +0 -0
  189. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-files.png +0 -0
  190. package/playwright-tests/star.spec.ts +40 -0
  191. package/playwright-tests/update-description.spec.ts +18 -0
  192. package/playwright-tests/view-snippet.spec.ts +35 -0
  193. package/playwright-tests/viewports.ts +5 -0
  194. package/playwright.config.ts +27 -0
  195. package/postcss.config.js +6 -0
  196. package/public/robots.txt +9 -0
  197. package/renovate.json +24 -0
  198. package/scripts/generate-image-sizes.ts +58 -0
  199. package/scripts/generate-sitemap.ts +103 -0
  200. package/scripts/generate_bundle_stats.js +192 -0
  201. package/scripts/snapshot.ts +35 -0
  202. package/src/App.tsx +113 -0
  203. package/src/ContextProviders.tsx +9 -0
  204. package/src/assets/originals/editor_example_1.webp +0 -0
  205. package/src/assets/originals/editor_example_1_more_square.webp +0 -0
  206. package/src/assets/originals/editor_example_2.webp +0 -0
  207. package/src/assets/originals/example_schematic.webp +0 -0
  208. package/src/components/AiChatInterface.tsx +221 -0
  209. package/src/components/AiChatMessage.tsx +86 -0
  210. package/src/components/Analytics.tsx +30 -0
  211. package/src/components/BomTable.tsx +69 -0
  212. package/src/components/ChatInput.tsx +53 -0
  213. package/src/components/CircuitToSvgWithMouseControl.tsx +78 -0
  214. package/src/components/CmdKMenu.tsx +301 -0
  215. package/src/components/CodeAndPreview.tsx +258 -0
  216. package/src/components/CodeEditor.tsx +460 -0
  217. package/src/components/CodeEditorHeader.tsx +160 -0
  218. package/src/components/CreateNewSnippetWithAiHero.tsx +77 -0
  219. package/src/components/DownloadButtonAndMenu.tsx +212 -0
  220. package/src/components/EditorNav.tsx +428 -0
  221. package/src/components/ErrorFallback.tsx +25 -0
  222. package/src/components/ErrorTabContent.tsx +122 -0
  223. package/src/components/FAQ.tsx +113 -0
  224. package/src/components/Footer.tsx +134 -0
  225. package/src/components/Footer2.tsx +100 -0
  226. package/src/components/FootprintDialog.tsx +342 -0
  227. package/src/components/Header.tsx +187 -0
  228. package/src/components/Header2.tsx +135 -0
  229. package/src/components/HeaderDropdown.tsx +83 -0
  230. package/src/components/HeaderLogin.tsx +94 -0
  231. package/src/components/JLCPCBImportDialog.tsx +155 -0
  232. package/src/components/LandingHero.tsx +175 -0
  233. package/src/components/LatestSnippets.tsx +39 -0
  234. package/src/components/OptimizedImage.tsx +96 -0
  235. package/src/components/OrderPreviewContent.tsx +61 -0
  236. package/src/components/ParametersEditor.tsx +140 -0
  237. package/src/components/PcbViewerWithContainerHeight.tsx +47 -0
  238. package/src/components/PrefetchPageLink.tsx +45 -0
  239. package/src/components/PreviewContent.tsx +375 -0
  240. package/src/components/PreviewEmptyState.tsx +16 -0
  241. package/src/components/RunButton.tsx +27 -0
  242. package/src/components/SearchComponent.tsx +163 -0
  243. package/src/components/ShippingInformationForm.tsx +423 -0
  244. package/src/components/SnippetLink.tsx +37 -0
  245. package/src/components/StaticPreviewContent.tsx +89 -0
  246. package/src/components/StaticViewSnippetHeader.tsx +70 -0
  247. package/src/components/StaticViewSnippetSidebar.tsx +100 -0
  248. package/src/components/TableViewer/CircuitJsonTableViewer.tsx +316 -0
  249. package/src/components/TableViewer/ClickableText.tsx +21 -0
  250. package/src/components/TableViewer/HeaderCell.tsx +27 -0
  251. package/src/components/TableViewer/Modal.tsx +39 -0
  252. package/src/components/TrendingSnippetCarousel.tsx +77 -0
  253. package/src/components/TypeBadge.tsx +31 -0
  254. package/src/components/ViewSnippetHeader.tsx +144 -0
  255. package/src/components/ViewSnippetSidebar.tsx +162 -0
  256. package/src/components/dialogs/confirm-delete-snippet-dialog.tsx +80 -0
  257. package/src/components/dialogs/create-order-dialog.tsx +146 -0
  258. package/src/components/dialogs/create-use-dialog.tsx +34 -0
  259. package/src/components/dialogs/edit-description-dialog.tsx +96 -0
  260. package/src/components/dialogs/files-dialog.tsx +70 -0
  261. package/src/components/dialogs/import-snippet-dialog.tsx +84 -0
  262. package/src/components/dialogs/rename-snippet-dialog.tsx +81 -0
  263. package/src/components/dialogs/view-ts-files-dialog.tsx +89 -0
  264. package/src/components/ui/accordion.tsx +55 -0
  265. package/src/components/ui/alert-dialog.tsx +139 -0
  266. package/src/components/ui/alert.tsx +59 -0
  267. package/src/components/ui/aspect-ratio.tsx +5 -0
  268. package/src/components/ui/avatar.tsx +48 -0
  269. package/src/components/ui/badge.tsx +36 -0
  270. package/src/components/ui/breadcrumb.tsx +118 -0
  271. package/src/components/ui/button.tsx +58 -0
  272. package/src/components/ui/calendar.tsx +73 -0
  273. package/src/components/ui/card.tsx +76 -0
  274. package/src/components/ui/carousel.tsx +260 -0
  275. package/src/components/ui/chart.tsx +363 -0
  276. package/src/components/ui/checkbox.tsx +28 -0
  277. package/src/components/ui/collapsible.tsx +9 -0
  278. package/src/components/ui/combobox.tsx +178 -0
  279. package/src/components/ui/command.tsx +151 -0
  280. package/src/components/ui/context-menu.tsx +202 -0
  281. package/src/components/ui/dialog.tsx +120 -0
  282. package/src/components/ui/drawer.tsx +116 -0
  283. package/src/components/ui/dropdown-menu.tsx +203 -0
  284. package/src/components/ui/form.tsx +182 -0
  285. package/src/components/ui/hover-card.tsx +27 -0
  286. package/src/components/ui/input-otp.tsx +69 -0
  287. package/src/components/ui/input.tsx +25 -0
  288. package/src/components/ui/label.tsx +24 -0
  289. package/src/components/ui/menubar.tsx +238 -0
  290. package/src/components/ui/navigation-menu.tsx +129 -0
  291. package/src/components/ui/pagination.tsx +121 -0
  292. package/src/components/ui/popover.tsx +31 -0
  293. package/src/components/ui/progress.tsx +26 -0
  294. package/src/components/ui/radio-group.tsx +42 -0
  295. package/src/components/ui/resizable.tsx +43 -0
  296. package/src/components/ui/scroll-area.tsx +46 -0
  297. package/src/components/ui/searchable-select.tsx +94 -0
  298. package/src/components/ui/select.tsx +162 -0
  299. package/src/components/ui/separator.tsx +29 -0
  300. package/src/components/ui/sheet.tsx +141 -0
  301. package/src/components/ui/skeleton.tsx +18 -0
  302. package/src/components/ui/slider.tsx +26 -0
  303. package/src/components/ui/sonner.tsx +30 -0
  304. package/src/components/ui/switch.tsx +27 -0
  305. package/src/components/ui/table.tsx +120 -0
  306. package/src/components/ui/tabs.tsx +53 -0
  307. package/src/components/ui/textarea.tsx +24 -0
  308. package/src/components/ui/toast.tsx +128 -0
  309. package/src/components/ui/toaster.tsx +33 -0
  310. package/src/components/ui/toggle-group.tsx +59 -0
  311. package/src/components/ui/toggle.tsx +43 -0
  312. package/src/components/ui/tooltip.tsx +28 -0
  313. package/src/entry-server.tsx +12 -0
  314. package/src/hooks/use-account-balance.ts +24 -0
  315. package/src/hooks/use-ai-api.ts +35 -0
  316. package/src/hooks/use-axios.ts +20 -0
  317. package/src/hooks/use-code-completion-ai-api.ts +11 -0
  318. package/src/hooks/use-compiled-tsx.ts +37 -0
  319. package/src/hooks/use-copy-to-clipboard.ts +26 -0
  320. package/src/hooks/use-create-snippet-mutation.ts +62 -0
  321. package/src/hooks/use-current-snippet-id.ts +75 -0
  322. package/src/hooks/use-current-snippet.ts +24 -0
  323. package/src/hooks/use-global-store.ts +33 -0
  324. package/src/hooks/use-is-using-fake-api.ts +3 -0
  325. package/src/hooks/use-run-tsx/construct-circuit.tsx +64 -0
  326. package/src/hooks/use-run-tsx/eval-compiled-js.ts +9 -0
  327. package/src/hooks/use-run-tsx/index.tsx +251 -0
  328. package/src/hooks/use-save-snippet.ts +66 -0
  329. package/src/hooks/use-sign-in.ts +22 -0
  330. package/src/hooks/use-snippet-by-name.ts +25 -0
  331. package/src/hooks/use-snippet.ts +23 -0
  332. package/src/hooks/use-snippets-base-api-url.ts +3 -0
  333. package/src/hooks/use-toast.tsx +208 -0
  334. package/src/hooks/use-typecheck.ts +54 -0
  335. package/src/hooks/use-url-params.ts +31 -0
  336. package/src/hooks/use-warn-user-on-page-change.ts +23 -0
  337. package/src/hooks/useForkSnippetMutation.ts +52 -0
  338. package/src/index.css +21 -0
  339. package/src/lib/__tests__/constants.test.ts +66 -0
  340. package/src/lib/base64ToBytes.ts +5 -0
  341. package/src/lib/bytesToBase64.ts +4 -0
  342. package/src/lib/codemirror/basic-setup.ts +51 -0
  343. package/src/lib/constants.ts +12 -0
  344. package/src/lib/decodeUrlHashToText.ts +15 -0
  345. package/src/lib/defaultCodeForBlankCode.tsx +7 -0
  346. package/src/lib/download-fns/createBlobURL.ts +4 -0
  347. package/src/lib/download-fns/download-assembly-svg.ts +12 -0
  348. package/src/lib/download-fns/download-circuit-json-fn.ts +12 -0
  349. package/src/lib/download-fns/download-dsn-file-fn.ts +12 -0
  350. package/src/lib/download-fns/download-fabrication-files.ts +233 -0
  351. package/src/lib/download-fns/download-gltf.ts +49 -0
  352. package/src/lib/download-fns/download-kicad-files.ts +27 -0
  353. package/src/lib/download-fns/download-readable-netlist.ts +12 -0
  354. package/src/lib/download-fns/download-schematic-svg.ts +12 -0
  355. package/src/lib/download-fns/download-simple-route-json.ts +17 -0
  356. package/src/lib/encodeTextToUrlHash.ts +17 -0
  357. package/src/lib/get-snippet-template.ts +26 -0
  358. package/src/lib/handleManualEditsImport.tsx +65 -0
  359. package/src/lib/jlc-parts-engine.ts +69 -0
  360. package/src/lib/templates/blank-3d-model-template.ts +12 -0
  361. package/src/lib/templates/blank-circuit-board-template.ts +24 -0
  362. package/src/lib/templates/blank-footprint-template.ts +29 -0
  363. package/src/lib/templates/blank-package-template.ts +22 -0
  364. package/src/lib/templates/blinking-led-board-template.ts +63 -0
  365. package/src/lib/templates/manual-edits-template.ts +5 -0
  366. package/src/lib/templates/usb-c-led-flashlight-template.ts +22 -0
  367. package/src/lib/utils/checkIfManualEditsImported.ts +6 -0
  368. package/src/lib/utils/getSyntaxError.ts +13 -0
  369. package/src/lib/utils/index.ts +6 -0
  370. package/src/lib/utils/load-prettier.ts +18 -0
  371. package/src/lib/utils/parseFootprintParams.ts +52 -0
  372. package/src/lib/utils/parseJsonOrNull.ts +8 -0
  373. package/src/lib/utils/pcbManualEditEventHandler.ts +156 -0
  374. package/src/main.tsx +10 -0
  375. package/src/pages/ai.tsx +92 -0
  376. package/src/pages/authorize.tsx +54 -0
  377. package/src/pages/dashboard.tsx +165 -0
  378. package/src/pages/dev-login.tsx +68 -0
  379. package/src/pages/editor.tsx +28 -0
  380. package/src/pages/landing.tsx +236 -0
  381. package/src/pages/my-orders.tsx +54 -0
  382. package/src/pages/newest.tsx +16 -0
  383. package/src/pages/preview.tsx +70 -0
  384. package/src/pages/quickstart.tsx +198 -0
  385. package/src/pages/search.tsx +26 -0
  386. package/src/pages/settings.tsx +25 -0
  387. package/src/pages/user-profile.tsx +97 -0
  388. package/src/pages/view-order.tsx +123 -0
  389. package/src/pages/view-snippet.tsx +149 -0
  390. package/src/prettier.ts +9 -0
  391. package/src/vite-env.d.ts +1 -0
  392. package/tailwind.config.js +47 -0
  393. package/tsconfig.json +30 -0
  394. package/vercel.json +50 -0
  395. package/vite.config.ts +146 -0
  396. package/winterspec.config.ts +6 -0
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Some relevant code from another project
3
+ import { AppContext } from "../util/app-context"
4
+ import { z } from "zod"
5
+ import * as Path from "path"
6
+ import { unlink } from "node:fs/promises"
7
+ import * as fs from "fs"
8
+ import {
9
+ stringifyGerberCommandLayers,
10
+ convertSoupToGerberCommands,
11
+ convertSoupToExcellonDrillCommands,
12
+ stringifyExcellonDrill,
13
+ } from "circuit-json-to-gerber"
14
+ import kleur from "kleur"
15
+ import archiver from "archiver"
16
+ import { AnyCircuitElement } from "circuit-json"
17
+
18
+ export const exportGerbersToFile = async (
19
+ params: {
20
+ circuitJson: AnyCircuitElement[]
21
+ example_file_path: string
22
+ export_name?: string
23
+ output_zip_path: string
24
+ },
25
+ ctx: AppContext,
26
+ ) => {
27
+ console.log(kleur.gray("[soupifying]..."))
28
+
29
+ console.log(kleur.gray("[soup to gerber json]..."))
30
+ const gerber_layer_cmds = convertSoupToGerberCommands(circuitJson, {
31
+ flip_y_axis: false,
32
+ })
33
+
34
+ console.log(kleur.gray("[soup to drl json]..."))
35
+ const drill_cmds = convertSoupToExcellonDrillCommands({
36
+ soup: circuitJson,
37
+ is_plated: true,
38
+ flip_y_axis: false,
39
+ })
40
+
41
+ console.log(kleur.gray("[stringify gerber json]..."))
42
+ const gerber_file_contents = stringifyGerberCommandLayers(gerber_layer_cmds)
43
+ console.log(kleur.gray("[stringify drl json]..."))
44
+ const drill_file_contents = {
45
+ plated: stringifyExcellonDrill(drill_cmds),
46
+ }
47
+
48
+ console.log(kleur.gray("[writing gerbers to tmp dir]..."))
49
+ const tempDir = Path.join(".tscircuit", "tmp-gerber-export")
50
+ fs.rmSync(tempDir, { recursive: true, force: true })
51
+ fs.mkdirSync(tempDir, { recursive: true })
52
+ for (const [fileName, fileContents] of Object.entries(gerber_file_contents)) {
53
+ const filePath = Path.join(tempDir, fileName)
54
+ await fs.writeFileSync(`${filePath}.gbr`, fileContents)
55
+ }
56
+ for (const [fileName, fileContents] of Object.entries(drill_file_contents)) {
57
+ const filePath = Path.join(tempDir, fileName)
58
+ await fs.writeFileSync(`${filePath}.drl`, fileContents)
59
+ }
60
+
61
+ console.log(kleur.gray("[zipping tmp dir]..."))
62
+ console.log(kleur.gray(" writing to " + params.output_zip_path))
63
+ const output = fs.createWriteStream(params.output_zip_path)
64
+
65
+ const archive = archiver("zip", {
66
+ zlib: { level: 9 },
67
+ })
68
+
69
+ archive.pipe(output)
70
+ archive.directory(tempDir, false)
71
+
72
+ await new Promise((resolve, reject) => {
73
+ output.on("close", resolve)
74
+ output.on("finish", resolve)
75
+ output.on("end", resolve)
76
+ output.on("error", reject)
77
+ archive.finalize()
78
+ })
79
+ }
80
+
81
+ export const exportGerbersToZipBuffer = async (
82
+ params: {
83
+ example_file_path: string
84
+ export_name?: string
85
+ },
86
+ ctx: AppContext,
87
+ ) => {
88
+ const tempDir = Path.join(".tscircuit", "tmp-gerber-zip")
89
+ fs.mkdirSync(tempDir, { recursive: true })
90
+
91
+ await exportGerbersToFile(
92
+ {
93
+ example_file_path: params.example_file_path,
94
+ export_name: params.export_name,
95
+ output_zip_path: Path.join(tempDir, "gerbers.zip"),
96
+ },
97
+ ctx,
98
+ )
99
+
100
+ const buffer = fs.readFileSync(Path.join(tempDir, "gerbers.zip"))
101
+
102
+ fs.rmSync(tempDir, { recursive: true })
103
+
104
+ return buffer
105
+ }
106
+
107
+
108
+ import { AppContext } from "../util/app-context"
109
+ import { soupify } from "cli/lib/soupify"
110
+ import kleur from "kleur"
111
+ import {
112
+ convertCircuitJsonToBomRows,
113
+ convertBomRowsToCsv,
114
+ } from "circuit-json-to-bom-csv"
115
+
116
+ export const exportBomCsvToBuffer = async (
117
+ params: {
118
+ example_file_path: string
119
+ export_name?: string
120
+ },
121
+ ctx: AppContext,
122
+ ) => {
123
+ console.log(kleur.gray("[soupifying]..."))
124
+ const circuitJson = await circuitJsonify(
125
+ {
126
+ filePath: params.example_file_path,
127
+ exportName: params.export_name,
128
+ },
129
+ ctx,
130
+ )
131
+
132
+ console.log(kleur.gray("[circuitJson to bom rows]..."))
133
+ const bom_rows = await convertCircuitJsonToBomRows({ circuitJson: circuitJson })
134
+
135
+ console.log(kleur.gray("[bom rows to csv]..."))
136
+ const bom_csv = await convertBomRowsToCsv(bom_rows)
137
+
138
+ return Buffer.from(bom_csv, "utf-8")
139
+ }
140
+
141
+
142
+ import { AppContext } from "../util/app-context"
143
+ import { z } from "zod"
144
+ import * as Path from "path"
145
+ import { unlink } from "node:fs/promises"
146
+ import { soupify } from "cli/lib/soupify"
147
+ import { convertCircuitJsonToPickAndPlaceCsv } from "circuit-json-to-pnp-csv"
148
+ import * as fs from "fs"
149
+ import kleur from "kleur"
150
+ import archiver from "archiver"
151
+
152
+ export const exportPnpCsvToBuffer = async (
153
+ params: {
154
+ example_file_path: string
155
+ export_name?: string
156
+ },
157
+ ctx: AppContext,
158
+ ) => {
159
+ console.log(kleur.gray("[soupifying]..."))
160
+ const circuitJson = await soupify(
161
+ {
162
+ filePath: params.example_file_path,
163
+ exportName: params.export_name,
164
+ },
165
+ ctx,
166
+ )
167
+
168
+ console.log(kleur.gray("[circuitJson to pnp csv string]..."))
169
+ const pnp_csv = await convertCircuitJsonToPickAndPlaceCsv(circuitJson)
170
+
171
+ return Buffer.from(pnp_csv, "utf-8")
172
+ }
173
+
174
+
175
+
176
+ */
177
+
178
+ import { AnyCircuitElement } from "circuit-json"
179
+ import { saveAs } from "file-saver"
180
+ import JSZip from "jszip"
181
+ import {
182
+ stringifyGerberCommandLayers,
183
+ convertSoupToGerberCommands,
184
+ convertSoupToExcellonDrillCommands,
185
+ stringifyExcellonDrill,
186
+ } from "circuit-json-to-gerber"
187
+ import {
188
+ convertCircuitJsonToBomRows,
189
+ convertBomRowsToCsv,
190
+ } from "circuit-json-to-bom-csv"
191
+ import { convertCircuitJsonToPickAndPlaceCsv } from "circuit-json-to-pnp-csv"
192
+
193
+ export const downloadFabricationFiles = async ({
194
+ circuitJson,
195
+ snippetUnscopedName,
196
+ }: {
197
+ circuitJson: AnyCircuitElement[]
198
+ snippetUnscopedName: string
199
+ }) => {
200
+ const zip = new JSZip()
201
+
202
+ // Generate Gerber files
203
+ const gerberLayerCmds = convertSoupToGerberCommands(circuitJson, {
204
+ flip_y_axis: false,
205
+ })
206
+ const gerberFileContents = stringifyGerberCommandLayers(gerberLayerCmds)
207
+
208
+ for (const [fileName, fileContents] of Object.entries(gerberFileContents)) {
209
+ zip.file(`gerber/${fileName}.gbr`, fileContents)
210
+ }
211
+
212
+ // Generate Drill files
213
+ const drillCmds = convertSoupToExcellonDrillCommands({
214
+ circuitJson,
215
+ is_plated: true,
216
+ flip_y_axis: false,
217
+ })
218
+ const drillFileContents = stringifyExcellonDrill(drillCmds)
219
+ zip.file("gerber/drill.drl", drillFileContents)
220
+
221
+ // Generate BOM CSV
222
+ const bomRows = await convertCircuitJsonToBomRows({ circuitJson })
223
+ const bomCsv = await convertBomRowsToCsv(bomRows)
224
+ zip.file("bom.csv", bomCsv)
225
+
226
+ // Generate Pick and Place CSV
227
+ const pnpCsv = await convertCircuitJsonToPickAndPlaceCsv(circuitJson)
228
+ zip.file("pick_and_place.csv", pnpCsv)
229
+
230
+ // Generate and download the zip file
231
+ const zipBlob = await zip.generateAsync({ type: "blob" })
232
+ saveAs(zipBlob, `${snippetUnscopedName}_fabrication_files.zip`)
233
+ }
@@ -0,0 +1,49 @@
1
+ import { AnyCircuitElement } from "circuit-json"
2
+ import { convertCircuitJsonToAssemblySvg } from "circuit-to-svg"
3
+ import { GLTFExporter, type GLTFExporterOptions } from "three-stdlib"
4
+ import { saveAs } from "file-saver"
5
+ import * as THREE from "three"
6
+
7
+ export const downloadGltf = async (
8
+ circuitJson: AnyCircuitElement[],
9
+ fileName: string,
10
+ ) => {
11
+ const threeJsObject = window.TSCIRCUIT_3D_OBJECT_REF
12
+ ?.current as THREE.Object3D
13
+
14
+ if (!threeJsObject) {
15
+ throw new Error(
16
+ "No 3D object found, run the snippet before downloading the 3d model",
17
+ )
18
+ }
19
+
20
+ const exporter = new GLTFExporter()
21
+
22
+ const options: GLTFExporterOptions = {
23
+ binary: true,
24
+ }
25
+
26
+ const {
27
+ promise: gltfPromise,
28
+ resolve: resolveGltf,
29
+ reject: rejectGltf,
30
+ } = Promise.withResolvers<Blob>()
31
+
32
+ exporter.parse(
33
+ threeJsObject,
34
+ (gltf) => {
35
+ const type = options.binary ? "gltf-binary" : "gltf+json"
36
+ const blob = new Blob(
37
+ [gltf instanceof ArrayBuffer ? gltf : JSON.stringify(gltf)],
38
+ { type: `model/${type}` },
39
+ )
40
+ resolveGltf(blob)
41
+ },
42
+ rejectGltf,
43
+ options,
44
+ )
45
+
46
+ const gltfBlob = await gltfPromise
47
+
48
+ saveAs(gltfBlob, fileName + ".gltf")
49
+ }
@@ -0,0 +1,27 @@
1
+ import { saveAs } from "file-saver"
2
+ import { convertCircuitJsonToKiCadPcb } from "kicad-converter"
3
+ import { convertCircuitJsonToKicadPro } from "kicad-converter"
4
+ import { AnyCircuitElement } from "circuit-json"
5
+ import JSZip from "jszip"
6
+
7
+ export const downloadKicadFiles = (
8
+ circuitJson: AnyCircuitElement[],
9
+ fileName: string,
10
+ ) => {
11
+ const kicadPcbString = convertCircuitJsonToKiCadPcb(circuitJson)
12
+ const pcbContent =
13
+ typeof kicadPcbString === "object"
14
+ ? JSON.stringify(kicadPcbString)
15
+ : kicadPcbString
16
+
17
+ const kicadProContent = convertCircuitJsonToKicadPro(circuitJson)
18
+ const proContent = JSON.stringify(kicadProContent)
19
+
20
+ const zip = new JSZip()
21
+ zip.file(`${fileName}.kicad_pcb`, pcbContent)
22
+ zip.file(`${fileName}.kicad_pro`, proContent)
23
+
24
+ zip.generateAsync({ type: "blob" }).then((content) => {
25
+ saveAs(content, `${fileName}_kicad.zip`)
26
+ })
27
+ }
@@ -0,0 +1,12 @@
1
+ import { AnyCircuitElement } from "circuit-json"
2
+ import { saveAs } from "file-saver"
3
+ import { convertCircuitJsonToReadableNetlist } from "circuit-json-to-readable-netlist"
4
+
5
+ export const downloadReadableNetlist = (
6
+ circuitJson: AnyCircuitElement[],
7
+ fileName: string,
8
+ ) => {
9
+ const readableNetlistString = convertCircuitJsonToReadableNetlist(circuitJson)
10
+ const blob = new Blob([readableNetlistString], { type: "text/plain" })
11
+ saveAs(blob, fileName + ".txt")
12
+ }
@@ -0,0 +1,12 @@
1
+ import { AnyCircuitElement } from "circuit-json"
2
+ import { convertCircuitJsonToSchematicSvg } from "circuit-to-svg"
3
+ import { saveAs } from "file-saver"
4
+
5
+ export const downloadSchematicSvg = (
6
+ circuitJson: AnyCircuitElement[],
7
+ fileName: string,
8
+ ) => {
9
+ const svg = convertCircuitJsonToSchematicSvg(circuitJson)
10
+ const blob = new Blob([svg], { type: "image/svg" })
11
+ saveAs(blob, fileName + ".svg")
12
+ }
@@ -0,0 +1,17 @@
1
+ import { AnyCircuitElement } from "circuit-json"
2
+ import { getSimpleRouteJsonFromCircuitJson } from "@tscircuit/core"
3
+ import { saveAs } from "file-saver"
4
+
5
+ export const downloadSimpleRouteJson = (
6
+ circuitJson: AnyCircuitElement[],
7
+ fileName: string,
8
+ ) => {
9
+ const simpleRouteJson = getSimpleRouteJsonFromCircuitJson({
10
+ circuitJson: circuitJson as any,
11
+ minTraceWidth: 0.1,
12
+ })
13
+ const blob = new Blob([JSON.stringify(simpleRouteJson, null, 2)], {
14
+ type: "application/json",
15
+ })
16
+ saveAs(blob, fileName + "_routes.json")
17
+ }
@@ -0,0 +1,17 @@
1
+ import { gzipSync, strToU8 } from "fflate"
2
+ import { bytesToBase64 } from "./bytesToBase64"
3
+
4
+ export function encodeTextToUrlHash(
5
+ text: string,
6
+ snippet_type?: string,
7
+ ): string {
8
+ // Compress the input string
9
+ const compressedData = gzipSync(strToU8(text))
10
+
11
+ // Convert to base64
12
+ const base64Data = bytesToBase64(compressedData)
13
+
14
+ // Construct the URL
15
+ const typeParam = snippet_type ? `&snippet_type=${snippet_type}` : ""
16
+ return `${window.location.origin}/editor?${typeParam}#data:application/gzip;base64,${base64Data}`
17
+ }
@@ -0,0 +1,26 @@
1
+ import { blankPackageTemplate } from "@/lib/templates/blank-package-template"
2
+ import { blankFootprintTemplate } from "@/lib/templates/blank-footprint-template"
3
+ import { blankCircuitBoardTemplate } from "@/lib/templates/blank-circuit-board-template"
4
+ import { blank3dModelTemplate } from "@/lib/templates/blank-3d-model-template"
5
+ import { defaultCodeForBlankPage } from "@/lib/defaultCodeForBlankCode"
6
+ import { blinkingLedBoardTemplate } from "@/lib/templates/blinking-led-board-template"
7
+ import { usbCLedFlashlightTemplate } from "@/lib/templates/usb-c-led-flashlight-template"
8
+
9
+ export const getSnippetTemplate = (template: string | undefined) => {
10
+ switch (template) {
11
+ case "blank-circuit-module":
12
+ return blankPackageTemplate
13
+ case "blank-footprint":
14
+ return blankFootprintTemplate
15
+ case "blank-circuit-board":
16
+ return blankCircuitBoardTemplate
17
+ case "blank-3d-model":
18
+ return blank3dModelTemplate
19
+ case "blinking-led-board":
20
+ return blinkingLedBoardTemplate
21
+ case "usb-c-led-flashlight":
22
+ return usbCLedFlashlightTemplate
23
+ default:
24
+ return { code: defaultCodeForBlankPage, type: "board" }
25
+ }
26
+ }
@@ -0,0 +1,65 @@
1
+ import { FileName } from "@/components/CodeEditorHeader"
2
+
3
+ export const handleManualEditsImport = (
4
+ files: Record<string, string>,
5
+ updateFileContent: (filename: FileName, content: string) => void,
6
+ toast: (options: {
7
+ title: string
8
+ description: string
9
+ variant?: "default" | "destructive"
10
+ }) => void,
11
+ ) => {
12
+ try {
13
+ let currentContent = files["index.tsx"]
14
+ const importRegex =
15
+ /import\s+(?:\*\s+as\s+)?([a-zA-Z_$][\w$]*)\s+from\s+["']\.\/manual-edits\.json["'];?/
16
+ const match = importRegex.exec(currentContent)
17
+ const importVariableName = match ? match[1] : "manualEdits"
18
+
19
+ if (!match) {
20
+ currentContent = `import ${importVariableName} from "./manual-edits.json";\n${currentContent}`
21
+ }
22
+
23
+ const boardRegex = /<board\b[^>]*>/gi
24
+ const groupSubcircuitRegex = /<group\b[^>]*\bsubcircuit\b[^>]*>/gi
25
+
26
+ let modifiedContent = currentContent.replace(boardRegex, (match) =>
27
+ match.includes(`manualEdits={${importVariableName}}`)
28
+ ? match
29
+ : match.replace(">", ` manualEdits={${importVariableName}}>`),
30
+ )
31
+
32
+ modifiedContent = modifiedContent.replace(groupSubcircuitRegex, (match) =>
33
+ match.includes(`manualEdits={${importVariableName}}`)
34
+ ? match
35
+ : match.replace(">", ` manualEdits={${importVariableName}}>`),
36
+ )
37
+
38
+ if (modifiedContent === currentContent) {
39
+ toast({
40
+ title: "No Manual Edits Applied",
41
+ description:
42
+ "No applicable <board> or <group subcircuit> tags were found to apply manual edits.",
43
+ variant: "destructive",
44
+ })
45
+ return
46
+ }
47
+
48
+ updateFileContent("index.tsx", modifiedContent)
49
+
50
+ toast({
51
+ title: "Manual Edits Imported",
52
+ description: "Successfully imported and applied manual edits.",
53
+ variant: "default",
54
+ })
55
+ } catch (error) {
56
+ toast({
57
+ title: "Import Error",
58
+ description:
59
+ error instanceof Error
60
+ ? error.message
61
+ : "Failed to import manual edits. Please check the file and apply manually.",
62
+ variant: "destructive",
63
+ })
64
+ }
65
+ }
@@ -0,0 +1,69 @@
1
+ import { type PartsEngine, SupplierPartNumbers } from "@tscircuit/props"
2
+ import { AnySourceComponent } from "circuit-json"
3
+ import qs from "qs"
4
+
5
+ const cache = new Map<string, any>()
6
+ const getJlcPartsCached = async (name: any, params: any) => {
7
+ const paramString = qs.stringify({ ...params, json: "true" })
8
+ if (cache.has(paramString)) {
9
+ return cache.get(paramString)
10
+ }
11
+ const response = await fetch(
12
+ `https://jlcsearch.tscircuit.com/${name}/list?${paramString}`,
13
+ )
14
+ const responseJson = await response.json()
15
+ cache.set(paramString, responseJson)
16
+ return responseJson
17
+ }
18
+
19
+ export const jlcPartsEngine: PartsEngine = {
20
+ findPart: async ({
21
+ sourceComponent,
22
+ footprinterString,
23
+ }): Promise<SupplierPartNumbers> => {
24
+ if (sourceComponent.ftype === "simple_resistor") {
25
+ const { resistors } = await getJlcPartsCached("resistors", {
26
+ resistance: sourceComponent.resistance,
27
+ package: footprinterString,
28
+ })
29
+
30
+ return {
31
+ jlcpcb: resistors.map((r: any) => `C${r.lcsc}`).slice(0, 3),
32
+ }
33
+ } else if (sourceComponent.ftype === "simple_capacitor") {
34
+ if (footprinterString?.includes("cap")) {
35
+ footprinterString = footprinterString.replace("cap", "")
36
+ }
37
+ const { capacitors } = await getJlcPartsCached("capacitors", {
38
+ capacitance: sourceComponent.capacitance,
39
+ package: footprinterString,
40
+ })
41
+
42
+ return {
43
+ jlcpcb: capacitors.map((c: any) => `C${c.lcsc}`).slice(0, 3),
44
+ }
45
+ } else if (sourceComponent.ftype === "simple_pin_header") {
46
+ let pitch
47
+ if (footprinterString?.includes("_p")) {
48
+ pitch = footprinterString.split("_p")[1]
49
+ }
50
+ const { headers } = await getJlcPartsCached(
51
+ "headers",
52
+ pitch
53
+ ? {
54
+ pitch: pitch,
55
+ num_pins: sourceComponent.pin_count,
56
+ gender: sourceComponent.gender,
57
+ }
58
+ : {
59
+ num_pins: sourceComponent.pin_count,
60
+ gender: sourceComponent.gender,
61
+ },
62
+ )
63
+ return {
64
+ jlcpcb: headers.map((h: any) => `C${h.lcsc}`).slice(0, 3),
65
+ }
66
+ }
67
+ return {}
68
+ },
69
+ }
@@ -0,0 +1,12 @@
1
+ export const blank3dModelTemplate = {
2
+ type: "model",
3
+ code: `
4
+ // Note: Eventually this should have a <jscad> wrapper
5
+ export const MyModel = (props: any) => (
6
+ <>
7
+ {/* <cuboid size={[5, 10, 5]} /> */}
8
+ <cube size={1} />
9
+ </>
10
+ )
11
+ `.trim(),
12
+ }
@@ -0,0 +1,24 @@
1
+ export const blankCircuitBoardTemplate = {
2
+ type: "board",
3
+ code: `
4
+ export default () => (
5
+ <board width="10mm" height="10mm">
6
+ <resistor
7
+ resistance="1k"
8
+ footprint="0402"
9
+ name="R1"
10
+ schX={3}
11
+ pcbX={3}
12
+ />
13
+ <capacitor
14
+ capacitance="1000pF"
15
+ footprint="0402"
16
+ name="C1"
17
+ schX={-3}
18
+ pcbX={-3}
19
+ />
20
+ <trace from=".R1 > .pin1" to=".C1 > .pin1" />
21
+ </board>
22
+ )
23
+ `.trim(),
24
+ }
@@ -0,0 +1,29 @@
1
+ export const blankFootprintTemplate = {
2
+ type: "footprint",
3
+ code: `
4
+ export const MyFootprint = (props: any) => (
5
+ <footprint>
6
+ <smtpad
7
+ shape="rect"
8
+ width="0.5mm"
9
+ height="0.5mm"
10
+ schX={-1}
11
+ schY={0}
12
+ pcbX={-1}
13
+ pcbY={0}
14
+ portHints={["1"]}
15
+ />
16
+ <smtpad
17
+ shape="rect"
18
+ width="0.5mm"
19
+ height="0.5mm"
20
+ schX={1}
21
+ schY={0}
22
+ pcbX={1}
23
+ pcbY={0}
24
+ portHints={["2"]}
25
+ />
26
+ </footprint>
27
+ )
28
+ `.trim(),
29
+ }
@@ -0,0 +1,22 @@
1
+ export const blankPackageTemplate = {
2
+ type: "package",
3
+ code: `
4
+ import { createUseComponent } from "@tscircuit/core"
5
+
6
+ export const MyChip = (props: { name: string }) => (
7
+ <chip {...props} pinLabels={pinLabels} footprint="soic8" />
8
+ )
9
+ const pinLabels = {
10
+ pin1: [],
11
+ pin2: [],
12
+ pin3: [],
13
+ pin4: [],
14
+ pin5: [],
15
+ pin6: [],
16
+ pin7: [],
17
+ pin8: [],
18
+ } as const
19
+
20
+ export const useMyChip = createUseComponent(MyChip, pinLabels)
21
+ `.trim(),
22
+ }
@@ -0,0 +1,63 @@
1
+ export const blinkingLedBoardTemplate = {
2
+ type: "board",
3
+ code: `
4
+ import { useUsbC } from "@tsci/seveibar.smd-usb-c"
5
+ import { useRedLed } from "@tsci/seveibar.red-led"
6
+ import { A555Timer } from "@tsci/seveibar.a555timer"
7
+
8
+ export const MyBlinkingLedCircuit = () => {
9
+ const USBC = useUsbC("USBC")
10
+ const Led = useRedLed("LED")
11
+
12
+ return (
13
+ <board width="30mm" height="30mm" schAutoLayoutEnabled>
14
+ <USBC GND1="net.GND" VBUS1="net.VBUS" pcbX={-10} pcbY={-10} />
15
+ <A555Timer
16
+ name="B1"
17
+ pin8="net.VBUS"
18
+ pin1="net.GND"
19
+ pin3="net.OUT"
20
+ pin2="net.TRIG"
21
+ pin6="net.THRES"
22
+ pin7="net.DIS"
23
+ />
24
+ <resistor name="R1" resistance="1K" footprint="0805" pcbX={-8} pcbY={8} />
25
+ <resistor
26
+ name="R2"
27
+ resistance="470K"
28
+ footprint="0805"
29
+ pcbX={0}
30
+ pcbY={-8}
31
+ />
32
+ <resistor
33
+ name="R3"
34
+ resistance="1k"
35
+ footprint="0805"
36
+ pcbX={2.5}
37
+ pcbY={8}
38
+ />
39
+
40
+ <capacitor
41
+ name="C1"
42
+ capacitance="1uF"
43
+ footprint="0805"
44
+ pcbX={-2.5}
45
+ pcbY={8}
46
+ />
47
+
48
+ <Led pos="net.OUT" neg="net.GND" pcbX={5} pcbY={10} />
49
+
50
+ <trace from=".USBC > .VBUS1" to=".R1 > .left" />
51
+ <trace from=".R1 > .right" to=".R2 > .left" />
52
+ <trace from=".R2 > .right" to=".C1 > .left" />
53
+ <trace from=".C1 > .right" to=".USBC > .GND1" />
54
+ <trace from=".B1 > .pin7" to=".R1 > .right" />
55
+ <trace from=".B1 > .pin6" to=".R2 > .right" />
56
+ <trace from=".B1 > .pin2" to=".R2 > .right" />
57
+ <trace from=".B1 > .pin3" to=".R3 > .left" />
58
+ <trace from=".R3 > .right" to=".LED > .pos" />
59
+ </board>
60
+ )
61
+ }
62
+ `.trim(),
63
+ }