@tscircuit/fake-snippets 0.0.101 → 0.0.103

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.
Files changed (56) hide show
  1. package/api/generated-index.js +23 -1
  2. package/bun.lock +2 -2
  3. package/dist/bundle.js +530 -367
  4. package/dist/index.d.ts +29 -2
  5. package/dist/index.js +18 -1
  6. package/dist/schema.d.ts +94 -1
  7. package/dist/schema.js +17 -1
  8. package/fake-snippets-api/lib/db/db-client.ts +6 -1
  9. package/fake-snippets-api/lib/db/schema.ts +15 -0
  10. package/fake-snippets-api/lib/public-mapping/public-map-package.ts +2 -0
  11. package/fake-snippets-api/routes/api/github/installations/create_new_installation_redirect.ts +75 -0
  12. package/fake-snippets-api/routes/api/github/repos/list_available.ts +91 -0
  13. package/fake-snippets-api/routes/api/packages/update.ts +6 -0
  14. package/package.json +2 -2
  15. package/src/App.tsx +10 -1
  16. package/src/components/CreateReleaseDialog.tsx +124 -0
  17. package/src/components/FileSidebar.tsx +128 -23
  18. package/src/components/PackageBuildsPage/package-build-header.tsx +9 -1
  19. package/src/components/PageSearchComponent.tsx +2 -2
  20. package/src/components/SearchComponent.tsx +2 -2
  21. package/src/components/SuspenseRunFrame.tsx +2 -2
  22. package/src/components/TrendingPackagesCarousel.tsx +2 -2
  23. package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +1 -0
  24. package/src/components/ViewPackagePage/components/sidebar-about-section.tsx +13 -1
  25. package/src/components/ViewPackagePage/components/sidebar-releases-section.tsx +17 -0
  26. package/src/components/dialogs/GitHubRepositorySelector.tsx +183 -0
  27. package/src/components/dialogs/create-use-dialog.tsx +8 -2
  28. package/src/components/dialogs/edit-package-details-dialog.tsx +32 -3
  29. package/src/components/dialogs/view-ts-files-dialog.tsx +178 -33
  30. package/src/components/package-port/CodeAndPreview.tsx +4 -1
  31. package/src/components/package-port/CodeEditor.tsx +42 -35
  32. package/src/components/package-port/CodeEditorHeader.tsx +6 -4
  33. package/src/components/package-port/EditorNav.tsx +94 -37
  34. package/src/components/preview/BuildsList.tsx +241 -0
  35. package/src/components/preview/ConnectedPackagesList.tsx +187 -0
  36. package/src/components/preview/ConnectedRepoDashboard.tsx +243 -0
  37. package/src/components/preview/ConnectedRepoOverview.tsx +454 -0
  38. package/src/components/preview/index.tsx +248 -0
  39. package/src/components/ui/tree-view.tsx +23 -6
  40. package/src/hooks/use-axios.ts +2 -2
  41. package/src/hooks/use-create-release-dialog.ts +160 -0
  42. package/src/hooks/use-package-details-form.ts +7 -0
  43. package/src/hooks/use-packages-base-api-url.ts +1 -1
  44. package/src/hooks/use-sign-in.ts +2 -2
  45. package/src/hooks/useFileManagement.ts +22 -2
  46. package/src/index.css +4 -0
  47. package/src/lib/utils/formatTimeAgo.ts +10 -0
  48. package/src/lib/utils/isValidFileName.ts +15 -3
  49. package/src/pages/dashboard.tsx +2 -2
  50. package/src/pages/dev-login.tsx +2 -2
  51. package/src/pages/latest.tsx +2 -2
  52. package/src/pages/preview-build.tsx +380 -0
  53. package/src/pages/search.tsx +2 -2
  54. package/src/pages/trending.tsx +2 -2
  55. package/src/pages/user-profile.tsx +40 -24
  56. package/src/pages/view-connected-repo.tsx +18 -0
@@ -0,0 +1,187 @@
1
+ import { useState } from "react"
2
+ import { Card, CardContent, CardHeader } from "@/components/ui/card"
3
+ import { Badge } from "@/components/ui/badge"
4
+ import { Button } from "@/components/ui/button"
5
+ import { GitBranch, Rocket, Github } from "lucide-react"
6
+ import { cn } from "@/lib/utils"
7
+ import { PrefetchPageLink } from "../PrefetchPageLink"
8
+ import { formatTimeAgo } from "@/lib/utils/formatTimeAgo"
9
+ import {
10
+ getBuildStatus,
11
+ getLatestBuildForPackage,
12
+ MOCK_DEPLOYMENTS,
13
+ PackageBuild,
14
+ StatusIcon,
15
+ } from "."
16
+ import { Package } from "fake-snippets-api/lib/db/schema"
17
+
18
+ export const ConnectedPackageCardSkeleton = () => {
19
+ return (
20
+ <Card className="animate-pulse">
21
+ <CardHeader className="pb-3">
22
+ <div className="flex items-start justify-between">
23
+ <div className="flex items-center gap-2 flex-1">
24
+ <div className="w-4 h-4 bg-gray-200 rounded" />
25
+ <div className="space-y-2 flex-1">
26
+ <div className="flex items-center gap-2">
27
+ <div className="w-12 h-4 bg-gray-200 rounded" />
28
+ <div className="w-16 h-3 bg-gray-200 rounded" />
29
+ </div>
30
+ <div className="w-20 h-3 bg-gray-200 rounded" />
31
+ </div>
32
+ </div>
33
+ </div>
34
+ </CardHeader>
35
+ <CardContent className="pt-0 space-y-3">
36
+ <div className="w-full h-4 bg-gray-200 rounded" />
37
+ <div className="flex gap-2">
38
+ <div className="w-16 h-3 bg-gray-200 rounded" />
39
+ <div className="w-20 h-3 bg-gray-200 rounded" />
40
+ </div>
41
+ <div className="flex gap-2 pt-2">
42
+ <div className="flex-1 h-8 bg-gray-200 rounded" />
43
+ <div className="flex-1 h-8 bg-gray-200 rounded" />
44
+ </div>
45
+ </CardContent>
46
+ </Card>
47
+ )
48
+ }
49
+
50
+ export const ConnectedPackageCard = ({
51
+ pkg,
52
+ className,
53
+ }: {
54
+ pkg: Package
55
+ className?: string
56
+ }) => {
57
+ const latestBuildInfo: PackageBuild = getLatestBuildForPackage(pkg)
58
+ const { status, label } = getBuildStatus(latestBuildInfo)
59
+ return (
60
+ <Card
61
+ className={cn(
62
+ "group relative overflow-hidden",
63
+ "border border-gray-200",
64
+ "hover:border-gray-300",
65
+ "bg-white",
66
+ "p-6",
67
+ "flex flex-col",
68
+ "min-h-[200px]",
69
+ className,
70
+ )}
71
+ >
72
+ <div className="flex items-start justify-between mb-4">
73
+ <div className="flex items-center gap-3">
74
+ <a
75
+ href="#"
76
+ className="text-lg font-semibold text-gray-900 hover:text-blue-600 transition-colors"
77
+ >
78
+ tsc-deploy
79
+ </a>
80
+ </div>
81
+
82
+ <div className="flex items-center justify-center gap-2">
83
+ <Badge
84
+ variant={
85
+ status === "success"
86
+ ? "default"
87
+ : status === "error"
88
+ ? "destructive"
89
+ : "secondary"
90
+ }
91
+ className="text-xs flex items-center"
92
+ >
93
+ {label}
94
+ </Badge>
95
+ <div className="flex items-center justify-center">
96
+ <StatusIcon status={status} />
97
+ </div>
98
+ </div>
99
+ </div>
100
+
101
+ <div className="flex items-center gap-2 mb-4">
102
+ <Github className="w-4 h-4 text-gray-600" />
103
+ <a
104
+ href={`https://github.com/${pkg.github_repo_full_name}`}
105
+ className="text-sm font-medium text-gray-700 hover:text-blue-600 transition-colors"
106
+ >
107
+ {pkg.github_repo_full_name}
108
+ </a>
109
+ </div>
110
+
111
+ {latestBuildInfo.commit_message && (
112
+ <div className="mb-6 flex-1">
113
+ <h4
114
+ title={latestBuildInfo.commit_message}
115
+ className="text-sm font-medium truncate text-gray-900 mb-2"
116
+ >
117
+ {latestBuildInfo.commit_message}
118
+ </h4>
119
+ <div className="flex items-center gap-2 text-xs text-gray-500">
120
+ <span>{formatTimeAgo(latestBuildInfo.created_at)} on</span>
121
+ <div className="flex items-center gap-1">
122
+ <GitBranch className="w-3 h-3" />
123
+ <span className="bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full font-medium">
124
+ {latestBuildInfo.branch_name || "main"}
125
+ </span>
126
+ </div>
127
+ </div>
128
+ </div>
129
+ )}
130
+
131
+ <div className="flex gap-2 w-full mt-auto">
132
+ <PrefetchPageLink
133
+ className="w-full"
134
+ href={`/build/${latestBuildInfo.package_build_id}`}
135
+ >
136
+ <Button
137
+ size="sm"
138
+ className="bg-blue-600 w-full hover:bg-blue-700 text-white px-4 py-2"
139
+ >
140
+ View
141
+ </Button>
142
+ </PrefetchPageLink>
143
+ {latestBuildInfo.preview_url && status === "success" && (
144
+ <PrefetchPageLink
145
+ className="w-full"
146
+ href={`/build/${latestBuildInfo.package_build_id}/preview`}
147
+ >
148
+ <Button size="sm" variant="outline" className="px-4 py-2 w-full">
149
+ Preview
150
+ </Button>
151
+ </PrefetchPageLink>
152
+ )}
153
+ </div>
154
+ </Card>
155
+ )
156
+ }
157
+
158
+ export const ConnectedPackagesList = ({
159
+ packages,
160
+ }: { packages: Package[] }) => {
161
+ const [pkgs, setpkgs] = useState(MOCK_DEPLOYMENTS)
162
+
163
+ if (pkgs.length === 0) {
164
+ return (
165
+ <div className="flex flex-col items-center justify-center py-20 text-black">
166
+ <Rocket className="w-12 h-12 mb-4 text-black" />
167
+ <h3 className="text-xl font-semibold mb-3">
168
+ No Connected Repositories
169
+ </h3>
170
+ <p className="text-sm text-center max-w-md text-gray-600">
171
+ Connect your GitHub repositories to start building and deploying your
172
+ circuits. Your connected repositories and builds will appear here.
173
+ </p>
174
+ </div>
175
+ )
176
+ }
177
+
178
+ return (
179
+ <div className="space-y-4">
180
+ <div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
181
+ {packages.map((pkg) => (
182
+ <ConnectedPackageCard key={pkg.package_id} pkg={pkg} />
183
+ ))}
184
+ </div>
185
+ </div>
186
+ )
187
+ }
@@ -0,0 +1,243 @@
1
+ import { useState } from "react"
2
+ import { Button } from "@/components/ui/button"
3
+ import { Badge } from "@/components/ui/badge"
4
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
5
+ import {
6
+ DropdownMenu,
7
+ DropdownMenuContent,
8
+ DropdownMenuItem,
9
+ DropdownMenuTrigger,
10
+ } from "@/components/ui/dropdown-menu"
11
+ import {
12
+ Activity,
13
+ Settings,
14
+ List,
15
+ Github,
16
+ MoreHorizontal,
17
+ Zap,
18
+ Clock,
19
+ GitBranch,
20
+ Hash,
21
+ User,
22
+ Eye,
23
+ } from "lucide-react"
24
+ import { useLocation } from "wouter"
25
+ import { ConnectedRepoOverview } from "./ConnectedRepoOverview"
26
+ import { BuildsList } from "./BuildsList"
27
+ import Header from "../Header"
28
+ import { formatTimeAgo } from "@/lib/utils/formatTimeAgo"
29
+ import {
30
+ getBuildStatus,
31
+ PackageBuild,
32
+ MOCK_DEPLOYMENTS,
33
+ getPackageFromBuild,
34
+ } from "."
35
+ import { PrefetchPageLink } from "../PrefetchPageLink"
36
+
37
+ export const ConnectedRepoDashboard = ({
38
+ latestBuild,
39
+ }: {
40
+ latestBuild: PackageBuild
41
+ }) => {
42
+ const [activeTab, setActiveTab] = useState("overview")
43
+ const [, setLocation] = useLocation()
44
+ const pkg = getPackageFromBuild(latestBuild)
45
+ const handleSelectBuild = (build: PackageBuild) => {
46
+ setLocation(`/build/${build.package_build_id}`)
47
+ setActiveTab("overview")
48
+ }
49
+ const { status, label } = getBuildStatus(latestBuild)
50
+
51
+ return (
52
+ <>
53
+ <Header />
54
+ <div className="min-h-screen bg-white">
55
+ {/* Project Header */}
56
+ <div className="bg-gray-50 border-b md:py-10">
57
+ <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
58
+ <div className="flex flex-col lg:flex-row lg:items-center lg:justify-between gap-6">
59
+ <div className="flex flex-col sm:flex-row sm:items-center gap-4">
60
+ <div className="w-12 hidden md:block h-12 rounded-lg overflow-hidden flex-shrink-0">
61
+ <img
62
+ src="https://github.com/tscircuit.png"
63
+ alt="tscircuit logo"
64
+ className="w-full h-full object-cover"
65
+ />
66
+ </div>
67
+ <div className="min-w-0 flex-1">
68
+ <div className="flex flex-col sm:flex-row sm:items-center gap-3">
69
+ <PrefetchPageLink
70
+ href={"/" + pkg.name}
71
+ className="text-2xl font-bold text-gray-900 truncate"
72
+ >
73
+ {pkg.unscoped_name}
74
+ </PrefetchPageLink>
75
+ <Badge
76
+ variant={
77
+ status === "success"
78
+ ? "default"
79
+ : status === "error"
80
+ ? "destructive"
81
+ : "secondary"
82
+ }
83
+ className="flex items-center gap-1 w-fit"
84
+ >
85
+ <div
86
+ className={`w-2 h-2 rounded-full ${
87
+ status === "success"
88
+ ? "bg-green-500"
89
+ : status === "error"
90
+ ? "bg-red-500"
91
+ : status === "building"
92
+ ? "bg-blue-500 animate-pulse"
93
+ : "bg-gray-500"
94
+ }`}
95
+ />
96
+ {label}
97
+ </Badge>
98
+ </div>
99
+ <div className="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-2 text-sm text-gray-600">
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
+ >
109
+ <GitBranch className="w-4 h-4 flex-shrink-0" />
110
+ <span className="truncate">
111
+ {latestBuild.branch_name || "main"}
112
+ </span>
113
+ </div>
114
+ <div className="flex items-center gap-1">
115
+ <Clock className="w-4 h-4 flex-shrink-0" />
116
+ <span>
117
+ <time dateTime={latestBuild.created_at}>
118
+ Last deployed {formatTimeAgo(latestBuild.created_at)}
119
+ </time>
120
+ </span>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ </div>
125
+
126
+ <div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-2">
127
+ <Button
128
+ variant="outline"
129
+ size="sm"
130
+ className="flex items-center gap-2 justify-center min-w-[120px] h-9"
131
+ onClick={() =>
132
+ window.open(
133
+ `https://github.com/${pkg.github_repo_full_name}`,
134
+ "_blank",
135
+ )
136
+ }
137
+ >
138
+ <Github className="w-4 h-4" />
139
+ <span className="hidden sm:inline">Repository</span>
140
+ <span className="sm:hidden">Repository</span>
141
+ </Button>
142
+ {latestBuild.preview_url && (
143
+ <Button
144
+ variant="outline"
145
+ size="sm"
146
+ className="flex items-center gap-2 justify-center min-w-[120px] h-9"
147
+ onClick={() =>
148
+ window.open(
149
+ `/build/${latestBuild.package_build_id}/preview`,
150
+ "_blank",
151
+ )
152
+ }
153
+ >
154
+ <Eye className="w-4 h-4" />
155
+ <span className="hidden sm:inline">Preview</span>
156
+ <span className="sm:hidden">Preview</span>
157
+ </Button>
158
+ )}
159
+ <Button
160
+ size="sm"
161
+ className="flex items-center gap-2 justify-center min-w-[120px] h-9 bg-black text-white"
162
+ >
163
+ <Zap className="w-4 h-4" />
164
+ <span className="hidden sm:inline">Redeploy</span>
165
+ <span className="sm:hidden">Redeploy</span>
166
+ </Button>
167
+ <DropdownMenu>
168
+ <DropdownMenuTrigger asChild>
169
+ <Button
170
+ variant="outline"
171
+ size="sm"
172
+ className="w-full h-9 sm:w-9 p-0"
173
+ >
174
+ <MoreHorizontal className="w-4 h-4" />
175
+ </Button>
176
+ </DropdownMenuTrigger>
177
+ <DropdownMenuContent align="end">
178
+ <DropdownMenuItem asChild>
179
+ <a
180
+ href={`https://github.com/${pkg.github_repo_full_name}`}
181
+ target="_blank"
182
+ rel="noopener noreferrer"
183
+ >
184
+ View Source
185
+ </a>
186
+ </DropdownMenuItem>
187
+ <DropdownMenuItem asChild>
188
+ <a href="#" download>
189
+ Download Build
190
+ </a>
191
+ </DropdownMenuItem>
192
+ <DropdownMenuItem
193
+ onClick={() => {
194
+ if (navigator.share) {
195
+ navigator.share({
196
+ title: pkg.unscoped_name,
197
+ url: window.location.href,
198
+ })
199
+ } else {
200
+ navigator.clipboard.writeText(window.location.href)
201
+ }
202
+ }}
203
+ >
204
+ Share Project
205
+ </DropdownMenuItem>
206
+ </DropdownMenuContent>
207
+ </DropdownMenu>
208
+ </div>
209
+ </div>
210
+ </div>
211
+ </div>
212
+
213
+ {/* Main Content */}
214
+ <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
215
+ <Tabs
216
+ value={activeTab}
217
+ onValueChange={setActiveTab}
218
+ className="space-y-6"
219
+ >
220
+ <TabsList className="grid w-full grid-cols-2 lg:w-auto lg:grid-cols-2">
221
+ <TabsTrigger value="overview" className="flex items-center gap-2">
222
+ <Activity className="w-4 h-4" />
223
+ Overview
224
+ </TabsTrigger>
225
+ <TabsTrigger value="builds" className="flex items-center gap-2">
226
+ <List className="w-4 h-4" />
227
+ Builds
228
+ </TabsTrigger>
229
+ </TabsList>
230
+
231
+ <TabsContent value="overview" className="space-y-6">
232
+ {latestBuild && <ConnectedRepoOverview build={latestBuild} />}
233
+ </TabsContent>
234
+
235
+ <TabsContent value="builds" className="space-y-6">
236
+ <BuildsList pkg={pkg} onSelectBuild={handleSelectBuild} />
237
+ </TabsContent>
238
+ </Tabs>
239
+ </div>
240
+ </div>
241
+ </>
242
+ )
243
+ }