@tscircuit/fake-snippets 0.0.65 → 0.0.67

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 (87) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/README.md +2 -2
  3. package/bun-tests/fake-snippets-api/fixtures/get-circuit-json.ts +5 -143
  4. package/bun-tests/fake-snippets-api/fixtures/get-test-server.ts +1 -4
  5. package/bun-tests/fake-snippets-api/fixtures/start-server.ts +7 -3
  6. package/bun-tests/fake-snippets-api/routes/order_quotes/create.test.ts +20 -56
  7. package/bun-tests/fake-snippets-api/routes/package_files/create_or_update.test.ts +2 -2
  8. package/bun-tests/fake-snippets-api/routes/package_releases/update.test.ts +1 -1
  9. package/bun-tests/fake-snippets-api/routes/packages/images.test.ts +1 -16
  10. package/bun.lock +42 -31
  11. package/dist/bundle.js +34 -41
  12. package/fake-snippets-api/routes/api/order_quotes/create.ts +30 -37
  13. package/fake-snippets-api/routes/api/order_quotes/get.ts +5 -8
  14. package/fake-snippets-api/routes/api/packages/images/[owner_github_username]/[unscoped_name]/[view_format].ts +3 -3
  15. package/package.json +7 -5
  16. package/src/App.tsx +0 -7
  17. package/src/ContextProviders.tsx +2 -0
  18. package/src/components/DownloadButtonAndMenu.tsx +1 -4
  19. package/src/components/ErrorTabContent.tsx +1 -1
  20. package/src/components/Footer.tsx +5 -2
  21. package/src/components/HeaderLogin.tsx +37 -54
  22. package/src/components/ImageWithFallback.tsx +37 -0
  23. package/src/components/JLCPCBImportDialog.tsx +43 -24
  24. package/src/components/PackageCard.tsx +12 -3
  25. package/src/components/{SnippetLink.tsx → PackageLink.tsx} +8 -16
  26. package/src/components/PackageSearchResults.tsx +87 -0
  27. package/src/components/PackagesList.tsx +3 -3
  28. package/src/components/PageSearchComponent.tsx +9 -9
  29. package/src/components/ShippingInformationForm.tsx +1 -1
  30. package/src/components/TrendingPackagesCarousel.tsx +43 -23
  31. package/src/components/ViewPackagePage/components/ShikiCodeViewer.tsx +5 -28
  32. package/src/components/ViewPackagePage/components/main-content-header.tsx +10 -22
  33. package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +25 -14
  34. package/src/components/ViewPackagePage/components/package-header.tsx +9 -4
  35. package/src/components/ViewPackagePage/components/preview-image-squares.tsx +6 -1
  36. package/src/components/ViewPackagePage/components/repo-page-content.tsx +4 -4
  37. package/src/components/ViewPackagePage/components/sidebar.tsx +2 -14
  38. package/src/components/ViewSnippetSidebar.tsx +1 -1
  39. package/src/components/package-port/CodeEditor.tsx +13 -10
  40. package/src/components/package-port/CodeEditorHeader.tsx +1 -1
  41. package/src/components/package-port/EditorNav.tsx +2 -2
  42. package/src/hooks/use-get-fsmap-hash-for-package.ts +19 -0
  43. package/src/hooks/use-global-store.ts +1 -0
  44. package/src/hooks/use-preview-images.ts +20 -4
  45. package/src/hooks/use-shiki-highlighter.ts +13 -6
  46. package/src/hooks/use-toast.tsx +1 -1
  47. package/src/lib/download-fns/download-gltf.ts +3 -10
  48. package/src/lib/handleManualEditsImport.tsx +1 -1
  49. package/src/lib/types.ts +4 -2
  50. package/src/pages/dashboard.tsx +3 -4
  51. package/src/pages/editor.tsx +20 -14
  52. package/src/pages/latest.tsx +25 -26
  53. package/src/pages/package-editor.tsx +14 -2
  54. package/src/pages/search.tsx +120 -19
  55. package/src/pages/trending.tsx +14 -59
  56. package/src/pages/user-profile.tsx +13 -8
  57. package/bun-tests/fake-snippets-api/routes/snippets/add_star.test.ts +0 -84
  58. package/bun-tests/fake-snippets-api/routes/snippets/create.test.ts +0 -53
  59. package/bun-tests/fake-snippets-api/routes/snippets/delete.test.ts +0 -82
  60. package/bun-tests/fake-snippets-api/routes/snippets/download.test.ts +0 -90
  61. package/bun-tests/fake-snippets-api/routes/snippets/generate_from_jlcpcb.test.ts +0 -16
  62. package/bun-tests/fake-snippets-api/routes/snippets/get.test.ts +0 -163
  63. package/bun-tests/fake-snippets-api/routes/snippets/get_image.test.ts +0 -117
  64. package/bun-tests/fake-snippets-api/routes/snippets/images.test.ts +0 -114
  65. package/bun-tests/fake-snippets-api/routes/snippets/list.test.ts +0 -169
  66. package/bun-tests/fake-snippets-api/routes/snippets/list_newest.test.ts +0 -50
  67. package/bun-tests/fake-snippets-api/routes/snippets/list_trending.test.ts +0 -72
  68. package/bun-tests/fake-snippets-api/routes/snippets/remove_star.test.ts +0 -80
  69. package/bun-tests/fake-snippets-api/routes/snippets/search.test.ts +0 -75
  70. package/bun-tests/fake-snippets-api/routes/snippets/star-count.test.ts +0 -51
  71. package/bun-tests/fake-snippets-api/routes/snippets/update.test.ts +0 -175
  72. package/src/components/AiChatInterface.tsx +0 -229
  73. package/src/components/CodeAndPreview.tsx +0 -289
  74. package/src/components/CodeEditor.tsx +0 -539
  75. package/src/components/CodeEditorHeader.tsx +0 -135
  76. package/src/components/EditorNav.tsx +0 -502
  77. package/src/components/PreviewContent.tsx +0 -372
  78. package/src/components/SnippetCard.tsx +0 -159
  79. package/src/components/SnippetList.tsx +0 -71
  80. package/src/hooks/use-compiled-tsx.ts +0 -37
  81. package/src/hooks/use-run-tsx/construct-circuit.tsx +0 -62
  82. package/src/hooks/use-run-tsx/index.tsx +0 -256
  83. package/src/hooks/use-save-snippet.ts +0 -66
  84. package/src/hooks/use-typecheck.ts +0 -54
  85. package/src/lib/utils/getSyntaxError.ts +0 -13
  86. package/src/pages/ai.tsx +0 -92
  87. package/src/pages/view-snippet.tsx +0 -166
@@ -1,166 +0,0 @@
1
- import { DownloadButtonAndMenu } from "@/components/DownloadButtonAndMenu"
2
- import Header from "@/components/Header"
3
- import { Button } from "@/components/ui/button"
4
- import ViewSnippetHeader from "@/components/ViewSnippetHeader"
5
- import ViewSnippetSidebar from "@/components/ViewSnippetSidebar"
6
- import { useCurrentSnippet } from "@/hooks/use-current-snippet"
7
- import { useRunTsx } from "@/hooks/use-run-tsx"
8
- import { encodeTextToUrlHash } from "@/lib/encodeTextToUrlHash"
9
- import { Share } from "lucide-react"
10
- import { useParams } from "wouter"
11
- import { PreviewContent } from "@/components/PreviewContent"
12
- import Footer from "@/components/Footer"
13
- import { Helmet } from "react-helmet-async"
14
- import type { AnyCircuitElement } from "circuit-json"
15
- import StaticViewSnippetHeader from "../components/StaticViewSnippetHeader"
16
- import StaticPreviewContent from "../components/StaticPreviewContent"
17
- import StaticViewSnippetSidebar from "../components/StaticViewSnippetSidebar"
18
- import { useEffect, useMemo, useState } from "react"
19
- import { parseJsonOrNull } from "@/lib/utils/parseJsonOrNull"
20
-
21
- export const ViewSnippetPage = () => {
22
- const { author, snippetName } = useParams()
23
- const { snippet, error: snippetError, isLoading } = useCurrentSnippet()
24
-
25
- const [manualEditsFileContent, setManualEditsFileContent] = useState<
26
- string | null
27
- >(null)
28
-
29
- useEffect(() => {
30
- if (snippet?.manual_edits_json_content) {
31
- setManualEditsFileContent(snippet.manual_edits_json_content ?? "")
32
- }
33
- }, [Boolean(snippet?.manual_edits_json_content)])
34
-
35
- const userImports = useMemo(
36
- () => ({
37
- "./manual-edits.json": parseJsonOrNull(manualEditsFileContent) ?? "",
38
- }),
39
- [manualEditsFileContent],
40
- )
41
-
42
- const {
43
- circuitJson: tsxResultCircuitJson,
44
- message,
45
- triggerRunTsx,
46
- isRunningCode,
47
- tsxRunTriggerCount,
48
- circuitJsonKey: tsxResultCircuitJsonKey,
49
- } = useRunTsx({
50
- code: snippet?.code ?? "",
51
- type: snippet?.snippet_type,
52
- userImports,
53
- circuitDisplayName: snippet?.name,
54
- })
55
-
56
- const circuitJsonForPreview = tsxResultCircuitJson ?? snippet?.circuit_json
57
- const circuitJsonKeyForPreview = tsxResultCircuitJson
58
- ? tsxResultCircuitJsonKey
59
- : snippet?.circuit_json
60
- ? "snippet"
61
- : ""
62
-
63
- return (
64
- <>
65
- <Helmet>
66
- <title>{`${author}/${snippetName} - tscircuit`}</title>
67
- {snippet && (
68
- <>
69
- <meta
70
- property="og:title"
71
- content={`${author}/${snippetName} - tscircuit`}
72
- />
73
- <meta
74
- property="og:image"
75
- content={`https://registry-api.tscircuit.com/snippets/images/${author}/${snippetName}/pcb.png`}
76
- />
77
- <meta name="twitter:card" content="summary_large_image" />
78
- <meta
79
- name="twitter:image"
80
- content={`https://registry-api.tscircuit.com/snippets/images/${author}/${snippetName}/pcb.png`}
81
- />
82
- </>
83
- )}
84
- </Helmet>
85
- <div>
86
- <Header />
87
- {isLoading && (
88
- <>
89
- <StaticViewSnippetHeader
90
- author={author as string}
91
- snippetName={snippetName as string}
92
- />
93
- <div className="flex flex-row min-h-full">
94
- <div className="flex-grow overflow-auto">
95
- <StaticPreviewContent />
96
- </div>
97
- <StaticViewSnippetSidebar />
98
- </div>
99
- </>
100
- )}
101
- {snippetError && snippetError.status === 404 && (
102
- <div className="text-gray-500 flex items-center justify-center h-64">
103
- Snippet not found: {author}/{snippetName}
104
- </div>
105
- )}
106
- {snippetError && snippetError.status !== 404 && (
107
- <div>Error: {snippetError.toString()}</div>
108
- )}
109
- {snippet && (
110
- <>
111
- <ViewSnippetHeader />
112
- <div className="flex flex-row min-h-full">
113
- <div className="flex-grow overflow-auto">
114
- <PreviewContent
115
- className="h-full"
116
- code={snippet?.code ?? ""}
117
- triggerRunTsx={triggerRunTsx}
118
- tsxRunTriggerCount={tsxRunTriggerCount}
119
- errorMessage={message}
120
- circuitJson={circuitJsonForPreview}
121
- circuitJsonKey={circuitJsonKeyForPreview}
122
- isRunningCode={isRunningCode}
123
- showCodeTab={true}
124
- showJsonTab={false}
125
- showImportAndFormatButtons={false}
126
- readOnly
127
- headerClassName="p-4 border-b border-gray-200"
128
- leftHeaderContent={
129
- <>
130
- <Button
131
- variant="outline"
132
- size="sm"
133
- className="h-6 px-2 text-xs"
134
- onClick={() => {
135
- if (!snippet) return
136
- const url = encodeTextToUrlHash(snippet.code)
137
- navigator.clipboard.writeText(url)
138
- alert("URL copied to clipboard!")
139
- }}
140
- >
141
- <Share className="mr-1 h-3 w-3" />
142
- Copy URL
143
- </Button>
144
- <DownloadButtonAndMenu
145
- snippetUnscopedName={snippet?.unscoped_name}
146
- circuitJson={
147
- circuitJsonForPreview as AnyCircuitElement[]
148
- }
149
- className="hidden md:flex"
150
- />
151
- </>
152
- }
153
- isStreaming={false}
154
- onCodeChange={() => {}}
155
- onDtsChange={() => {}}
156
- />
157
- </div>
158
- <ViewSnippetSidebar />
159
- </div>
160
- </>
161
- )}
162
- <Footer />
163
- </div>
164
- </>
165
- )
166
- }