@tscircuit/fake-snippets 0.0.119 → 0.0.120
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-tests/fake-snippets-api/routes/bug_reports/create.test.ts +37 -0
- package/bun-tests/fake-snippets-api/routes/bug_reports/upload_file.test.ts +89 -0
- package/bun.lock +2 -2
- package/dist/bundle.js +758 -504
- package/dist/index.d.ts +131 -6
- package/dist/index.js +90 -1
- package/dist/schema.d.ts +177 -7
- package/dist/schema.js +29 -1
- package/fake-snippets-api/lib/db/db-client.ts +89 -0
- package/fake-snippets-api/lib/db/schema.ts +29 -0
- package/fake-snippets-api/routes/api/bug_reports/create.ts +43 -0
- package/fake-snippets-api/routes/api/bug_reports/upload_file.ts +113 -0
- package/package.json +2 -2
- package/src/components/Header.tsx +16 -0
- package/src/components/PackageCard.tsx +7 -4
- package/src/components/PackageSearchResults.tsx +1 -7
- package/src/components/SearchComponent.tsx +64 -53
- package/src/components/TrendingPackagesCarousel.tsx +16 -23
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +3 -2
- package/src/components/ViewPackagePage/components/preview-image-squares.tsx +6 -3
- package/src/hooks/use-preview-images.ts +22 -17
- package/src/hooks/useUpdatePackageFilesMutation.ts +8 -0
- package/src/lib/utils/getPackagePreviewImageUrl.ts +15 -0
- package/src/pages/dashboard.tsx +0 -1
- package/src/pages/editor.tsx +12 -9
- package/src/pages/organization-profile.tsx +0 -1
- package/src/pages/package-editor.tsx +13 -9
- package/src/pages/user-profile.tsx +0 -1
|
@@ -1,46 +1,50 @@
|
|
|
1
|
-
import { useState } from "react"
|
|
1
|
+
import { useEffect, useState } from "react"
|
|
2
2
|
|
|
3
3
|
interface UsePreviewImagesProps {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
cadPreviewUrl?: string | null
|
|
5
|
+
pcbPreviewUrl?: string | null
|
|
6
|
+
schematicPreviewUrl?: string | null
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export function usePreviewImages({
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
cadPreviewUrl,
|
|
11
|
+
pcbPreviewUrl,
|
|
12
|
+
schematicPreviewUrl,
|
|
11
13
|
}: UsePreviewImagesProps) {
|
|
12
14
|
const [imageStatus, setImageStatus] = useState<
|
|
13
15
|
Record<string, "loading" | "loaded" | "error">
|
|
14
16
|
>({
|
|
15
|
-
"3d": "loading",
|
|
16
|
-
pcb: "loading",
|
|
17
|
-
schematic: "loading",
|
|
17
|
+
"3d": cadPreviewUrl ? "loading" : "error",
|
|
18
|
+
pcb: pcbPreviewUrl ? "loading" : "error",
|
|
19
|
+
schematic: schematicPreviewUrl ? "loading" : "error",
|
|
18
20
|
})
|
|
19
21
|
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
setImageStatus({
|
|
24
|
+
"3d": cadPreviewUrl ? "loading" : "error",
|
|
25
|
+
pcb: pcbPreviewUrl ? "loading" : "error",
|
|
26
|
+
schematic: schematicPreviewUrl ? "loading" : "error",
|
|
27
|
+
})
|
|
28
|
+
}, [cadPreviewUrl, pcbPreviewUrl, schematicPreviewUrl])
|
|
29
|
+
|
|
20
30
|
const views = [
|
|
21
31
|
{
|
|
22
32
|
id: "3d",
|
|
23
33
|
label: "3D View",
|
|
24
34
|
backgroundClass: "bg-gray-100",
|
|
25
|
-
imageUrl:
|
|
26
|
-
? `https://api.tscircuit.com/packages/images/${packageName}/3d.png?fs_sha=${fsMapHash}`
|
|
27
|
-
: undefined,
|
|
35
|
+
imageUrl: cadPreviewUrl ?? undefined,
|
|
28
36
|
},
|
|
29
37
|
{
|
|
30
38
|
id: "pcb",
|
|
31
39
|
label: "PCB View",
|
|
32
40
|
backgroundClass: "bg-black",
|
|
33
|
-
imageUrl:
|
|
34
|
-
? `https://api.tscircuit.com/packages/images/${packageName}/pcb.png?fs_sha=${fsMapHash}`
|
|
35
|
-
: undefined,
|
|
41
|
+
imageUrl: pcbPreviewUrl ?? undefined,
|
|
36
42
|
},
|
|
37
43
|
{
|
|
38
44
|
id: "schematic",
|
|
39
45
|
label: "Schematic View",
|
|
40
46
|
backgroundClass: "bg-[#F5F1ED]",
|
|
41
|
-
imageUrl:
|
|
42
|
-
? `https://api.tscircuit.com/packages/images/${packageName}/schematic.png?fs_sha=${fsMapHash}`
|
|
43
|
-
: undefined,
|
|
47
|
+
imageUrl: schematicPreviewUrl ?? undefined,
|
|
44
48
|
},
|
|
45
49
|
]
|
|
46
50
|
|
|
@@ -59,6 +63,7 @@ export function usePreviewImages({
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
const availableViews = views
|
|
66
|
+
.filter((view) => Boolean(view.imageUrl))
|
|
62
67
|
.map((view) => ({
|
|
63
68
|
...view,
|
|
64
69
|
status: imageStatus[view.id],
|
|
@@ -88,6 +88,14 @@ export function useUpdatePackageFilesMutation({
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
if (!currentPackage) {
|
|
93
|
+
await axios.post("/package_releases/update", {
|
|
94
|
+
package_name_with_version: newPackage.package_name_with_version,
|
|
95
|
+
ready_to_build: true,
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
91
99
|
return updatedFilesCount
|
|
92
100
|
},
|
|
93
101
|
onSuccess: (updatedFilesCount) => {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Package } from "fake-snippets-api/lib/db/schema"
|
|
2
|
+
|
|
3
|
+
export const getPackagePreviewImageUrl = (
|
|
4
|
+
pkg: Package,
|
|
5
|
+
view: "pcb" | "schematic" | "3d" = "pcb",
|
|
6
|
+
) => {
|
|
7
|
+
switch (view) {
|
|
8
|
+
case "schematic":
|
|
9
|
+
return pkg.latest_sch_preview_image_url
|
|
10
|
+
case "3d":
|
|
11
|
+
return pkg.latest_cad_preview_image_url
|
|
12
|
+
default:
|
|
13
|
+
return pkg.latest_pcb_preview_image_url
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/pages/dashboard.tsx
CHANGED
package/src/pages/editor.tsx
CHANGED
|
@@ -8,6 +8,11 @@ export const EditorPage = () => {
|
|
|
8
8
|
const { packageInfo: pkg, error } = useCurrentPackageInfo()
|
|
9
9
|
|
|
10
10
|
const projectUrl = pkg ? `https://tscircuit.com/${pkg.name}` : undefined
|
|
11
|
+
const previewImageUrl =
|
|
12
|
+
pkg?.latest_pcb_preview_image_url ??
|
|
13
|
+
pkg?.latest_sch_preview_image_url ??
|
|
14
|
+
pkg?.latest_cad_preview_image_url ??
|
|
15
|
+
undefined
|
|
11
16
|
|
|
12
17
|
return (
|
|
13
18
|
<div className="overflow-x-hidden">
|
|
@@ -21,15 +26,13 @@ export const EditorPage = () => {
|
|
|
21
26
|
property="og:title"
|
|
22
27
|
content={`${pkg.unscoped_name} - tscircuit`}
|
|
23
28
|
/>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
content={`https://api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png?fs_sha=${pkg.latest_package_release_fs_sha}`}
|
|
32
|
-
/>
|
|
29
|
+
{previewImageUrl && (
|
|
30
|
+
<>
|
|
31
|
+
<meta property="og:image" content={previewImageUrl} />
|
|
32
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
33
|
+
<meta name="twitter:image" content={previewImageUrl} />
|
|
34
|
+
</>
|
|
35
|
+
)}
|
|
33
36
|
</>
|
|
34
37
|
)}
|
|
35
38
|
</Helmet>
|
|
@@ -12,6 +12,12 @@ export const EditorPage = () => {
|
|
|
12
12
|
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/,
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
+
const previewImageUrl =
|
|
16
|
+
pkg?.latest_pcb_preview_image_url ??
|
|
17
|
+
pkg?.latest_sch_preview_image_url ??
|
|
18
|
+
pkg?.latest_cad_preview_image_url ??
|
|
19
|
+
undefined
|
|
20
|
+
|
|
15
21
|
return (
|
|
16
22
|
<div className="flex flex-col h-screen overflow-x-hidden">
|
|
17
23
|
<Helmet>
|
|
@@ -22,15 +28,13 @@ export const EditorPage = () => {
|
|
|
22
28
|
property="og:title"
|
|
23
29
|
content={`${pkg.unscoped_name} - tscircuit`}
|
|
24
30
|
/>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
content={`https://api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png?fs_sha=${pkg.latest_package_release_fs_sha}`}
|
|
33
|
-
/>
|
|
31
|
+
{previewImageUrl && (
|
|
32
|
+
<>
|
|
33
|
+
<meta property="og:image" content={previewImageUrl} />
|
|
34
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
35
|
+
<meta name="twitter:image" content={previewImageUrl} />
|
|
36
|
+
</>
|
|
37
|
+
)}
|
|
34
38
|
</>
|
|
35
39
|
)}
|
|
36
40
|
</Helmet>
|