@tscircuit/fake-snippets 0.0.102 → 0.0.104
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/dist/bundle.js +20 -10
- package/dist/index.d.ts +15 -0
- package/dist/index.js +6 -2
- package/dist/schema.d.ts +24 -0
- package/dist/schema.js +6 -2
- package/fake-snippets-api/lib/db/schema.ts +5 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package-release.ts +2 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package.ts +2 -0
- package/fake-snippets-api/routes/api/packages/update.ts +7 -2
- package/package.json +1 -1
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +1 -0
- package/src/components/ViewPackagePage/components/sidebar-about-section.tsx +13 -1
- package/src/components/ViewPackagePage/components/sidebar-releases-section.tsx +17 -0
- package/src/components/dialogs/GitHubRepositorySelector.tsx +103 -66
- package/src/components/dialogs/edit-package-details-dialog.tsx +18 -3
- package/src/components/preview/BuildsList.tsx +19 -16
- package/src/components/preview/{ConnectedReposCards.tsx → ConnectedPackagesList.tsx} +64 -68
- package/src/components/preview/ConnectedRepoDashboard.tsx +37 -52
- package/src/components/preview/ConnectedRepoOverview.tsx +2 -2
- package/src/components/preview/index.tsx +42 -1
- package/src/hooks/use-package-details-form.ts +13 -1
- package/src/pages/user-profile.tsx +14 -6
- package/src/pages/view-connected-repo.tsx +1 -7
- package/src/components/preview/ConnectedRepoSettings.tsx +0 -343
|
@@ -24,33 +24,28 @@ import {
|
|
|
24
24
|
import { useLocation } from "wouter"
|
|
25
25
|
import { ConnectedRepoOverview } from "./ConnectedRepoOverview"
|
|
26
26
|
import { BuildsList } from "./BuildsList"
|
|
27
|
-
import { ConnectedRepoSettings } from "./ConnectedRepoSettings"
|
|
28
27
|
import Header from "../Header"
|
|
29
28
|
import { formatTimeAgo } from "@/lib/utils/formatTimeAgo"
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
29
|
+
import {
|
|
30
|
+
getBuildStatus,
|
|
31
|
+
PackageBuild,
|
|
32
|
+
MOCK_DEPLOYMENTS,
|
|
33
|
+
getPackageFromBuild,
|
|
34
|
+
} from "."
|
|
35
|
+
import { PrefetchPageLink } from "../PrefetchPageLink"
|
|
37
36
|
|
|
38
37
|
export const ConnectedRepoDashboard = ({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
38
|
+
latestBuild,
|
|
39
|
+
}: {
|
|
40
|
+
latestBuild: PackageBuild
|
|
41
|
+
}) => {
|
|
43
42
|
const [activeTab, setActiveTab] = useState("overview")
|
|
44
|
-
const [currentBuild, setCurrentBuild] = useState<PackageBuild | undefined>(
|
|
45
|
-
selectedBuild || builds[0],
|
|
46
|
-
)
|
|
47
43
|
const [, setLocation] = useLocation()
|
|
48
|
-
|
|
44
|
+
const pkg = getPackageFromBuild(latestBuild)
|
|
49
45
|
const handleSelectBuild = (build: PackageBuild) => {
|
|
50
46
|
setLocation(`/build/${build.package_build_id}`)
|
|
47
|
+
setActiveTab("overview")
|
|
51
48
|
}
|
|
52
|
-
|
|
53
|
-
const latestBuild = builds[0]
|
|
54
49
|
const { status, label } = getBuildStatus(latestBuild)
|
|
55
50
|
|
|
56
51
|
return (
|
|
@@ -71,9 +66,12 @@ export const ConnectedRepoDashboard = ({
|
|
|
71
66
|
</div>
|
|
72
67
|
<div className="min-w-0 flex-1">
|
|
73
68
|
<div className="flex flex-col sm:flex-row sm:items-center gap-3">
|
|
74
|
-
<
|
|
75
|
-
{
|
|
76
|
-
|
|
69
|
+
<PrefetchPageLink
|
|
70
|
+
href={"/" + pkg.name}
|
|
71
|
+
className="text-2xl font-bold text-gray-900 truncate"
|
|
72
|
+
>
|
|
73
|
+
{pkg.unscoped_name}
|
|
74
|
+
</PrefetchPageLink>
|
|
77
75
|
<Badge
|
|
78
76
|
variant={
|
|
79
77
|
status === "success"
|
|
@@ -99,7 +97,15 @@ export const ConnectedRepoDashboard = ({
|
|
|
99
97
|
</Badge>
|
|
100
98
|
</div>
|
|
101
99
|
<div className="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-2 text-sm text-gray-600">
|
|
102
|
-
<div
|
|
100
|
+
<div
|
|
101
|
+
className="flex cursor-pointer items-center gap-1"
|
|
102
|
+
onClick={() =>
|
|
103
|
+
window?.open(
|
|
104
|
+
`https://github.com/${pkg.github_repo_full_name}/tree/${latestBuild.branch_name || "main"}`,
|
|
105
|
+
"_blank",
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
>
|
|
103
109
|
<GitBranch className="w-4 h-4 flex-shrink-0" />
|
|
104
110
|
<span className="truncate">
|
|
105
111
|
{latestBuild.branch_name || "main"}
|
|
@@ -108,19 +114,9 @@ export const ConnectedRepoDashboard = ({
|
|
|
108
114
|
<div className="flex items-center gap-1">
|
|
109
115
|
<Clock className="w-4 h-4 flex-shrink-0" />
|
|
110
116
|
<span>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
<div className="flex items-center gap-1">
|
|
115
|
-
<User className="w-4 h-4 flex-shrink-0" />
|
|
116
|
-
<span className="truncate">
|
|
117
|
-
{latestBuild.commit_author || "Unknown"}
|
|
118
|
-
</span>
|
|
119
|
-
</div>
|
|
120
|
-
<div className="flex items-center gap-1">
|
|
121
|
-
<Hash className="w-4 h-4 flex-shrink-0" />
|
|
122
|
-
<span className="font-mono text-xs truncate">
|
|
123
|
-
{latestBuild.package_build_id?.slice(-8) || "N/A"}
|
|
117
|
+
<time dateTime={latestBuild.created_at}>
|
|
118
|
+
Last deployed {formatTimeAgo(latestBuild.created_at)}
|
|
119
|
+
</time>
|
|
124
120
|
</span>
|
|
125
121
|
</div>
|
|
126
122
|
</div>
|
|
@@ -134,7 +130,7 @@ export const ConnectedRepoDashboard = ({
|
|
|
134
130
|
className="flex items-center gap-2 justify-center min-w-[120px] h-9"
|
|
135
131
|
onClick={() =>
|
|
136
132
|
window.open(
|
|
137
|
-
`https://github.com/${
|
|
133
|
+
`https://github.com/${pkg.github_repo_full_name}`,
|
|
138
134
|
"_blank",
|
|
139
135
|
)
|
|
140
136
|
}
|
|
@@ -181,7 +177,7 @@ export const ConnectedRepoDashboard = ({
|
|
|
181
177
|
<DropdownMenuContent align="end">
|
|
182
178
|
<DropdownMenuItem asChild>
|
|
183
179
|
<a
|
|
184
|
-
href={`https://github.com/${
|
|
180
|
+
href={`https://github.com/${pkg.github_repo_full_name}`}
|
|
185
181
|
target="_blank"
|
|
186
182
|
rel="noopener noreferrer"
|
|
187
183
|
>
|
|
@@ -197,7 +193,7 @@ export const ConnectedRepoDashboard = ({
|
|
|
197
193
|
onClick={() => {
|
|
198
194
|
if (navigator.share) {
|
|
199
195
|
navigator.share({
|
|
200
|
-
title:
|
|
196
|
+
title: pkg.unscoped_name,
|
|
201
197
|
url: window.location.href,
|
|
202
198
|
})
|
|
203
199
|
} else {
|
|
@@ -221,7 +217,7 @@ export const ConnectedRepoDashboard = ({
|
|
|
221
217
|
onValueChange={setActiveTab}
|
|
222
218
|
className="space-y-6"
|
|
223
219
|
>
|
|
224
|
-
<TabsList className="grid w-full grid-cols-
|
|
220
|
+
<TabsList className="grid w-full grid-cols-2 lg:w-auto lg:grid-cols-2">
|
|
225
221
|
<TabsTrigger value="overview" className="flex items-center gap-2">
|
|
226
222
|
<Activity className="w-4 h-4" />
|
|
227
223
|
Overview
|
|
@@ -230,25 +226,14 @@ export const ConnectedRepoDashboard = ({
|
|
|
230
226
|
<List className="w-4 h-4" />
|
|
231
227
|
Builds
|
|
232
228
|
</TabsTrigger>
|
|
233
|
-
<TabsTrigger value="settings" className="flex items-center gap-2">
|
|
234
|
-
<Settings className="w-4 h-4" />
|
|
235
|
-
Settings
|
|
236
|
-
</TabsTrigger>
|
|
237
229
|
</TabsList>
|
|
238
230
|
|
|
239
231
|
<TabsContent value="overview" className="space-y-6">
|
|
240
|
-
{
|
|
232
|
+
{latestBuild && <ConnectedRepoOverview build={latestBuild} />}
|
|
241
233
|
</TabsContent>
|
|
242
234
|
|
|
243
235
|
<TabsContent value="builds" className="space-y-6">
|
|
244
|
-
<BuildsList
|
|
245
|
-
</TabsContent>
|
|
246
|
-
|
|
247
|
-
<TabsContent value="settings" className="space-y-6">
|
|
248
|
-
<ConnectedRepoSettings
|
|
249
|
-
projectName={projectName}
|
|
250
|
-
onSave={(settings) => console.log("Settings saved:", settings)}
|
|
251
|
-
/>
|
|
236
|
+
<BuildsList pkg={pkg} onSelectBuild={handleSelectBuild} />
|
|
252
237
|
</TabsContent>
|
|
253
238
|
</Tabs>
|
|
254
239
|
</div>
|
|
@@ -198,7 +198,7 @@ export const ConnectedRepoOverview = ({
|
|
|
198
198
|
</div>
|
|
199
199
|
|
|
200
200
|
<div className="space-y-3">
|
|
201
|
-
<h2 className="text-lg font-semibold text-gray-900">
|
|
201
|
+
<h2 className="text-lg font-semibold text-gray-900">Logs</h2>
|
|
202
202
|
|
|
203
203
|
<Collapsible
|
|
204
204
|
open={openSections.transpilation}
|
|
@@ -387,7 +387,7 @@ export const ConnectedRepoOverview = ({
|
|
|
387
387
|
) : (
|
|
388
388
|
<Clock className="w-5 h-5 text-gray-400" />
|
|
389
389
|
)}
|
|
390
|
-
<span className="font-medium">
|
|
390
|
+
<span className="font-medium">Build</span>
|
|
391
391
|
</div>
|
|
392
392
|
<div className="flex items-center gap-2">
|
|
393
393
|
{getStepDuration(
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { ConnectedRepoOverview } from "./ConnectedRepoOverview"
|
|
2
2
|
export { BuildsList } from "./BuildsList"
|
|
3
|
-
export { ConnectedRepoSettings } from "./ConnectedRepoSettings"
|
|
4
3
|
export { ConnectedRepoDashboard } from "./ConnectedRepoDashboard"
|
|
5
4
|
|
|
6
5
|
export const getBuildStatus = (build: PackageBuild) => {
|
|
@@ -192,6 +191,7 @@ export const MOCK_DEPLOYMENTS: PackageBuild[] = [
|
|
|
192
191
|
},
|
|
193
192
|
]
|
|
194
193
|
|
|
194
|
+
import { Package, PackageRelease } from "fake-snippets-api/lib/db/schema"
|
|
195
195
|
import { Clock, CheckCircle, AlertCircle, Loader2 } from "lucide-react"
|
|
196
196
|
export const StatusIcon = ({ status }: { status: string }) => {
|
|
197
197
|
switch (status) {
|
|
@@ -205,3 +205,44 @@ export const StatusIcon = ({ status }: { status: string }) => {
|
|
|
205
205
|
return <Clock className="w-4 h-4 text-gray-500" />
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
+
|
|
209
|
+
export const getLatestBuildForPackage = (pkg: Package): PackageBuild => {
|
|
210
|
+
return MOCK_DEPLOYMENTS[0]
|
|
211
|
+
}
|
|
212
|
+
export const getLatestBuildFromPackageRelease = (
|
|
213
|
+
pkg: PackageRelease,
|
|
214
|
+
): PackageBuild => {
|
|
215
|
+
return MOCK_DEPLOYMENTS[0]
|
|
216
|
+
}
|
|
217
|
+
export const getPackageFromBuild = (build: PackageBuild): Package => {
|
|
218
|
+
return {
|
|
219
|
+
ai_description: "placeholder ai description",
|
|
220
|
+
ai_usage_instructions: "placeholder ai usage instructions",
|
|
221
|
+
created_at: "2025-08-06T14:37:05.802Z",
|
|
222
|
+
creator_account_id: "account-1234",
|
|
223
|
+
default_view: "files",
|
|
224
|
+
description: "placeholder ai description",
|
|
225
|
+
github_repo_full_name: "testuser/pcb-designs",
|
|
226
|
+
is_board: false,
|
|
227
|
+
is_footprint: false,
|
|
228
|
+
is_model: false,
|
|
229
|
+
is_package: false,
|
|
230
|
+
is_private: false,
|
|
231
|
+
is_public: true,
|
|
232
|
+
is_snippet: false,
|
|
233
|
+
is_source_from_github: false,
|
|
234
|
+
is_unlisted: false,
|
|
235
|
+
latest_package_release_fs_sha: "md5-425b47ef26be8f0863eca9e63e516dfa",
|
|
236
|
+
latest_package_release_id: "package_release_1754491026466",
|
|
237
|
+
latest_version: "0.0.1",
|
|
238
|
+
license: null,
|
|
239
|
+
name: "testuser/untitled-package-0",
|
|
240
|
+
owner_github_username: "testuser",
|
|
241
|
+
owner_org_id: "org-1234",
|
|
242
|
+
package_id: "package_1754491025802",
|
|
243
|
+
star_count: 0,
|
|
244
|
+
unscoped_name: "untitled-package-0",
|
|
245
|
+
updated_at: "2025-08-06T14:37:25.083Z",
|
|
246
|
+
website: "",
|
|
247
|
+
}
|
|
248
|
+
}
|
|
@@ -18,6 +18,7 @@ interface PackageDetailsForm {
|
|
|
18
18
|
defaultView: string
|
|
19
19
|
githubRepoFullName: string | null
|
|
20
20
|
unscopedPackageName: string
|
|
21
|
+
allowPrPreviews?: boolean
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
interface UsePackageDetailsFormProps {
|
|
@@ -29,6 +30,7 @@ interface UsePackageDetailsFormProps {
|
|
|
29
30
|
initialUnscopedPackageName: string
|
|
30
31
|
initialGithubRepoFullName: string | null
|
|
31
32
|
isDialogOpen: boolean
|
|
33
|
+
initialAllowPrPreviews?: boolean
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
export const usePackageDetailsForm = ({
|
|
@@ -40,6 +42,7 @@ export const usePackageDetailsForm = ({
|
|
|
40
42
|
initialUnscopedPackageName,
|
|
41
43
|
initialGithubRepoFullName,
|
|
42
44
|
isDialogOpen,
|
|
45
|
+
initialAllowPrPreviews,
|
|
43
46
|
}: UsePackageDetailsFormProps) => {
|
|
44
47
|
const [formData, setFormData] = useState<PackageDetailsForm>({
|
|
45
48
|
description: initialDescription,
|
|
@@ -62,6 +65,7 @@ export const usePackageDetailsForm = ({
|
|
|
62
65
|
githubRepoFullName: initialGithubRepoFullName,
|
|
63
66
|
defaultView: initialDefaultView,
|
|
64
67
|
unscopedPackageName: initialUnscopedPackageName,
|
|
68
|
+
allowPrPreviews: initialAllowPrPreviews,
|
|
65
69
|
})
|
|
66
70
|
setWebsiteError(null)
|
|
67
71
|
}
|
|
@@ -98,6 +102,11 @@ export const usePackageDetailsForm = ({
|
|
|
98
102
|
[formData.defaultView, initialDefaultView],
|
|
99
103
|
)
|
|
100
104
|
|
|
105
|
+
const hasAllowPrPreviewsChanged = useMemo(
|
|
106
|
+
() => formData.allowPrPreviews !== initialAllowPrPreviews,
|
|
107
|
+
[formData.allowPrPreviews, initialAllowPrPreviews],
|
|
108
|
+
)
|
|
109
|
+
|
|
101
110
|
const hasChanges = useMemo(
|
|
102
111
|
() =>
|
|
103
112
|
formData.description !== initialDescription ||
|
|
@@ -106,7 +115,8 @@ export const usePackageDetailsForm = ({
|
|
|
106
115
|
formData.visibility !== initialVisibility ||
|
|
107
116
|
formData.defaultView !== initialDefaultView ||
|
|
108
117
|
formData.githubRepoFullName !== initialGithubRepoFullName ||
|
|
109
|
-
formData.unscopedPackageName !== initialUnscopedPackageName
|
|
118
|
+
formData.unscopedPackageName !== initialUnscopedPackageName ||
|
|
119
|
+
formData.allowPrPreviews !== initialAllowPrPreviews,
|
|
110
120
|
[
|
|
111
121
|
formData,
|
|
112
122
|
initialDescription,
|
|
@@ -116,6 +126,7 @@ export const usePackageDetailsForm = ({
|
|
|
116
126
|
initialDefaultView,
|
|
117
127
|
initialGithubRepoFullName,
|
|
118
128
|
initialUnscopedPackageName,
|
|
129
|
+
initialAllowPrPreviews,
|
|
119
130
|
],
|
|
120
131
|
)
|
|
121
132
|
|
|
@@ -128,6 +139,7 @@ export const usePackageDetailsForm = ({
|
|
|
128
139
|
hasLicenseChanged,
|
|
129
140
|
hasVisibilityChanged,
|
|
130
141
|
hasDefaultViewChanged,
|
|
142
|
+
hasAllowPrPreviewsChanged,
|
|
131
143
|
hasChanges,
|
|
132
144
|
isFormValid,
|
|
133
145
|
}
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "@/components/ui/select"
|
|
26
26
|
import { Box, Star } from "lucide-react"
|
|
27
27
|
import { PackageCardSkeleton } from "@/components/PackageCardSkeleton"
|
|
28
|
-
import {
|
|
28
|
+
import { ConnectedPackagesList } from "@/components/preview/ConnectedPackagesList"
|
|
29
29
|
|
|
30
30
|
export const UserProfilePage = () => {
|
|
31
31
|
const { username } = useParams()
|
|
@@ -101,7 +101,6 @@ export const UserProfilePage = () => {
|
|
|
101
101
|
if (accountError) {
|
|
102
102
|
return <NotFoundPage heading="User Not Found" />
|
|
103
103
|
}
|
|
104
|
-
|
|
105
104
|
const packagesToShow =
|
|
106
105
|
activeTab === "starred" ? starredPackages : userPackages
|
|
107
106
|
const isLoading =
|
|
@@ -179,9 +178,13 @@ export const UserProfilePage = () => {
|
|
|
179
178
|
<TabsList>
|
|
180
179
|
<TabsTrigger value="all">Packages</TabsTrigger>
|
|
181
180
|
<TabsTrigger value="starred">Starred Packages</TabsTrigger>
|
|
182
|
-
{isCurrentUserProfile &&
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
{isCurrentUserProfile &&
|
|
182
|
+
(
|
|
183
|
+
userPackages?.filter((x) => Boolean(x.github_repo_full_name)) ??
|
|
184
|
+
[]
|
|
185
|
+
).length > 0 && (
|
|
186
|
+
<TabsTrigger value="repos">Connected Repositories</TabsTrigger>
|
|
187
|
+
)}
|
|
185
188
|
</TabsList>
|
|
186
189
|
</Tabs>
|
|
187
190
|
{activeTab !== "repos" && (
|
|
@@ -208,7 +211,12 @@ export const UserProfilePage = () => {
|
|
|
208
211
|
</div>
|
|
209
212
|
)}
|
|
210
213
|
{activeTab === "repos" ? (
|
|
211
|
-
<
|
|
214
|
+
<ConnectedPackagesList
|
|
215
|
+
packages={
|
|
216
|
+
userPackages?.filter((x) => Boolean(x.github_repo_full_name)) ??
|
|
217
|
+
[]
|
|
218
|
+
}
|
|
219
|
+
/>
|
|
212
220
|
) : isLoading ? (
|
|
213
221
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
214
222
|
{[...Array(6)].map((_, i) => (
|
|
@@ -14,11 +14,5 @@ export default function ViewConnectedRepoOverview() {
|
|
|
14
14
|
return <NotFoundPage heading="Build Not Found" />
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
return
|
|
18
|
-
<ConnectedRepoDashboard
|
|
19
|
-
projectName="tscircuit-project"
|
|
20
|
-
builds={MOCK_DEPLOYMENTS}
|
|
21
|
-
selectedBuild={selectedBuild}
|
|
22
|
-
/>
|
|
23
|
-
)
|
|
17
|
+
return <ConnectedRepoDashboard latestBuild={selectedBuild} />
|
|
24
18
|
}
|