@tscircuit/fake-snippets 0.0.98 → 0.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.lock +9 -146
- package/dist/bundle.js +1 -2
- package/fake-snippets-api/routes/api/autocomplete/create_autocomplete.ts +0 -1
- package/package.json +5 -4
- package/src/components/DownloadButtonAndMenu.tsx +13 -0
- package/src/components/FileSidebar.tsx +83 -10
- package/src/components/PackageBuildsPage/LogContent.tsx +19 -7
- package/src/components/package-port/CodeAndPreview.tsx +5 -0
- package/src/components/package-port/CodeEditor.tsx +19 -1
- package/src/components/package-port/CodeEditorHeader.tsx +12 -7
- package/src/components/ui/tree-view.tsx +51 -2
- package/src/hooks/useFileManagement.ts +70 -1
- package/src/lib/download-fns/download-spice-file.ts +13 -0
- package/src/pages/dashboard.tsx +1 -1
- package/src/pages/datasheet.tsx +157 -67
- package/src/pages/datasheets.tsx +2 -2
- package/src/pages/latest.tsx +2 -2
- package/src/pages/search.tsx +1 -1
- package/src/pages/trending.tsx +2 -2
- package/vite.config.ts +1 -0
package/src/pages/datasheet.tsx
CHANGED
|
@@ -5,6 +5,21 @@ import Header from "@/components/Header"
|
|
|
5
5
|
import Footer from "@/components/Footer"
|
|
6
6
|
import ExpandableText from "@/components/ExpandableText"
|
|
7
7
|
import type { Datasheet } from "fake-snippets-api/lib/db/schema"
|
|
8
|
+
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"
|
|
9
|
+
import { Button } from "@/components/ui/button"
|
|
10
|
+
import { Loader2, AlertCircle, FileText } from "lucide-react"
|
|
11
|
+
|
|
12
|
+
const SectionCard = ({
|
|
13
|
+
title,
|
|
14
|
+
children,
|
|
15
|
+
}: { title: string; children: React.ReactNode }) => (
|
|
16
|
+
<Card className="mb-6">
|
|
17
|
+
<CardHeader className="pb-2">
|
|
18
|
+
<CardTitle className="text-xl font-semibold">{title}</CardTitle>
|
|
19
|
+
</CardHeader>
|
|
20
|
+
<CardContent>{children}</CardContent>
|
|
21
|
+
</Card>
|
|
22
|
+
)
|
|
8
23
|
|
|
9
24
|
export const DatasheetPage = () => {
|
|
10
25
|
const { chipName } = useParams<{ chipName: string }>()
|
|
@@ -19,85 +34,160 @@ export const DatasheetPage = () => {
|
|
|
19
34
|
return (
|
|
20
35
|
<div className="min-h-screen flex flex-col">
|
|
21
36
|
<Header />
|
|
22
|
-
<main className="
|
|
23
|
-
<
|
|
24
|
-
|
|
37
|
+
<main className="flex-grow mx-auto px-4 md:px-20 lg:px-28 py-8 w-full">
|
|
38
|
+
<div className="mb-8">
|
|
39
|
+
<h1 className="text-3xl md:text-4xl font-bold text-gray-900 mb-2 break-words">
|
|
40
|
+
{chipName} Datasheet
|
|
41
|
+
</h1>
|
|
42
|
+
<p className="text-lg text-gray-600 mb-4">
|
|
43
|
+
View and download the datasheet for{" "}
|
|
44
|
+
<span className="font-semibold text-gray-800">{chipName}</span>. If
|
|
45
|
+
the datasheet is not available, you can request its creation.
|
|
46
|
+
</p>
|
|
25
47
|
<a
|
|
26
48
|
href={`https://api.tscircuit.com/datasheets/get?chip_name=${encodeURIComponent(chipName)}`}
|
|
27
|
-
className="text-blue-600 underline"
|
|
49
|
+
className="inline-flex items-center gap-1 text-blue-600 hover:underline text-sm font-medium"
|
|
50
|
+
target="_blank"
|
|
51
|
+
rel="noopener noreferrer"
|
|
28
52
|
>
|
|
29
|
-
Download JSON
|
|
53
|
+
<FileText className="w-4 h-4" /> Download JSON
|
|
30
54
|
</a>
|
|
31
|
-
</
|
|
55
|
+
</div>
|
|
56
|
+
|
|
32
57
|
{datasheetQuery.isLoading ? (
|
|
33
|
-
<
|
|
58
|
+
<div className="flex flex-col items-center justify-center py-16">
|
|
59
|
+
<Loader2 className="w-10 h-10 animate-spin text-blue-500 mb-4" />
|
|
60
|
+
<h3 className="text-xl font-semibold mb-2">Loading Datasheet...</h3>
|
|
61
|
+
<p className="text-gray-500 max-w-md text-center">
|
|
62
|
+
Please wait while we fetch the datasheet information for{" "}
|
|
63
|
+
<span className="font-semibold">{chipName}</span>.
|
|
64
|
+
</p>
|
|
65
|
+
</div>
|
|
34
66
|
) : datasheetQuery.data ? (
|
|
35
|
-
|
|
36
|
-
{!
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<a href={url} className="text-blue-600 underline">
|
|
47
|
-
{url}
|
|
48
|
-
</a>
|
|
49
|
-
</li>
|
|
50
|
-
))}
|
|
51
|
-
</ul>
|
|
52
|
-
) : (
|
|
53
|
-
<p>No datasheet PDFs available.</p>
|
|
67
|
+
<>
|
|
68
|
+
{!(
|
|
69
|
+
datasheetQuery.data.pin_information ||
|
|
70
|
+
datasheetQuery.data.datasheet_pdf_urls
|
|
71
|
+
) && (
|
|
72
|
+
<SectionCard title="Processing">
|
|
73
|
+
<div className="flex items-center gap-3 text-yellow-700">
|
|
74
|
+
<Loader2 className="w-5 h-5 animate-spin" />
|
|
75
|
+
<span>Datasheet is processing. Please check back later.</span>
|
|
76
|
+
</div>
|
|
77
|
+
</SectionCard>
|
|
54
78
|
)}
|
|
55
79
|
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
<SectionCard title="Description">
|
|
81
|
+
{datasheetQuery.data.ai_description ? (
|
|
82
|
+
<div className="flex items-center gap-3 text-gray-500">
|
|
83
|
+
<span>{datasheetQuery.data.ai_description}</span>
|
|
84
|
+
</div>
|
|
85
|
+
) : (
|
|
86
|
+
<p className="text-gray-500">No description available.</p>
|
|
87
|
+
)}
|
|
88
|
+
</SectionCard>
|
|
89
|
+
|
|
90
|
+
<SectionCard title="PDFs">
|
|
91
|
+
{datasheetQuery.data.datasheet_pdf_urls &&
|
|
92
|
+
datasheetQuery.data.datasheet_pdf_urls.length > 0 ? (
|
|
93
|
+
<ul className="list-disc pl-5 space-y-2">
|
|
94
|
+
{datasheetQuery.data.datasheet_pdf_urls.map((url) => (
|
|
95
|
+
<li key={url}>
|
|
96
|
+
<a
|
|
97
|
+
href={url}
|
|
98
|
+
className="text-blue-600 underline break-all"
|
|
99
|
+
target="_blank"
|
|
100
|
+
rel="noopener noreferrer"
|
|
101
|
+
>
|
|
102
|
+
{url}
|
|
103
|
+
</a>
|
|
104
|
+
</li>
|
|
80
105
|
))}
|
|
81
|
-
</
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
106
|
+
</ul>
|
|
107
|
+
) : (
|
|
108
|
+
<p className="text-gray-500">No datasheet PDFs available.</p>
|
|
109
|
+
)}
|
|
110
|
+
</SectionCard>
|
|
111
|
+
|
|
112
|
+
<SectionCard title="Pin Information">
|
|
113
|
+
{datasheetQuery.data.pin_information &&
|
|
114
|
+
datasheetQuery.data.pin_information.length > 0 ? (
|
|
115
|
+
<div className="overflow-x-auto">
|
|
116
|
+
<table className="min-w-full border-collapse text-sm">
|
|
117
|
+
<thead>
|
|
118
|
+
<tr>
|
|
119
|
+
<th className="border-b px-3 py-2 text-left font-semibold">
|
|
120
|
+
Pin
|
|
121
|
+
</th>
|
|
122
|
+
<th className="border-b px-3 py-2 text-left font-semibold">
|
|
123
|
+
Name
|
|
124
|
+
</th>
|
|
125
|
+
<th className="border-b px-3 py-2 text-left font-semibold">
|
|
126
|
+
Description
|
|
127
|
+
</th>
|
|
128
|
+
<th className="border-b px-3 py-2 text-left font-semibold">
|
|
129
|
+
Capabilities
|
|
130
|
+
</th>
|
|
131
|
+
</tr>
|
|
132
|
+
</thead>
|
|
133
|
+
<tbody>
|
|
134
|
+
{datasheetQuery.data.pin_information.map((pin) => (
|
|
135
|
+
<tr key={pin.pin_number} className="hover:bg-gray-50">
|
|
136
|
+
<td className="border-b px-3 py-2 font-mono">
|
|
137
|
+
{pin.pin_number}
|
|
138
|
+
</td>
|
|
139
|
+
<td className="border-b px-3 py-2">{pin.name}</td>
|
|
140
|
+
<td className="border-b px-3 py-2">
|
|
141
|
+
{pin.description}
|
|
142
|
+
</td>
|
|
143
|
+
<td className="border-b px-3 py-2">
|
|
144
|
+
<ExpandableText
|
|
145
|
+
text={pin.capabilities.join(", ")}
|
|
146
|
+
maxChars={30}
|
|
147
|
+
/>
|
|
148
|
+
</td>
|
|
149
|
+
</tr>
|
|
150
|
+
))}
|
|
151
|
+
</tbody>
|
|
152
|
+
</table>
|
|
153
|
+
</div>
|
|
154
|
+
) : (
|
|
155
|
+
<p className="text-gray-500">No pin information available.</p>
|
|
156
|
+
)}
|
|
157
|
+
</SectionCard>
|
|
158
|
+
</>
|
|
87
159
|
) : datasheetQuery.error &&
|
|
88
160
|
(datasheetQuery.error as any).status === 404 ? (
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
className="
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
161
|
+
<SectionCard title="No Datasheet Found">
|
|
162
|
+
<div className="flex flex-col items-center gap-4">
|
|
163
|
+
<AlertCircle className="w-8 h-8 text-red-500" />
|
|
164
|
+
<p className="text-gray-700 text-center">
|
|
165
|
+
No datasheet found for{" "}
|
|
166
|
+
<span className="font-semibold">{chipName}</span>.<br />
|
|
167
|
+
You can request its creation below.
|
|
168
|
+
</p>
|
|
169
|
+
<Button
|
|
170
|
+
className="mt-2"
|
|
171
|
+
onClick={handleCreate}
|
|
172
|
+
disabled={createDatasheet.isLoading}
|
|
173
|
+
size="lg"
|
|
174
|
+
>
|
|
175
|
+
{createDatasheet.isLoading ? "Creating..." : "Create Datasheet"}
|
|
176
|
+
</Button>
|
|
177
|
+
</div>
|
|
178
|
+
</SectionCard>
|
|
99
179
|
) : (
|
|
100
|
-
<
|
|
180
|
+
<div className="flex flex-col items-center justify-center py-16">
|
|
181
|
+
<AlertCircle className="w-10 h-10 text-red-500 mb-4" />
|
|
182
|
+
<h3 className="text-xl font-semibold mb-2">
|
|
183
|
+
Error loading datasheet
|
|
184
|
+
</h3>
|
|
185
|
+
<p className="text-gray-500 max-w-md text-center">
|
|
186
|
+
There was an error loading the datasheet for{" "}
|
|
187
|
+
<span className="font-semibold">{chipName}</span>. Please try
|
|
188
|
+
again later.
|
|
189
|
+
</p>
|
|
190
|
+
</div>
|
|
101
191
|
)}
|
|
102
192
|
</main>
|
|
103
193
|
<Footer />
|
package/src/pages/datasheets.tsx
CHANGED
|
@@ -43,7 +43,7 @@ export const DatasheetsPage: React.FC = () => {
|
|
|
43
43
|
return (
|
|
44
44
|
<div className="min-h-screen flex flex-col">
|
|
45
45
|
<Header />
|
|
46
|
-
<main className="flex-grow container mx-auto px-4 py-8">
|
|
46
|
+
<main className="flex-grow container mx-auto px-4 py-8 min-h-[80vh]">
|
|
47
47
|
<div className="mb-8 max-w-3xl">
|
|
48
48
|
<div className="flex items-center gap-2 mb-3">
|
|
49
49
|
<h1 className="text-4xl font-bold text-gray-900">Datasheets</h1>
|
|
@@ -126,7 +126,7 @@ export const DatasheetsPage: React.FC = () => {
|
|
|
126
126
|
</p>
|
|
127
127
|
{searchQuery && (
|
|
128
128
|
<button
|
|
129
|
-
className="mt-2 px-4 py-2 bg-blue-
|
|
129
|
+
className="mt-2 px-4 py-2 bg-blue-600 text-white rounded"
|
|
130
130
|
onClick={() =>
|
|
131
131
|
createDatasheet.mutate({ chip_name: searchQuery })
|
|
132
132
|
}
|
package/src/pages/latest.tsx
CHANGED
|
@@ -58,9 +58,9 @@ const LatestPage: React.FC = () => {
|
|
|
58
58
|
?.sort((a, b) => b.created_at.localeCompare(a.created_at))
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
|
-
<div className="min-h-screen flex flex-col
|
|
61
|
+
<div className="min-h-screen flex flex-col">
|
|
62
62
|
<Header />
|
|
63
|
-
<main className="flex-grow container mx-auto px-4 py-8">
|
|
63
|
+
<main className="flex-grow container mx-auto px-4 py-8 min-h-[80vh]">
|
|
64
64
|
<div className="mb-8 max-w-3xl">
|
|
65
65
|
<div className="flex items-center gap-2 mb-3">
|
|
66
66
|
<h1 className="text-4xl font-bold text-gray-900">
|
package/src/pages/search.tsx
CHANGED
|
@@ -91,7 +91,7 @@ export const SearchPage = () => {
|
|
|
91
91
|
return (
|
|
92
92
|
<div className="min-h-screen flex flex-col">
|
|
93
93
|
<Header />
|
|
94
|
-
<main className="flex-grow
|
|
94
|
+
<main className="flex-grow pb-12 min-h-[80vh]">
|
|
95
95
|
<div className="container mx-auto px-4 py-8">
|
|
96
96
|
<div className="max-w-8xl mx-auto">
|
|
97
97
|
<div className="mb-6">
|
package/src/pages/trending.tsx
CHANGED
|
@@ -87,9 +87,9 @@ const TrendingPage: React.FC = () => {
|
|
|
87
87
|
})
|
|
88
88
|
|
|
89
89
|
return (
|
|
90
|
-
<div className="min-h-screen flex flex-col
|
|
90
|
+
<div className="min-h-screen flex flex-col">
|
|
91
91
|
<Header />
|
|
92
|
-
<main className="flex-grow container mx-auto px-4 py-8">
|
|
92
|
+
<main className="flex-grow container mx-auto px-4 py-8 min-h-[80vh]">
|
|
93
93
|
<div className="mb-8 max-w-3xl">
|
|
94
94
|
<h1 className="text-4xl font-bold text-gray-900 mb-3">
|
|
95
95
|
Trending Packages
|
package/vite.config.ts
CHANGED