@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.
- package/.github/CODEOWNERS +1 -0
- package/.github/workflows/bun-formatcheck.yml +26 -0
- package/.github/workflows/bun-test.yml +28 -0
- package/.github/workflows/bun-typecheck.yml +26 -0
- package/.github/workflows/bundle-size-analysis.yml +79 -0
- package/.github/workflows/playwright-test.yml +37 -0
- package/.github/workflows/stale.yml +40 -0
- package/.github/workflows/update-snapshots.yml +49 -0
- package/CONTRIBUTING.md +59 -0
- package/LICENSE +21 -0
- package/README.md +113 -0
- package/biome.json +60 -0
- package/bun-tests/fake-snippets-api/fixtures/get-circuit-json.ts +148 -0
- package/bun-tests/fake-snippets-api/fixtures/get-test-server.ts +96 -0
- package/bun-tests/fake-snippets-api/fixtures/start-server.ts +44 -0
- package/bun-tests/fake-snippets-api/routes/accounts/get_account_balance.test.ts +18 -0
- package/bun-tests/fake-snippets-api/routes/health.test.ts +9 -0
- package/bun-tests/fake-snippets-api/routes/order_files/get.test.ts +48 -0
- package/bun-tests/fake-snippets-api/routes/order_files/upload.test.ts +77 -0
- package/bun-tests/fake-snippets-api/routes/orders/create.test.ts +19 -0
- package/bun-tests/fake-snippets-api/routes/orders/get.test.ts +38 -0
- package/bun-tests/fake-snippets-api/routes/orders/list.test.ts +30 -0
- package/bun-tests/fake-snippets-api/routes/orders/update.test.ts +46 -0
- package/bun-tests/fake-snippets-api/routes/snippets/add_star.test.ts +114 -0
- package/bun-tests/fake-snippets-api/routes/snippets/create.test.ts +28 -0
- package/bun-tests/fake-snippets-api/routes/snippets/delete.test.ts +106 -0
- package/bun-tests/fake-snippets-api/routes/snippets/download.test.ts +90 -0
- package/bun-tests/fake-snippets-api/routes/snippets/generate_from_jlcpcb.test.ts +25 -0
- package/bun-tests/fake-snippets-api/routes/snippets/get_image.test.ts +113 -0
- package/bun-tests/fake-snippets-api/routes/snippets/images.test.ts +112 -0
- package/bun-tests/fake-snippets-api/routes/snippets/list.test.ts +62 -0
- package/bun-tests/fake-snippets-api/routes/snippets/list_newest.test.ts +48 -0
- package/bun-tests/fake-snippets-api/routes/snippets/list_trending.test.ts +69 -0
- package/bun-tests/fake-snippets-api/routes/snippets/remove_star.test.ts +110 -0
- package/bun-tests/fake-snippets-api/routes/snippets/search.test.ts +75 -0
- package/bun-tests/fake-snippets-api/routes/snippets/star-count.test.ts +44 -0
- package/bun-tests/fake-snippets-api/routes/snippets/update.test.ts +116 -0
- package/bun-tests/parts-engine.test.ts +18 -0
- package/bun.lockb +0 -0
- package/bunfig.toml +2 -0
- package/components.json +20 -0
- package/dist/assets/editor_example_1-1000w.webp +0 -0
- package/dist/assets/editor_example_1-1200w.webp +0 -0
- package/dist/assets/editor_example_1-1600w.webp +0 -0
- package/dist/assets/editor_example_1-2000w.webp +0 -0
- package/dist/assets/editor_example_1-400w.webp +0 -0
- package/dist/assets/editor_example_1-600w.webp +0 -0
- package/dist/assets/editor_example_1-800w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1000w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1200w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1600w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-2000w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-400w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-600w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-800w.webp +0 -0
- package/dist/assets/editor_example_2-1000w.webp +0 -0
- package/dist/assets/editor_example_2-1200w.webp +0 -0
- package/dist/assets/editor_example_2-1600w.webp +0 -0
- package/dist/assets/editor_example_2-2000w.webp +0 -0
- package/dist/assets/editor_example_2-400w.webp +0 -0
- package/dist/assets/editor_example_2-600w.webp +0 -0
- package/dist/assets/editor_example_2-800w.webp +0 -0
- package/dist/assets/example_schematic-1000w.webp +0 -0
- package/dist/assets/example_schematic-1200w.webp +0 -0
- package/dist/assets/example_schematic-1600w.webp +0 -0
- package/dist/assets/example_schematic-2000w.webp +0 -0
- package/dist/assets/example_schematic-400w.webp +0 -0
- package/dist/assets/example_schematic-600w.webp +0 -0
- package/dist/assets/example_schematic-800w.webp +0 -0
- package/dist/bundle.js +3270 -0
- package/dist/robots.txt +9 -0
- package/dist/sitemap.xml +118 -0
- package/docs/CIRCUIT_JSON_SOURCE_COMPONENT_OVERVIEW.md +151 -0
- package/fake-snippets-api/README.md +6 -0
- package/fake-snippets-api/biome.json +47 -0
- package/fake-snippets-api/bun.lockb +0 -0
- package/fake-snippets-api/lib/db/autoload-dev-snippets.ts +84 -0
- package/fake-snippets-api/lib/db/autoload-snippets.json +24 -0
- package/fake-snippets-api/lib/db/db-client.ts +343 -0
- package/fake-snippets-api/lib/db/schema.ts +112 -0
- package/fake-snippets-api/lib/db/seed.ts +1608 -0
- package/fake-snippets-api/lib/middleware/with-ctx-error.ts +26 -0
- package/fake-snippets-api/lib/middleware/with-db.ts +15 -0
- package/fake-snippets-api/lib/middleware/with-error-handling.ts +24 -0
- package/fake-snippets-api/lib/middleware/with-optional-session-auth.ts +34 -0
- package/fake-snippets-api/lib/middleware/with-request-logging.ts +54 -0
- package/fake-snippets-api/lib/middleware/with-session-auth.ts +39 -0
- package/fake-snippets-api/lib/middleware/with-winter-spec.ts +24 -0
- package/fake-snippets-api/next-env.d.ts +5 -0
- package/fake-snippets-api/routes/api/accounts/get.ts +21 -0
- package/fake-snippets-api/routes/api/accounts/get_account_balance.ts +22 -0
- package/fake-snippets-api/routes/api/accounts/update.ts +32 -0
- package/fake-snippets-api/routes/api/ai/[...anyroute].ts +31 -0
- package/fake-snippets-api/routes/api/ai.ts +2 -0
- package/fake-snippets-api/routes/api/aistream/[...anyroute].ts +65 -0
- package/fake-snippets-api/routes/api/health.ts +9 -0
- package/fake-snippets-api/routes/api/internal/sessions/create_without_auth.ts +63 -0
- package/fake-snippets-api/routes/api/order_files/get.ts +28 -0
- package/fake-snippets-api/routes/api/order_files/upload.ts +43 -0
- package/fake-snippets-api/routes/api/orders/create.ts +41 -0
- package/fake-snippets-api/routes/api/orders/get.ts +28 -0
- package/fake-snippets-api/routes/api/orders/list.ts +15 -0
- package/fake-snippets-api/routes/api/orders/update.ts +50 -0
- package/fake-snippets-api/routes/api/snippets/add_star.ts +42 -0
- package/fake-snippets-api/routes/api/snippets/create.ts +55 -0
- package/fake-snippets-api/routes/api/snippets/delete.ts +41 -0
- package/fake-snippets-api/routes/api/snippets/download.ts +148 -0
- package/fake-snippets-api/routes/api/snippets/generate_from_jlcpcb.ts +55 -0
- package/fake-snippets-api/routes/api/snippets/get.ts +50 -0
- package/fake-snippets-api/routes/api/snippets/get_image.ts +65 -0
- package/fake-snippets-api/routes/api/snippets/images/[author]/[snippet_name]/[typeFormat].ts +74 -0
- package/fake-snippets-api/routes/api/snippets/list.ts +28 -0
- package/fake-snippets-api/routes/api/snippets/list_newest.ts +13 -0
- package/fake-snippets-api/routes/api/snippets/list_trending.ts +21 -0
- package/fake-snippets-api/routes/api/snippets/remove_star.ts +42 -0
- package/fake-snippets-api/routes/api/snippets/search.ts +18 -0
- package/fake-snippets-api/routes/api/snippets/update.ts +86 -0
- package/favicon.ico +0 -0
- package/index.html +23 -0
- package/landing.html +23 -0
- package/package.json +164 -0
- package/playwright-tests/ai-page.spec.ts +19 -0
- package/playwright-tests/cmd-click.spec.ts +43 -0
- package/playwright-tests/dashboard-page.spec.ts +10 -0
- package/playwright-tests/editor-page.spec.ts +15 -0
- package/playwright-tests/files-dialog.spec.ts +19 -0
- package/playwright-tests/footprint-dialog/footprint-dialog.spec.ts +27 -0
- package/playwright-tests/footprint-dialog/footprint-insertion.spec.ts +38 -0
- package/playwright-tests/footprint-dialog/footprint-preview.spec.ts +34 -0
- package/playwright-tests/footprint-dialog/footprint-selection.spec.ts +29 -0
- package/playwright-tests/handle-manual-edits.spec.ts +55 -0
- package/playwright-tests/home-page.spec.ts +10 -0
- package/playwright-tests/images.spec.ts +17 -0
- package/playwright-tests/manual-edits.spec.ts +89 -0
- package/playwright-tests/preview-page.spec.ts +14 -0
- package/playwright-tests/quickstart-page.spec.ts +10 -0
- package/playwright-tests/search-links.spec.ts +21 -0
- package/playwright-tests/search.spec.ts +27 -0
- package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-lg.png +0 -0
- package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-md.png +0 -0
- package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-xs.png +0 -0
- package/playwright-tests/snapshots/cmd-click.spec.ts-underlined-imports.png +0 -0
- package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-lg.png +0 -0
- package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-md.png +0 -0
- package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-xs.png +0 -0
- package/playwright-tests/snapshots/editor-page.spec.ts-editor-with-snippet.png +0 -0
- package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-lg.png +0 -0
- package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-md.png +0 -0
- package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-xs.png +0 -0
- package/playwright-tests/snapshots/files-dialog.spec.ts-view-snippet-files.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-lg.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-md.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-xs.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-lg.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-md.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-xs.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-lg.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-md.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-xs.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-lg.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-md.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-xs.png +0 -0
- package/playwright-tests/snapshots/handle-manual-edits.spec.ts-handle-manual-edits.png +0 -0
- package/playwright-tests/snapshots/home-page.spec.ts-Home-page-lg.png +0 -0
- package/playwright-tests/snapshots/home-page.spec.ts-Home-page-md.png +0 -0
- package/playwright-tests/snapshots/home-page.spec.ts-Home-page-xs.png +0 -0
- package/playwright-tests/snapshots/images.spec.ts-pcb-image.png +0 -0
- package/playwright-tests/snapshots/images.spec.ts-schematic-image.png +0 -0
- package/playwright-tests/snapshots/manual-edits.spec.ts-editor-manual-edits.png +0 -0
- package/playwright-tests/snapshots/manual-edits.spec.ts-manual-edits-view.png +0 -0
- package/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-pcb.png +0 -0
- package/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-schematic.png +0 -0
- package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagelg.png +0 -0
- package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagemd.png +0 -0
- package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagexs.png +0 -0
- package/playwright-tests/snapshots/search-links.spec.ts-search-links.png +0 -0
- package/playwright-tests/snapshots/search.spec.ts-search-lg.png +0 -0
- package/playwright-tests/snapshots/search.spec.ts-search-md.png +0 -0
- package/playwright-tests/snapshots/search.spec.ts-search-xs.png +0 -0
- package/playwright-tests/snapshots/star.spec.ts-remove-star-button.png +0 -0
- package/playwright-tests/snapshots/star.spec.ts-star-button.png +0 -0
- package/playwright-tests/snapshots/update-description.spec.ts-update-description.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-lg.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-md.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-xs.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-lg.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-md.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-xs.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-files.png +0 -0
- package/playwright-tests/star.spec.ts +40 -0
- package/playwright-tests/update-description.spec.ts +18 -0
- package/playwright-tests/view-snippet.spec.ts +35 -0
- package/playwright-tests/viewports.ts +5 -0
- package/playwright.config.ts +27 -0
- package/postcss.config.js +6 -0
- package/public/robots.txt +9 -0
- package/renovate.json +24 -0
- package/scripts/generate-image-sizes.ts +58 -0
- package/scripts/generate-sitemap.ts +103 -0
- package/scripts/generate_bundle_stats.js +192 -0
- package/scripts/snapshot.ts +35 -0
- package/src/App.tsx +113 -0
- package/src/ContextProviders.tsx +9 -0
- package/src/assets/originals/editor_example_1.webp +0 -0
- package/src/assets/originals/editor_example_1_more_square.webp +0 -0
- package/src/assets/originals/editor_example_2.webp +0 -0
- package/src/assets/originals/example_schematic.webp +0 -0
- package/src/components/AiChatInterface.tsx +221 -0
- package/src/components/AiChatMessage.tsx +86 -0
- package/src/components/Analytics.tsx +30 -0
- package/src/components/BomTable.tsx +69 -0
- package/src/components/ChatInput.tsx +53 -0
- package/src/components/CircuitToSvgWithMouseControl.tsx +78 -0
- package/src/components/CmdKMenu.tsx +301 -0
- package/src/components/CodeAndPreview.tsx +258 -0
- package/src/components/CodeEditor.tsx +460 -0
- package/src/components/CodeEditorHeader.tsx +160 -0
- package/src/components/CreateNewSnippetWithAiHero.tsx +77 -0
- package/src/components/DownloadButtonAndMenu.tsx +212 -0
- package/src/components/EditorNav.tsx +428 -0
- package/src/components/ErrorFallback.tsx +25 -0
- package/src/components/ErrorTabContent.tsx +122 -0
- package/src/components/FAQ.tsx +113 -0
- package/src/components/Footer.tsx +134 -0
- package/src/components/Footer2.tsx +100 -0
- package/src/components/FootprintDialog.tsx +342 -0
- package/src/components/Header.tsx +187 -0
- package/src/components/Header2.tsx +135 -0
- package/src/components/HeaderDropdown.tsx +83 -0
- package/src/components/HeaderLogin.tsx +94 -0
- package/src/components/JLCPCBImportDialog.tsx +155 -0
- package/src/components/LandingHero.tsx +175 -0
- package/src/components/LatestSnippets.tsx +39 -0
- package/src/components/OptimizedImage.tsx +96 -0
- package/src/components/OrderPreviewContent.tsx +61 -0
- package/src/components/ParametersEditor.tsx +140 -0
- package/src/components/PcbViewerWithContainerHeight.tsx +47 -0
- package/src/components/PrefetchPageLink.tsx +45 -0
- package/src/components/PreviewContent.tsx +375 -0
- package/src/components/PreviewEmptyState.tsx +16 -0
- package/src/components/RunButton.tsx +27 -0
- package/src/components/SearchComponent.tsx +163 -0
- package/src/components/ShippingInformationForm.tsx +423 -0
- package/src/components/SnippetLink.tsx +37 -0
- package/src/components/StaticPreviewContent.tsx +89 -0
- package/src/components/StaticViewSnippetHeader.tsx +70 -0
- package/src/components/StaticViewSnippetSidebar.tsx +100 -0
- package/src/components/TableViewer/CircuitJsonTableViewer.tsx +316 -0
- package/src/components/TableViewer/ClickableText.tsx +21 -0
- package/src/components/TableViewer/HeaderCell.tsx +27 -0
- package/src/components/TableViewer/Modal.tsx +39 -0
- package/src/components/TrendingSnippetCarousel.tsx +77 -0
- package/src/components/TypeBadge.tsx +31 -0
- package/src/components/ViewSnippetHeader.tsx +144 -0
- package/src/components/ViewSnippetSidebar.tsx +162 -0
- package/src/components/dialogs/confirm-delete-snippet-dialog.tsx +80 -0
- package/src/components/dialogs/create-order-dialog.tsx +146 -0
- package/src/components/dialogs/create-use-dialog.tsx +34 -0
- package/src/components/dialogs/edit-description-dialog.tsx +96 -0
- package/src/components/dialogs/files-dialog.tsx +70 -0
- package/src/components/dialogs/import-snippet-dialog.tsx +84 -0
- package/src/components/dialogs/rename-snippet-dialog.tsx +81 -0
- package/src/components/dialogs/view-ts-files-dialog.tsx +89 -0
- package/src/components/ui/accordion.tsx +55 -0
- package/src/components/ui/alert-dialog.tsx +139 -0
- package/src/components/ui/alert.tsx +59 -0
- package/src/components/ui/aspect-ratio.tsx +5 -0
- package/src/components/ui/avatar.tsx +48 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/breadcrumb.tsx +118 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/calendar.tsx +73 -0
- package/src/components/ui/card.tsx +76 -0
- package/src/components/ui/carousel.tsx +260 -0
- package/src/components/ui/chart.tsx +363 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/collapsible.tsx +9 -0
- package/src/components/ui/combobox.tsx +178 -0
- package/src/components/ui/command.tsx +151 -0
- package/src/components/ui/context-menu.tsx +202 -0
- package/src/components/ui/dialog.tsx +120 -0
- package/src/components/ui/drawer.tsx +116 -0
- package/src/components/ui/dropdown-menu.tsx +203 -0
- package/src/components/ui/form.tsx +182 -0
- package/src/components/ui/hover-card.tsx +27 -0
- package/src/components/ui/input-otp.tsx +69 -0
- package/src/components/ui/input.tsx +25 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/menubar.tsx +238 -0
- package/src/components/ui/navigation-menu.tsx +129 -0
- package/src/components/ui/pagination.tsx +121 -0
- package/src/components/ui/popover.tsx +31 -0
- package/src/components/ui/progress.tsx +26 -0
- package/src/components/ui/radio-group.tsx +42 -0
- package/src/components/ui/resizable.tsx +43 -0
- package/src/components/ui/scroll-area.tsx +46 -0
- package/src/components/ui/searchable-select.tsx +94 -0
- package/src/components/ui/select.tsx +162 -0
- package/src/components/ui/separator.tsx +29 -0
- package/src/components/ui/sheet.tsx +141 -0
- package/src/components/ui/skeleton.tsx +18 -0
- package/src/components/ui/slider.tsx +26 -0
- package/src/components/ui/sonner.tsx +30 -0
- package/src/components/ui/switch.tsx +27 -0
- package/src/components/ui/table.tsx +120 -0
- package/src/components/ui/tabs.tsx +53 -0
- package/src/components/ui/textarea.tsx +24 -0
- package/src/components/ui/toast.tsx +128 -0
- package/src/components/ui/toaster.tsx +33 -0
- package/src/components/ui/toggle-group.tsx +59 -0
- package/src/components/ui/toggle.tsx +43 -0
- package/src/components/ui/tooltip.tsx +28 -0
- package/src/entry-server.tsx +12 -0
- package/src/hooks/use-account-balance.ts +24 -0
- package/src/hooks/use-ai-api.ts +35 -0
- package/src/hooks/use-axios.ts +20 -0
- package/src/hooks/use-code-completion-ai-api.ts +11 -0
- package/src/hooks/use-compiled-tsx.ts +37 -0
- package/src/hooks/use-copy-to-clipboard.ts +26 -0
- package/src/hooks/use-create-snippet-mutation.ts +62 -0
- package/src/hooks/use-current-snippet-id.ts +75 -0
- package/src/hooks/use-current-snippet.ts +24 -0
- package/src/hooks/use-global-store.ts +33 -0
- package/src/hooks/use-is-using-fake-api.ts +3 -0
- package/src/hooks/use-run-tsx/construct-circuit.tsx +64 -0
- package/src/hooks/use-run-tsx/eval-compiled-js.ts +9 -0
- package/src/hooks/use-run-tsx/index.tsx +251 -0
- package/src/hooks/use-save-snippet.ts +66 -0
- package/src/hooks/use-sign-in.ts +22 -0
- package/src/hooks/use-snippet-by-name.ts +25 -0
- package/src/hooks/use-snippet.ts +23 -0
- package/src/hooks/use-snippets-base-api-url.ts +3 -0
- package/src/hooks/use-toast.tsx +208 -0
- package/src/hooks/use-typecheck.ts +54 -0
- package/src/hooks/use-url-params.ts +31 -0
- package/src/hooks/use-warn-user-on-page-change.ts +23 -0
- package/src/hooks/useForkSnippetMutation.ts +52 -0
- package/src/index.css +21 -0
- package/src/lib/__tests__/constants.test.ts +66 -0
- package/src/lib/base64ToBytes.ts +5 -0
- package/src/lib/bytesToBase64.ts +4 -0
- package/src/lib/codemirror/basic-setup.ts +51 -0
- package/src/lib/constants.ts +12 -0
- package/src/lib/decodeUrlHashToText.ts +15 -0
- package/src/lib/defaultCodeForBlankCode.tsx +7 -0
- package/src/lib/download-fns/createBlobURL.ts +4 -0
- package/src/lib/download-fns/download-assembly-svg.ts +12 -0
- package/src/lib/download-fns/download-circuit-json-fn.ts +12 -0
- package/src/lib/download-fns/download-dsn-file-fn.ts +12 -0
- package/src/lib/download-fns/download-fabrication-files.ts +233 -0
- package/src/lib/download-fns/download-gltf.ts +49 -0
- package/src/lib/download-fns/download-kicad-files.ts +27 -0
- package/src/lib/download-fns/download-readable-netlist.ts +12 -0
- package/src/lib/download-fns/download-schematic-svg.ts +12 -0
- package/src/lib/download-fns/download-simple-route-json.ts +17 -0
- package/src/lib/encodeTextToUrlHash.ts +17 -0
- package/src/lib/get-snippet-template.ts +26 -0
- package/src/lib/handleManualEditsImport.tsx +65 -0
- package/src/lib/jlc-parts-engine.ts +69 -0
- package/src/lib/templates/blank-3d-model-template.ts +12 -0
- package/src/lib/templates/blank-circuit-board-template.ts +24 -0
- package/src/lib/templates/blank-footprint-template.ts +29 -0
- package/src/lib/templates/blank-package-template.ts +22 -0
- package/src/lib/templates/blinking-led-board-template.ts +63 -0
- package/src/lib/templates/manual-edits-template.ts +5 -0
- package/src/lib/templates/usb-c-led-flashlight-template.ts +22 -0
- package/src/lib/utils/checkIfManualEditsImported.ts +6 -0
- package/src/lib/utils/getSyntaxError.ts +13 -0
- package/src/lib/utils/index.ts +6 -0
- package/src/lib/utils/load-prettier.ts +18 -0
- package/src/lib/utils/parseFootprintParams.ts +52 -0
- package/src/lib/utils/parseJsonOrNull.ts +8 -0
- package/src/lib/utils/pcbManualEditEventHandler.ts +156 -0
- package/src/main.tsx +10 -0
- package/src/pages/ai.tsx +92 -0
- package/src/pages/authorize.tsx +54 -0
- package/src/pages/dashboard.tsx +165 -0
- package/src/pages/dev-login.tsx +68 -0
- package/src/pages/editor.tsx +28 -0
- package/src/pages/landing.tsx +236 -0
- package/src/pages/my-orders.tsx +54 -0
- package/src/pages/newest.tsx +16 -0
- package/src/pages/preview.tsx +70 -0
- package/src/pages/quickstart.tsx +198 -0
- package/src/pages/search.tsx +26 -0
- package/src/pages/settings.tsx +25 -0
- package/src/pages/user-profile.tsx +97 -0
- package/src/pages/view-order.tsx +123 -0
- package/src/pages/view-snippet.tsx +149 -0
- package/src/prettier.ts +9 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.js +47 -0
- package/tsconfig.json +30 -0
- package/vercel.json +50 -0
- package/vite.config.ts +146 -0
- package/winterspec.config.ts +6 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { getTestServer } from "bun-tests/fake-snippets-api/fixtures/get-test-server"
|
|
2
|
+
import { test, expect } from "bun:test"
|
|
3
|
+
|
|
4
|
+
test("remove star from snippet", async () => {
|
|
5
|
+
const { axios, db } = await getTestServer()
|
|
6
|
+
|
|
7
|
+
// Add a test snippet
|
|
8
|
+
const snippet = {
|
|
9
|
+
unscoped_name: "TestSnippet",
|
|
10
|
+
owner_name: "otheruser",
|
|
11
|
+
code: "Test Content",
|
|
12
|
+
created_at: "2023-01-01T00:00:00Z",
|
|
13
|
+
updated_at: "2023-01-01T00:00:00Z",
|
|
14
|
+
name: "otheruser/TestSnippet",
|
|
15
|
+
snippet_type: "package",
|
|
16
|
+
description: "Test Description",
|
|
17
|
+
}
|
|
18
|
+
const addedSnippet = db.addSnippet(snippet as any)!
|
|
19
|
+
|
|
20
|
+
// Star the snippet
|
|
21
|
+
await axios.post(
|
|
22
|
+
"/api/snippets/add_star",
|
|
23
|
+
{
|
|
24
|
+
snippet_id: addedSnippet.snippet_id,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
headers: {
|
|
28
|
+
Authorization: "Bearer 1234",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// remove star from snippet
|
|
34
|
+
const response = await axios.post(
|
|
35
|
+
"/api/snippets/remove_star",
|
|
36
|
+
{
|
|
37
|
+
snippet_id: addedSnippet.snippet_id,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: "Bearer 123",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
expect(response.status).toBe(200)
|
|
47
|
+
expect(response.data.ok).toBe(true)
|
|
48
|
+
expect(response.data.is_starred).toBe(false)
|
|
49
|
+
|
|
50
|
+
// Verify star was removed in database
|
|
51
|
+
expect(db.hasStarred("account-123", addedSnippet.snippet_id)).toBe(false)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test("remove star from non-existent snippet", async () => {
|
|
55
|
+
const { axios } = await getTestServer()
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
await axios.post(
|
|
59
|
+
"/api/snippets/remove_star",
|
|
60
|
+
{
|
|
61
|
+
snippet_id: "non-existent-id",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
headers: {
|
|
65
|
+
Authorization: "Bearer 1234",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
)
|
|
69
|
+
expect(true).toBe(false) // Should not reach here
|
|
70
|
+
} catch (error: any) {
|
|
71
|
+
expect(error.status).toBe(404)
|
|
72
|
+
expect(error.data.error.message).toBe("Snippet not found")
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
test("remove star from unstarred snippet", async () => {
|
|
77
|
+
const { axios, db } = await getTestServer()
|
|
78
|
+
|
|
79
|
+
// Add a test snippet
|
|
80
|
+
const snippet = {
|
|
81
|
+
unscoped_name: "TestSnippet",
|
|
82
|
+
owner_name: "otheruser",
|
|
83
|
+
code: "Test Content",
|
|
84
|
+
created_at: "2023-01-01T00:00:00Z",
|
|
85
|
+
updated_at: "2023-01-01T00:00:00Z",
|
|
86
|
+
name: "otheruser/TestSnippet",
|
|
87
|
+
snippet_type: "package",
|
|
88
|
+
description: "Test Description",
|
|
89
|
+
}
|
|
90
|
+
const addedSnippet = db.addSnippet(snippet as any)
|
|
91
|
+
|
|
92
|
+
// Remove star
|
|
93
|
+
try {
|
|
94
|
+
await axios.post(
|
|
95
|
+
"/api/snippets/remove_star",
|
|
96
|
+
{
|
|
97
|
+
snippet_id: addedSnippet.snippet_id,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
headers: {
|
|
101
|
+
Authorization: "Bearer 1234",
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
)
|
|
105
|
+
expect(true).toBe(false) // Should not reach here
|
|
106
|
+
} catch (error: any) {
|
|
107
|
+
expect(error.status).toBe(400)
|
|
108
|
+
expect(error.data.error.message).toBe("You have not starred this snippet")
|
|
109
|
+
}
|
|
110
|
+
})
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { getTestServer } from "bun-tests/fake-snippets-api/fixtures/get-test-server"
|
|
2
|
+
import { test, expect } from "bun:test"
|
|
3
|
+
|
|
4
|
+
test("search snippets", async () => {
|
|
5
|
+
const { axios, db } = await getTestServer()
|
|
6
|
+
|
|
7
|
+
// Add some test snippets
|
|
8
|
+
const snippets = [
|
|
9
|
+
{
|
|
10
|
+
unscoped_name: "Snippet1",
|
|
11
|
+
owner_name: "User1",
|
|
12
|
+
code: "Content1",
|
|
13
|
+
created_at: "2023-01-01T00:00:00Z",
|
|
14
|
+
updated_at: "2023-01-01T00:00:00Z",
|
|
15
|
+
name: "User1/Snippet1",
|
|
16
|
+
snippet_type: "board",
|
|
17
|
+
description: "First test snippet",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
unscoped_name: "Snippet2",
|
|
21
|
+
owner_name: "User2",
|
|
22
|
+
code: "Content2 with searchable text",
|
|
23
|
+
created_at: "2023-01-02T00:00:00Z",
|
|
24
|
+
updated_at: "2023-01-02T00:00:00Z",
|
|
25
|
+
name: "User2/Snippet2",
|
|
26
|
+
snippet_type: "package",
|
|
27
|
+
description: "Second test snippet",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
unscoped_name: "Snippet3",
|
|
31
|
+
owner_name: "User1",
|
|
32
|
+
code: "Content3",
|
|
33
|
+
created_at: "2023-01-03T00:00:00Z",
|
|
34
|
+
updated_at: "2023-01-03T00:00:00Z",
|
|
35
|
+
name: "User1/Snippet3",
|
|
36
|
+
snippet_type: "model",
|
|
37
|
+
description: "Third test snippet with searchable description",
|
|
38
|
+
},
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
for (const snippet of snippets) {
|
|
42
|
+
db.addSnippet(snippet as any)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Test search by name
|
|
46
|
+
const nameSearchResponse = await axios.get("/api/snippets/search", {
|
|
47
|
+
params: { q: "Snippet1" },
|
|
48
|
+
})
|
|
49
|
+
expect(nameSearchResponse.status).toBe(200)
|
|
50
|
+
expect(nameSearchResponse.data.snippets).toHaveLength(1)
|
|
51
|
+
expect(nameSearchResponse.data.snippets[0].name).toBe("User1/Snippet1")
|
|
52
|
+
|
|
53
|
+
// Test search by description
|
|
54
|
+
const descriptionSearchResponse = await axios.get("/api/snippets/search", {
|
|
55
|
+
params: { q: "searchable description" },
|
|
56
|
+
})
|
|
57
|
+
expect(descriptionSearchResponse.status).toBe(200)
|
|
58
|
+
expect(descriptionSearchResponse.data.snippets).toHaveLength(1)
|
|
59
|
+
expect(descriptionSearchResponse.data.snippets[0].name).toBe("User1/Snippet3")
|
|
60
|
+
|
|
61
|
+
// Test search by code content
|
|
62
|
+
const codeSearchResponse = await axios.get("/api/snippets/search", {
|
|
63
|
+
params: { q: "searchable text" },
|
|
64
|
+
})
|
|
65
|
+
expect(codeSearchResponse.status).toBe(200)
|
|
66
|
+
expect(codeSearchResponse.data.snippets).toHaveLength(1)
|
|
67
|
+
expect(codeSearchResponse.data.snippets[0].name).toBe("User2/Snippet2")
|
|
68
|
+
|
|
69
|
+
// Test search with no results
|
|
70
|
+
const noResultsResponse = await axios.get("/api/snippets/search", {
|
|
71
|
+
params: { q: "nonexistent" },
|
|
72
|
+
})
|
|
73
|
+
expect(noResultsResponse.status).toBe(200)
|
|
74
|
+
expect(noResultsResponse.data.snippets).toHaveLength(0)
|
|
75
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getTestServer } from "bun-tests/fake-snippets-api/fixtures/get-test-server"
|
|
2
|
+
import { test, expect } from "bun:test"
|
|
3
|
+
|
|
4
|
+
test("star count is correctly calculated", async () => {
|
|
5
|
+
const { axios, db } = await getTestServer()
|
|
6
|
+
|
|
7
|
+
// Add a test snippet
|
|
8
|
+
const snippet = {
|
|
9
|
+
unscoped_name: "TestSnippet",
|
|
10
|
+
owner_name: "testuser",
|
|
11
|
+
code: "Test Content",
|
|
12
|
+
created_at: "2023-01-01T00:00:00Z",
|
|
13
|
+
updated_at: "2023-01-01T00:00:00Z",
|
|
14
|
+
name: "testuser/TestSnippet",
|
|
15
|
+
snippet_type: "package",
|
|
16
|
+
description: "Test Description",
|
|
17
|
+
}
|
|
18
|
+
const addedSnippet = db.addSnippet(snippet as any)
|
|
19
|
+
|
|
20
|
+
// Add some stars from different users
|
|
21
|
+
db.addStar("user1", addedSnippet.snippet_id)
|
|
22
|
+
db.addStar("user2", addedSnippet.snippet_id)
|
|
23
|
+
db.addStar("user3", addedSnippet.snippet_id)
|
|
24
|
+
|
|
25
|
+
// Test star count in list endpoint
|
|
26
|
+
const listResponse = await axios.get("/api/snippets/list")
|
|
27
|
+
expect(listResponse.status).toBe(200)
|
|
28
|
+
expect(listResponse.data.snippets[0].star_count).toBe(3)
|
|
29
|
+
|
|
30
|
+
// Test star count in get endpoint
|
|
31
|
+
const getResponse = await axios.get("/api/snippets/get", {
|
|
32
|
+
params: { snippet_id: addedSnippet.snippet_id },
|
|
33
|
+
})
|
|
34
|
+
expect(getResponse.status).toBe(200)
|
|
35
|
+
expect(getResponse.data.snippet.star_count).toBe(3)
|
|
36
|
+
|
|
37
|
+
// Remove a star
|
|
38
|
+
db.removeStar("user2", addedSnippet.snippet_id)
|
|
39
|
+
|
|
40
|
+
// Verify updated star count
|
|
41
|
+
const updatedListResponse = await axios.get("/api/snippets/list")
|
|
42
|
+
expect(updatedListResponse.status).toBe(200)
|
|
43
|
+
expect(updatedListResponse.data.snippets[0].star_count).toBe(2)
|
|
44
|
+
})
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { getTestServer } from "bun-tests/fake-snippets-api/fixtures/get-test-server"
|
|
2
|
+
import { test, expect } from "bun:test"
|
|
3
|
+
|
|
4
|
+
test("update snippet", async () => {
|
|
5
|
+
const { axios, db } = await getTestServer()
|
|
6
|
+
|
|
7
|
+
// Add a test snippet
|
|
8
|
+
const snippet = {
|
|
9
|
+
unscoped_name: "TestSnippet",
|
|
10
|
+
owner_name: "testuser",
|
|
11
|
+
code: "Original Content",
|
|
12
|
+
created_at: "2023-01-01T00:00:00Z",
|
|
13
|
+
updated_at: "2023-01-01T00:00:00Z",
|
|
14
|
+
name: "testuser/TestSnippet",
|
|
15
|
+
snippet_type: "package",
|
|
16
|
+
description: "Original Description",
|
|
17
|
+
compiled_js: null,
|
|
18
|
+
}
|
|
19
|
+
db.addSnippet(snippet as any)
|
|
20
|
+
|
|
21
|
+
const addedSnippet = db.snippets[0]
|
|
22
|
+
|
|
23
|
+
// Update the snippet
|
|
24
|
+
const updatedCode = "Updated Content"
|
|
25
|
+
const updatedCompiledJs = "console.log('Updated Content')"
|
|
26
|
+
const response = await axios.post(
|
|
27
|
+
"/api/snippets/update",
|
|
28
|
+
{
|
|
29
|
+
snippet_id: addedSnippet.snippet_id,
|
|
30
|
+
code: updatedCode,
|
|
31
|
+
compiled_js: updatedCompiledJs,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: "Bearer 1234",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
expect(response.status).toBe(200)
|
|
41
|
+
expect(response.data.snippet.code).toBe(updatedCode)
|
|
42
|
+
expect(response.data.snippet.compiled_js).toBe(updatedCompiledJs)
|
|
43
|
+
expect(response.data.snippet.updated_at).not.toBe(addedSnippet.created_at)
|
|
44
|
+
|
|
45
|
+
// Verify the snippet was updated in the database
|
|
46
|
+
const updatedSnippet = db.snippets[0]
|
|
47
|
+
expect(updatedSnippet.code).toBe(updatedCode)
|
|
48
|
+
expect(updatedSnippet.compiled_js).toBe(updatedCompiledJs)
|
|
49
|
+
expect(updatedSnippet.updated_at).not.toBe(updatedSnippet.created_at)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test("update non-existent snippet", async () => {
|
|
53
|
+
const { axios } = await getTestServer()
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
await axios.post(
|
|
57
|
+
"/api/snippets/update",
|
|
58
|
+
{
|
|
59
|
+
snippet_id: "non-existent-id",
|
|
60
|
+
code: "Updated Content",
|
|
61
|
+
compiled_js: "console.log('Updated Content')",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
headers: {
|
|
65
|
+
Authorization: "Bearer 1234",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
)
|
|
69
|
+
// If the request doesn't throw an error, fail the test
|
|
70
|
+
expect(true).toBe(false)
|
|
71
|
+
} catch (error: any) {
|
|
72
|
+
expect(error.status).toBe(404)
|
|
73
|
+
expect(error.data.error.message).toBe("Snippet not found")
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
test("update snippet with null compiled_js", async () => {
|
|
78
|
+
const { axios, db } = await getTestServer()
|
|
79
|
+
|
|
80
|
+
// Add a test snippet with compiled_js
|
|
81
|
+
const snippet = {
|
|
82
|
+
unscoped_name: "TestSnippet",
|
|
83
|
+
owner_name: "testuser",
|
|
84
|
+
code: "Original Content",
|
|
85
|
+
created_at: "2023-01-01T00:00:00Z",
|
|
86
|
+
updated_at: "2023-01-01T00:00:00Z",
|
|
87
|
+
name: "testuser/TestSnippet",
|
|
88
|
+
snippet_type: "package",
|
|
89
|
+
description: "Original Description",
|
|
90
|
+
compiled_js: "console.log('Original Content')",
|
|
91
|
+
}
|
|
92
|
+
db.addSnippet(snippet as any)
|
|
93
|
+
|
|
94
|
+
const addedSnippet = db.snippets[0]
|
|
95
|
+
|
|
96
|
+
// Update the snippet with null compiled_js
|
|
97
|
+
const response = await axios.post(
|
|
98
|
+
"/api/snippets/update",
|
|
99
|
+
{
|
|
100
|
+
snippet_id: addedSnippet.snippet_id,
|
|
101
|
+
compiled_js: null,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
headers: {
|
|
105
|
+
Authorization: "Bearer 1234",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
expect(response.status).toBe(200)
|
|
111
|
+
expect(response.data.snippet.compiled_js).toBeNull()
|
|
112
|
+
|
|
113
|
+
// Verify the snippet was updated in the database
|
|
114
|
+
const updatedSnippet = db.snippets[0]
|
|
115
|
+
expect(updatedSnippet.compiled_js).toBeNull()
|
|
116
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jlcPartsEngine } from "@/lib/jlc-parts-engine"
|
|
2
|
+
import { test, expect } from "bun:test"
|
|
3
|
+
|
|
4
|
+
test("findPart", async () => {
|
|
5
|
+
if (process.env.CI) return
|
|
6
|
+
const supplierPartNumbers = await jlcPartsEngine.findPart({
|
|
7
|
+
sourceComponent: {
|
|
8
|
+
type: "source_component",
|
|
9
|
+
ftype: "simple_resistor",
|
|
10
|
+
source_component_id: "123",
|
|
11
|
+
name: "R1",
|
|
12
|
+
resistance: 1000,
|
|
13
|
+
},
|
|
14
|
+
footprinterString: "0402",
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
expect(supplierPartNumbers.jlcpcb!.length).toEqual(3)
|
|
18
|
+
})
|
package/bun.lockb
ADDED
|
Binary file
|
package/bunfig.toml
ADDED
package/components.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": false,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "tailwind.config.js",
|
|
8
|
+
"css": "src/index.css",
|
|
9
|
+
"baseColor": "slate",
|
|
10
|
+
"cssVariables": false,
|
|
11
|
+
"prefix": ""
|
|
12
|
+
},
|
|
13
|
+
"aliases": {
|
|
14
|
+
"components": "@/components",
|
|
15
|
+
"utils": "@/lib/utils",
|
|
16
|
+
"ui": "@/components/ui",
|
|
17
|
+
"lib": "@/lib",
|
|
18
|
+
"hooks": "@/hooks"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|