@tscircuit/fake-snippets 0.0.72 → 0.0.73
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 +33 -17
- package/dist/bundle.js +53 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +47 -1
- package/dist/schema.d.ts +8 -0
- package/dist/schema.js +1 -0
- package/fake-snippets-api/lib/db/db-client.ts +47 -0
- package/fake-snippets-api/lib/db/schema.ts +1 -0
- package/fake-snippets-api/lib/package_file/generate-fs-sha.ts +20 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package.ts +1 -0
- package/fake-snippets-api/routes/api/package_files/create.ts +3 -0
- package/fake-snippets-api/routes/api/package_files/create_or_update.ts +6 -0
- package/fake-snippets-api/routes/api/package_files/delete.ts +3 -0
- package/fake-snippets-api/routes/api/packages/create.ts +1 -0
- package/package.json +7 -7
- package/src/App.tsx +5 -0
- package/src/components/JLCPCBImportDialog.tsx +1 -1
- package/src/components/PackageBuildsPage/DeploymentDetailsPage.tsx +56 -0
- package/src/components/PackageBuildsPage/build-preview-content.tsx +11 -0
- package/src/components/PackageBuildsPage/collapsible-section.tsx +70 -0
- package/src/components/PackageBuildsPage/deployment-details-panel.tsx +84 -0
- package/src/components/PackageBuildsPage/deployment-header.tsx +75 -0
- package/src/components/PackageCard.tsx +1 -10
- package/src/components/TrendingPackagesCarousel.tsx +5 -16
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +1 -1
- package/src/components/ViewPackagePage/components/preview-image-squares.tsx +2 -6
- package/src/components/package-port/CodeEditor.tsx +1 -1
- package/src/components/package-port/EditorNav.tsx +17 -13
- package/src/hooks/use-current-package-id.ts +2 -8
- package/src/hooks/use-preview-images.ts +3 -15
- package/src/lib/utils/checkIfManualEditsImported.ts +9 -0
- package/src/pages/editor.tsx +2 -10
- package/src/pages/package-builds.tsx +33 -0
- package/src/pages/package-editor.tsx +2 -14
- package/src/hooks/use-get-fsmap-hash-for-package.ts +0 -19
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Globe, GitBranch, GitCommit, Clock } from "lucide-react"
|
|
2
|
+
import { Badge } from "@/components/ui/badge"
|
|
3
|
+
|
|
4
|
+
export function DeploymentDetailsPanel() {
|
|
5
|
+
return (
|
|
6
|
+
<div className="space-y-6 bg-white p-4 border border-gray-200 rounded-lg">
|
|
7
|
+
{/* Created */}
|
|
8
|
+
<div>
|
|
9
|
+
<h3 className="text-sm font-medium text-gray-600 mb-2">Created</h3>
|
|
10
|
+
<div className="flex items-center gap-2">
|
|
11
|
+
<div className="w-6 h-6 bg-orange-500 rounded-full flex items-center justify-center text-xs font-bold">
|
|
12
|
+
I
|
|
13
|
+
</div>
|
|
14
|
+
<span className="text-sm">imrishabh18</span>
|
|
15
|
+
<span className="text-sm text-gray-500">48m ago</span>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
{/* Status */}
|
|
20
|
+
<div>
|
|
21
|
+
<h3 className="text-sm font-medium text-gray-600 mb-2">Status</h3>
|
|
22
|
+
<div className="flex items-center gap-2">
|
|
23
|
+
<div className="w-2 h-2 bg-green-500 rounded-full"></div>
|
|
24
|
+
<span className="text-sm">Ready</span>
|
|
25
|
+
<Badge
|
|
26
|
+
variant="secondary"
|
|
27
|
+
className="bg-gray-200 text-gray-700 text-xs"
|
|
28
|
+
>
|
|
29
|
+
Latest
|
|
30
|
+
</Badge>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
{/* Time to Ready */}
|
|
35
|
+
<div>
|
|
36
|
+
<h3 className="text-sm font-medium text-gray-600 mb-2">
|
|
37
|
+
Time to Ready
|
|
38
|
+
</h3>
|
|
39
|
+
<div className="flex items-center gap-2">
|
|
40
|
+
<Clock className="w-4 h-4 text-gray-500" />
|
|
41
|
+
<span className="text-sm">1m 3s</span>
|
|
42
|
+
<span className="text-sm text-gray-500">47m ago</span>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
{/* Version */}
|
|
47
|
+
<div>
|
|
48
|
+
<h3 className="text-sm font-medium text-gray-600 mb-2">Version</h3>
|
|
49
|
+
<div className="flex items-center gap-2">
|
|
50
|
+
<Globe className="w-4 h-4 text-gray-500" />
|
|
51
|
+
<span className="text-sm">v1.0.3</span>
|
|
52
|
+
<Badge variant="default" className="bg-blue-600 text-white text-xs">
|
|
53
|
+
Current
|
|
54
|
+
</Badge>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
{/* Outputs */}
|
|
59
|
+
<div>
|
|
60
|
+
<h3 className="text-sm font-medium text-gray-600 mb-2">Outputs</h3>
|
|
61
|
+
<div>
|
|
62
|
+
<span className="text-sm text-gray-400">None</span>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
{/* Source */}
|
|
67
|
+
<div>
|
|
68
|
+
<h3 className="text-sm font-medium text-gray-600 mb-2">Source</h3>
|
|
69
|
+
<div className="space-y-2">
|
|
70
|
+
<div className="flex items-center gap-2">
|
|
71
|
+
<GitBranch className="w-4 h-4 text-gray-500" />
|
|
72
|
+
<span className="text-sm">main</span>
|
|
73
|
+
</div>
|
|
74
|
+
<div className="flex items-center gap-2">
|
|
75
|
+
<GitCommit className="w-4 h-4 text-gray-500" />
|
|
76
|
+
<span className="text-sm text-gray-500">
|
|
77
|
+
edfdc67 support empty file creation (#356)
|
|
78
|
+
</span>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ChevronDown, Download, Github, Link } from "lucide-react"
|
|
2
|
+
import { Button } from "@/components/ui/button"
|
|
3
|
+
import {
|
|
4
|
+
DropdownMenu,
|
|
5
|
+
DropdownMenuContent,
|
|
6
|
+
DropdownMenuItem,
|
|
7
|
+
DropdownMenuTrigger,
|
|
8
|
+
} from "@/components/ui/dropdown-menu"
|
|
9
|
+
import { useParams } from "wouter"
|
|
10
|
+
|
|
11
|
+
export function DeploymentHeader() {
|
|
12
|
+
const { author, packageName } = useParams()
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="border-b border-gray-200 bg-white px-6 py-4">
|
|
16
|
+
<div className="flex items-center justify-between container mx-auto">
|
|
17
|
+
<h1 className="text-2xl font-semibold">
|
|
18
|
+
Package Build
|
|
19
|
+
<a
|
|
20
|
+
className="ml-2 bg-gray-100 px-2 py-1 rounded font-mono text-blue-600"
|
|
21
|
+
href={`/${author}/${packageName}`}
|
|
22
|
+
>
|
|
23
|
+
{author}/{packageName}
|
|
24
|
+
</a>
|
|
25
|
+
</h1>
|
|
26
|
+
<div className="flex items-center gap-3">
|
|
27
|
+
<Button
|
|
28
|
+
variant="outline"
|
|
29
|
+
size="sm"
|
|
30
|
+
className="border-gray-300 bg-white hover:bg-gray-50 text-xs sm:text-sm"
|
|
31
|
+
asChild
|
|
32
|
+
>
|
|
33
|
+
<a
|
|
34
|
+
href="https://github.com/tscircuit/tscircuit.com/issues/new"
|
|
35
|
+
target="_blank"
|
|
36
|
+
rel="noopener noreferrer"
|
|
37
|
+
>
|
|
38
|
+
<Github className="w-3 h-3 sm:w-4 sm:h-4 mr-1 sm:mr-2" />
|
|
39
|
+
Report Issue
|
|
40
|
+
</a>
|
|
41
|
+
</Button>
|
|
42
|
+
<DropdownMenu>
|
|
43
|
+
<DropdownMenuTrigger asChild>
|
|
44
|
+
<Button
|
|
45
|
+
size="sm"
|
|
46
|
+
className="bg-gray-900 text-white hover:bg-gray-800"
|
|
47
|
+
>
|
|
48
|
+
<Download className="w-4 h-4 mr-2" />
|
|
49
|
+
Download
|
|
50
|
+
<ChevronDown className="w-4 h-4 ml-2" />
|
|
51
|
+
</Button>
|
|
52
|
+
</DropdownMenuTrigger>
|
|
53
|
+
<DropdownMenuContent
|
|
54
|
+
align="end"
|
|
55
|
+
className="bg-white border-gray-200"
|
|
56
|
+
>
|
|
57
|
+
<DropdownMenuItem className="text-gray-900 hover:bg-gray-100">
|
|
58
|
+
Circuit JSON
|
|
59
|
+
</DropdownMenuItem>
|
|
60
|
+
<DropdownMenuItem className="text-gray-900 hover:bg-gray-100">
|
|
61
|
+
PCB SVG
|
|
62
|
+
</DropdownMenuItem>
|
|
63
|
+
<DropdownMenuItem className="text-gray-900 hover:bg-gray-100">
|
|
64
|
+
Schematic SVG
|
|
65
|
+
</DropdownMenuItem>
|
|
66
|
+
<DropdownMenuItem className="text-gray-900 hover:bg-gray-100">
|
|
67
|
+
3D Model (stl)
|
|
68
|
+
</DropdownMenuItem>
|
|
69
|
+
</DropdownMenuContent>
|
|
70
|
+
</DropdownMenu>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from "@/components/ui/dropdown-menu"
|
|
13
13
|
import { SnippetType, SnippetTypeIcon } from "./SnippetTypeIcon"
|
|
14
14
|
import { timeAgo } from "@/lib/utils/timeAgo"
|
|
15
|
-
import { useGetFsMapHashForPackage } from "@/hooks/use-get-fsmap-hash-for-package"
|
|
16
15
|
import { ImageWithFallback } from "./ImageWithFallback"
|
|
17
16
|
|
|
18
17
|
export interface PackageCardProps {
|
|
@@ -57,10 +56,6 @@ export const PackageCard: React.FC<PackageCardProps> = ({
|
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
const fsMapHash = useGetFsMapHashForPackage(
|
|
61
|
-
pkg.latest_package_release_id ?? "",
|
|
62
|
-
)
|
|
63
|
-
|
|
64
59
|
const cardContent = (
|
|
65
60
|
<div
|
|
66
61
|
className={`border p-4 rounded-md hover:shadow-md transition-shadow flex flex-col gap-4 ${className}`}
|
|
@@ -70,11 +65,7 @@ export const PackageCard: React.FC<PackageCardProps> = ({
|
|
|
70
65
|
className={`${imageSize} flex-shrink-0 rounded-md overflow-hidden`}
|
|
71
66
|
>
|
|
72
67
|
<ImageWithFallback
|
|
73
|
-
src={`${baseUrl}/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.svg
|
|
74
|
-
{
|
|
75
|
-
fs_sha: fsMapHash ?? "",
|
|
76
|
-
},
|
|
77
|
-
).toString()}`}
|
|
68
|
+
src={`${baseUrl}/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.svg?fs_sha=${pkg.latest_package_release_fs_sha}`}
|
|
78
69
|
alt={`${pkg.unscoped_name} PCB image`}
|
|
79
70
|
className={`object-cover h-full w-full ${imageTransform}`}
|
|
80
71
|
/>
|
|
@@ -5,16 +5,11 @@ import { Link } from "wouter"
|
|
|
5
5
|
import { Package } from "fake-snippets-api/lib/db/schema"
|
|
6
6
|
import { useRef, useState } from "react"
|
|
7
7
|
import { useSnippetsBaseApiUrl } from "@/hooks/use-snippets-base-api-url"
|
|
8
|
-
import { useGetFsMapHashForPackage } from "@/hooks/use-get-fsmap-hash-for-package"
|
|
9
8
|
|
|
10
9
|
const CarouselItem = ({
|
|
11
10
|
pkg,
|
|
12
11
|
apiBaseUrl,
|
|
13
12
|
}: { pkg: Package; apiBaseUrl: string }) => {
|
|
14
|
-
const fsMapHash = useGetFsMapHashForPackage(
|
|
15
|
-
pkg.latest_package_release_id ?? "",
|
|
16
|
-
)
|
|
17
|
-
|
|
18
13
|
return (
|
|
19
14
|
<Link href={`/${pkg.owner_github_username}/${pkg.unscoped_name}`}>
|
|
20
15
|
<div className="flex-shrink-0 w-[200px] bg-white p-3 py-2 rounded-lg shadow-sm border border-gray-200 hover:border-gray-300 transition-colors">
|
|
@@ -22,17 +17,11 @@ const CarouselItem = ({
|
|
|
22
17
|
{pkg.owner_github_username}/{pkg.unscoped_name}
|
|
23
18
|
</div>
|
|
24
19
|
<div className="mb-2 h-24 w-full bg-black rounded overflow-hidden">
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
).toString()}`}
|
|
32
|
-
alt="PCB preview"
|
|
33
|
-
className="w-full h-full object-contain p-2 scale-[3] rotate-45 hover:scale-[3.5] transition-transform"
|
|
34
|
-
/>
|
|
35
|
-
)}
|
|
20
|
+
<img
|
|
21
|
+
src={`${apiBaseUrl}/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.svg?fs_map=${pkg.latest_package_release_fs_sha}`}
|
|
22
|
+
alt="PCB preview"
|
|
23
|
+
className="w-full h-full object-contain p-2 scale-[3] rotate-45 hover:scale-[3.5] transition-transform"
|
|
24
|
+
/>
|
|
36
25
|
</div>
|
|
37
26
|
<div className="flex items-center text-xs text-gray-500">
|
|
38
27
|
<StarFilledIcon className="w-3 h-3 mr-1" />
|
|
@@ -72,7 +72,7 @@ const MobileSidebar = ({
|
|
|
72
72
|
|
|
73
73
|
const { availableViews } = usePreviewImages({
|
|
74
74
|
packageName: packageInfo?.name,
|
|
75
|
-
fsMapHash: packageInfo?.
|
|
75
|
+
fsMapHash: packageInfo?.latest_package_release_fs_sha ?? "",
|
|
76
76
|
})
|
|
77
77
|
|
|
78
78
|
const handleViewClick = useCallback(
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { Skeleton } from "@/components/ui/skeleton"
|
|
3
|
-
import { useGetFsMapHashForPackage } from "@/hooks/use-get-fsmap-hash-for-package"
|
|
4
3
|
import { usePreviewImages } from "@/hooks/use-preview-images"
|
|
5
4
|
import type { Package } from "fake-snippets-api/lib/db/schema"
|
|
6
5
|
|
|
7
6
|
interface ViewPlaceholdersProps {
|
|
8
|
-
packageInfo?: Pick<Package, "name" | "
|
|
7
|
+
packageInfo?: Pick<Package, "name" | "latest_package_release_fs_sha">
|
|
9
8
|
onViewChange?: (view: "3d" | "pcb" | "schematic") => void
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -13,12 +12,9 @@ export default function PreviewImageSquares({
|
|
|
13
12
|
packageInfo,
|
|
14
13
|
onViewChange,
|
|
15
14
|
}: ViewPlaceholdersProps) {
|
|
16
|
-
const fsMapHash = useGetFsMapHashForPackage(
|
|
17
|
-
packageInfo?.latest_package_release_id ?? "",
|
|
18
|
-
)
|
|
19
15
|
const { availableViews } = usePreviewImages({
|
|
20
16
|
packageName: packageInfo?.name,
|
|
21
|
-
fsMapHash:
|
|
17
|
+
fsMapHash: packageInfo?.latest_package_release_fs_sha ?? "",
|
|
22
18
|
})
|
|
23
19
|
|
|
24
20
|
const handleViewClick = (viewId: string) => {
|
|
@@ -207,19 +207,23 @@ export default function EditorNav({
|
|
|
207
207
|
<div className="flex items-center space-x-1">
|
|
208
208
|
{pkg && (
|
|
209
209
|
<>
|
|
210
|
-
<
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
className="text-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
210
|
+
<div className="flex items-center space-x-1 overflow-hidden">
|
|
211
|
+
<Link
|
|
212
|
+
className="text-blue-500 font-semibold hover:underline truncate"
|
|
213
|
+
href={`/${pkg.owner_github_username}`}
|
|
214
|
+
title={pkg.owner_github_username || ""}
|
|
215
|
+
>
|
|
216
|
+
{pkg.owner_github_username}
|
|
217
|
+
</Link>
|
|
218
|
+
<span className="px-0.5 text-gray-500">/</span>
|
|
219
|
+
<Link
|
|
220
|
+
className="text-blue-500 font-semibold hover:underline truncate"
|
|
221
|
+
href={`/${pkg.name}`}
|
|
222
|
+
title={pkg.unscoped_name}
|
|
223
|
+
>
|
|
224
|
+
{pkg.unscoped_name}
|
|
225
|
+
</Link>
|
|
226
|
+
</div>
|
|
223
227
|
{pkg.star_count !== undefined && (
|
|
224
228
|
<span className="ml-2 text-gray-500 text-xs flex items-center">
|
|
225
229
|
<Star className="w-3 h-3 mr-1" />
|
|
@@ -31,17 +31,11 @@ export const useCurrentPackageId = (): {
|
|
|
31
31
|
error: errorPackageByName,
|
|
32
32
|
} = usePackageByName(packageName)
|
|
33
33
|
|
|
34
|
-
const {
|
|
35
|
-
data: packageById,
|
|
36
|
-
isLoading: isLoadingPackageById,
|
|
37
|
-
error: errorPackageById,
|
|
38
|
-
} = usePackageById(packageIdFromUrl)
|
|
39
|
-
|
|
40
34
|
const packageId = packageIdFromUrl ?? packageByName?.package_id ?? null
|
|
41
35
|
|
|
42
36
|
return {
|
|
43
37
|
packageId,
|
|
44
|
-
isLoading: isLoadingPackageByName
|
|
45
|
-
error: errorPackageByName
|
|
38
|
+
isLoading: isLoadingPackageByName,
|
|
39
|
+
error: errorPackageByName,
|
|
46
40
|
}
|
|
47
41
|
}
|
|
@@ -22,33 +22,21 @@ export function usePreviewImages({
|
|
|
22
22
|
id: "3d",
|
|
23
23
|
label: "3D View",
|
|
24
24
|
imageUrl: packageName
|
|
25
|
-
? `https://registry-api.tscircuit.com/packages/images/${packageName}/3d.png
|
|
26
|
-
{
|
|
27
|
-
fs_sha: fsMapHash ?? "",
|
|
28
|
-
},
|
|
29
|
-
).toString()}`
|
|
25
|
+
? `https://registry-api.tscircuit.com/packages/images/${packageName}/3d.png?fs_sha=${fsMapHash}`
|
|
30
26
|
: undefined,
|
|
31
27
|
},
|
|
32
28
|
{
|
|
33
29
|
id: "pcb",
|
|
34
30
|
label: "PCB View",
|
|
35
31
|
imageUrl: packageName
|
|
36
|
-
? `https://registry-api.tscircuit.com/packages/images/${packageName}/pcb.png
|
|
37
|
-
{
|
|
38
|
-
fs_sha: fsMapHash ?? "",
|
|
39
|
-
},
|
|
40
|
-
).toString()}`
|
|
32
|
+
? `https://registry-api.tscircuit.com/packages/images/${packageName}/pcb.png?fs_sha=${fsMapHash}`
|
|
41
33
|
: undefined,
|
|
42
34
|
},
|
|
43
35
|
{
|
|
44
36
|
id: "schematic",
|
|
45
37
|
label: "Schematic View",
|
|
46
38
|
imageUrl: packageName
|
|
47
|
-
? `https://registry-api.tscircuit.com/packages/images/${packageName}/schematic.png
|
|
48
|
-
{
|
|
49
|
-
fs_sha: fsMapHash ?? "",
|
|
50
|
-
},
|
|
51
|
-
).toString()}`
|
|
39
|
+
? `https://registry-api.tscircuit.com/packages/images/${packageName}/schematic.png?fs_sha=${fsMapHash}`
|
|
52
40
|
: undefined,
|
|
53
41
|
},
|
|
54
42
|
]
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { findTargetFile } from "./findTargetFile"
|
|
2
|
+
|
|
1
3
|
export const checkIfManualEditsImported = (
|
|
2
4
|
files: Record<string, string>,
|
|
3
5
|
file: string = "index.tsx",
|
|
4
6
|
) => {
|
|
5
7
|
if (!files[file]) return false
|
|
8
|
+
const targetFile = findTargetFile(
|
|
9
|
+
Object.keys(files).map((f) => ({ path: f, content: files[f] })),
|
|
10
|
+
null,
|
|
11
|
+
)
|
|
12
|
+
if (targetFile && file !== targetFile.path) {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
6
15
|
if (!file.endsWith(".tsx") && !file.endsWith(".ts")) return false
|
|
7
16
|
const importRegex =
|
|
8
17
|
/import\s+(?:\*\s+as\s+)?([a-zA-Z_$][\w$]*)\s+from\s+["'](?:\.\/)?manual-edits\.json["'];?/
|
package/src/pages/editor.tsx
CHANGED
|
@@ -4,14 +4,10 @@ import Header from "@/components/Header"
|
|
|
4
4
|
import { Helmet } from "react-helmet-async"
|
|
5
5
|
import { useCurrentPackageId } from "@/hooks/use-current-package-id"
|
|
6
6
|
import { usePackage } from "@/hooks/use-package"
|
|
7
|
-
import { useGetFsMapHashForPackage } from "@/hooks/use-get-fsmap-hash-for-package"
|
|
8
7
|
|
|
9
8
|
export const EditorPage = () => {
|
|
10
9
|
const { packageId } = useCurrentPackageId()
|
|
11
10
|
const { data: pkg, isLoading, error } = usePackage(packageId)
|
|
12
|
-
const fsMapHash = useGetFsMapHashForPackage(
|
|
13
|
-
pkg?.latest_package_release_id ?? "",
|
|
14
|
-
)
|
|
15
11
|
|
|
16
12
|
return (
|
|
17
13
|
<div className="overflow-x-hidden">
|
|
@@ -27,16 +23,12 @@ export const EditorPage = () => {
|
|
|
27
23
|
/>
|
|
28
24
|
<meta
|
|
29
25
|
property="og:image"
|
|
30
|
-
content={`https://registry-api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png
|
|
31
|
-
{
|
|
32
|
-
fs_sha: fsMapHash ?? "",
|
|
33
|
-
},
|
|
34
|
-
).toString()}`}
|
|
26
|
+
content={`https://registry-api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png?fs_sha=${pkg.latest_package_release_fs_sha}`}
|
|
35
27
|
/>
|
|
36
28
|
<meta name="twitter:card" content="summary_large_image" />
|
|
37
29
|
<meta
|
|
38
30
|
name="twitter:image"
|
|
39
|
-
content={`https://registry-api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png`}
|
|
31
|
+
content={`https://registry-api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png?fs_sha=${pkg.latest_package_release_fs_sha}`}
|
|
40
32
|
/>
|
|
41
33
|
</>
|
|
42
34
|
)}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CodeAndPreview } from "@/components/package-port/CodeAndPreview"
|
|
2
|
+
import Footer from "@/components/Footer"
|
|
3
|
+
import Header from "@/components/Header"
|
|
4
|
+
import { usePackage } from "@/hooks/use-package"
|
|
5
|
+
import { Helmet } from "react-helmet-async"
|
|
6
|
+
import { useCurrentPackageId } from "@/hooks/use-current-package-id"
|
|
7
|
+
import { NotFound } from "@/components/NotFound"
|
|
8
|
+
import { ErrorOutline } from "@/components/ErrorOutline"
|
|
9
|
+
import { DeploymentDetailsPage } from "@/components/PackageBuildsPage/DeploymentDetailsPage"
|
|
10
|
+
|
|
11
|
+
export const EditorPage = () => {
|
|
12
|
+
const { packageId } = useCurrentPackageId()
|
|
13
|
+
const { data: pkg, error } = usePackage(packageId)
|
|
14
|
+
const uuid4RegExp = new RegExp(
|
|
15
|
+
/^[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}$/,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="overflow-x-hidden">
|
|
20
|
+
<Helmet>
|
|
21
|
+
<title>{pkg ? `${pkg.name} Package Builds` : "Package Builds"}</title>
|
|
22
|
+
{pkg && (
|
|
23
|
+
<>
|
|
24
|
+
<meta property="og:title" content={`${pkg.name} Package Builds`} />
|
|
25
|
+
</>
|
|
26
|
+
)}
|
|
27
|
+
</Helmet>
|
|
28
|
+
<Header />
|
|
29
|
+
<DeploymentDetailsPage />
|
|
30
|
+
<Footer />
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -6,14 +6,10 @@ import { Helmet } from "react-helmet-async"
|
|
|
6
6
|
import { useCurrentPackageId } from "@/hooks/use-current-package-id"
|
|
7
7
|
import { NotFound } from "@/components/NotFound"
|
|
8
8
|
import { ErrorOutline } from "@/components/ErrorOutline"
|
|
9
|
-
import { useGetFsMapHashForPackage } from "@/hooks/use-get-fsmap-hash-for-package"
|
|
10
9
|
|
|
11
10
|
export const EditorPage = () => {
|
|
12
11
|
const { packageId } = useCurrentPackageId()
|
|
13
12
|
const { data: pkg, error } = usePackage(packageId)
|
|
14
|
-
const fsMapHash = useGetFsMapHashForPackage(
|
|
15
|
-
pkg?.latest_package_release_id ?? "",
|
|
16
|
-
)
|
|
17
13
|
const uuid4RegExp = new RegExp(
|
|
18
14
|
/^[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}$/,
|
|
19
15
|
)
|
|
@@ -30,20 +26,12 @@ export const EditorPage = () => {
|
|
|
30
26
|
/>
|
|
31
27
|
<meta
|
|
32
28
|
property="og:image"
|
|
33
|
-
content={`https://registry-api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png
|
|
34
|
-
{
|
|
35
|
-
fs_sha: fsMapHash ?? "",
|
|
36
|
-
},
|
|
37
|
-
).toString()}`}
|
|
29
|
+
content={`https://registry-api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png?fs_sha=${pkg.latest_package_release_fs_sha}`}
|
|
38
30
|
/>
|
|
39
31
|
<meta name="twitter:card" content="summary_large_image" />
|
|
40
32
|
<meta
|
|
41
33
|
name="twitter:image"
|
|
42
|
-
content={`https://registry-api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png
|
|
43
|
-
{
|
|
44
|
-
fs_sha: fsMapHash ?? "",
|
|
45
|
-
},
|
|
46
|
-
).toString()}`}
|
|
34
|
+
content={`https://registry-api.tscircuit.com/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/pcb.png?fs_sha=${pkg.latest_package_release_fs_sha}`}
|
|
47
35
|
/>
|
|
48
36
|
</>
|
|
49
37
|
)}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { usePackageFiles } from "@/hooks/use-package-files"
|
|
2
|
-
import md5 from "md5"
|
|
3
|
-
|
|
4
|
-
export const useGetFsMapHashForPackage = (packageReleaseId: string) => {
|
|
5
|
-
const { data: pkgFilesList } = usePackageFiles(packageReleaseId)
|
|
6
|
-
|
|
7
|
-
if (!pkgFilesList) {
|
|
8
|
-
console.error(
|
|
9
|
-
`No package files found for package release ${packageReleaseId}`,
|
|
10
|
-
)
|
|
11
|
-
return null
|
|
12
|
-
}
|
|
13
|
-
const fsMap = new Map<string, string>()
|
|
14
|
-
for (const file of pkgFilesList) {
|
|
15
|
-
fsMap.set(file.file_path, file.content_text ?? "")
|
|
16
|
-
}
|
|
17
|
-
const fsMapHash = md5(JSON.stringify(fsMap))
|
|
18
|
-
return `md5-${fsMapHash}`
|
|
19
|
-
}
|