@tscircuit/fake-snippets 0.0.100 → 0.0.101
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 +2 -2
- package/dist/bundle.js +456 -411
- package/dist/index.d.ts +4 -2
- package/dist/index.js +25 -0
- package/fake-snippets-api/lib/db/db-client.ts +32 -0
- package/fake-snippets-api/routes/api/accounts/search.ts +20 -0
- package/package.json +2 -2
- package/src/components/CmdKMenu.tsx +154 -19
- package/src/components/Header2.tsx +106 -25
- package/src/components/PackageBuildsPage/package-build-header.tsx +19 -15
- package/src/components/ViewPackagePage/components/important-files-view.tsx +18 -13
- package/src/components/package-port/CodeEditorHeader.tsx +20 -16
- package/src/pages/landing.tsx +1 -1
|
@@ -4,9 +4,11 @@ import { useRebuildPackageReleaseMutation } from "@/hooks/use-rebuild-package-re
|
|
|
4
4
|
import { Github, RefreshCw } from "lucide-react"
|
|
5
5
|
import { useParams } from "wouter"
|
|
6
6
|
import { DownloadButtonAndMenu } from "../DownloadButtonAndMenu"
|
|
7
|
+
import { useGlobalStore } from "@/hooks/use-global-store"
|
|
7
8
|
|
|
8
9
|
export function PackageBuildHeader() {
|
|
9
10
|
const { author, packageName } = useParams()
|
|
11
|
+
const session = useGlobalStore((s) => s.session)
|
|
10
12
|
const { packageRelease } = useCurrentPackageRelease({
|
|
11
13
|
include_logs: true,
|
|
12
14
|
})
|
|
@@ -44,21 +46,23 @@ export function PackageBuildHeader() {
|
|
|
44
46
|
<span className="xs:hidden">Report</span>
|
|
45
47
|
</a>
|
|
46
48
|
</Button>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
{session?.github_username == author && (
|
|
50
|
+
<Button
|
|
51
|
+
variant="outline"
|
|
52
|
+
size="sm"
|
|
53
|
+
className="border-gray-300 bg-white hover:bg-gray-50 text-xs sm:text-sm"
|
|
54
|
+
disabled={isLoading || !packageRelease}
|
|
55
|
+
onClick={() =>
|
|
56
|
+
packageRelease &&
|
|
57
|
+
rebuildPackage({
|
|
58
|
+
package_release_id: packageRelease.package_release_id,
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
>
|
|
62
|
+
<RefreshCw className="w-3 h-3 sm:w-4 sm:h-4 mr-1 sm:mr-2" />
|
|
63
|
+
{isLoading ? "Rebuilding..." : "Rebuild"}
|
|
64
|
+
</Button>
|
|
65
|
+
)}
|
|
62
66
|
<DownloadButtonAndMenu unscopedName={packageName} author={author} />
|
|
63
67
|
</div>
|
|
64
68
|
</div>
|
|
@@ -17,6 +17,7 @@ import { usePackageFile } from "@/hooks/use-package-files"
|
|
|
17
17
|
import { ShikiCodeViewer } from "./ShikiCodeViewer"
|
|
18
18
|
import MarkdownViewer from "./markdown-viewer"
|
|
19
19
|
import { useGlobalStore } from "@/hooks/use-global-store"
|
|
20
|
+
import { useCurrentPackageCircuitJson } from "../hooks/use-current-package-circuit-json"
|
|
20
21
|
|
|
21
22
|
interface PackageFile {
|
|
22
23
|
package_file_id: string
|
|
@@ -129,14 +130,12 @@ export default function ImportantFilesView({
|
|
|
129
130
|
const availableTabs = useMemo((): TabInfo[] => {
|
|
130
131
|
const tabs: TabInfo[] = []
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
})
|
|
139
|
-
}
|
|
133
|
+
tabs.push({
|
|
134
|
+
type: "ai",
|
|
135
|
+
filePath: null,
|
|
136
|
+
label: "Description",
|
|
137
|
+
icon: <SparklesIcon className="h-3.5 w-3.5 mr-1.5" />,
|
|
138
|
+
})
|
|
140
139
|
|
|
141
140
|
tabs.push({
|
|
142
141
|
type: "ai-review",
|
|
@@ -266,6 +265,8 @@ export default function ImportantFilesView({
|
|
|
266
265
|
}
|
|
267
266
|
}, [activeTab, importantFiles, getDefaultTab])
|
|
268
267
|
|
|
268
|
+
const { circuitJson } = useCurrentPackageCircuitJson()
|
|
269
|
+
|
|
269
270
|
// Get active file content
|
|
270
271
|
const partialActiveFile = useMemo(() => {
|
|
271
272
|
if (activeTab?.type !== "file" || !activeTab.filePath) return null
|
|
@@ -321,7 +322,15 @@ export default function ImportantFilesView({
|
|
|
321
322
|
from our AI assistant.
|
|
322
323
|
</p>
|
|
323
324
|
</div>
|
|
324
|
-
{isOwner ? (
|
|
325
|
+
{!isOwner ? (
|
|
326
|
+
<p className="text-sm text-gray-500">
|
|
327
|
+
Only the package owner can generate an AI review
|
|
328
|
+
</p>
|
|
329
|
+
) : !Boolean(circuitJson) ? (
|
|
330
|
+
<p className="text-sm text-gray-500">
|
|
331
|
+
Circuit JSON is required for AI review.
|
|
332
|
+
</p>
|
|
333
|
+
) : (
|
|
325
334
|
<Button
|
|
326
335
|
onClick={onRequestAiReview}
|
|
327
336
|
size="sm"
|
|
@@ -330,10 +339,6 @@ export default function ImportantFilesView({
|
|
|
330
339
|
<SparklesIcon className="h-4 w-4 mr-2" />
|
|
331
340
|
Request AI Review
|
|
332
341
|
</Button>
|
|
333
|
-
) : (
|
|
334
|
-
<p className="text-sm text-gray-500">
|
|
335
|
-
Only the package owner can generate an AI review
|
|
336
|
-
</p>
|
|
337
342
|
)}
|
|
338
343
|
</div>
|
|
339
344
|
</div>
|
|
@@ -162,22 +162,26 @@ export const CodeEditorHeader: React.FC<CodeEditorHeaderProps> = ({
|
|
|
162
162
|
if (!session?.token) {
|
|
163
163
|
throw new Error("You need to be logged in to import jlcpcb component")
|
|
164
164
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
165
|
+
|
|
166
|
+
const jlcpcbComponent = await fetchEasyEDAComponent(
|
|
167
|
+
component.partNumber ?? component.name,
|
|
168
|
+
{
|
|
169
|
+
fetch: ((url, options: any) => {
|
|
170
|
+
return fetch(`${API_BASE}/proxy`, {
|
|
171
|
+
body: options.body,
|
|
172
|
+
method: options.method,
|
|
173
|
+
headers: {
|
|
174
|
+
authority: options.headers.authority,
|
|
175
|
+
Authorization: `Bearer ${session?.token}`,
|
|
176
|
+
"X-Target-Url": url.toString(),
|
|
177
|
+
"X-Sender-Host": options.headers.origin,
|
|
178
|
+
"X-Sender-Origin": options.headers.origin,
|
|
179
|
+
"content-type": options.headers["content-type"],
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
}) as typeof fetch,
|
|
183
|
+
},
|
|
184
|
+
)
|
|
181
185
|
const tsxComponent = await convertRawEasyToTsx(jlcpcbComponent)
|
|
182
186
|
let componentName = component.name.replace(/ /g, "-")
|
|
183
187
|
if (files[`${componentName}.tsx`] || files[`./${componentName}.tsx`]) {
|