@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.
@@ -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
- <Button
48
- variant="outline"
49
- size="sm"
50
- className="border-gray-300 bg-white hover:bg-gray-50 text-xs sm:text-sm"
51
- disabled={isLoading || !packageRelease}
52
- onClick={() =>
53
- packageRelease &&
54
- rebuildPackage({
55
- package_release_id: packageRelease.package_release_id,
56
- })
57
- }
58
- >
59
- <RefreshCw className="w-3 h-3 sm:w-4 sm:h-4 mr-1 sm:mr-2" />
60
- {isLoading ? "Rebuilding..." : "Rebuild"}
61
- </Button>
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
- if (hasAiContent) {
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
- })
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
- const jlcpcbComponent = await fetchEasyEDAComponent("C1", {
166
- fetch: ((url, options: any) => {
167
- return fetch(`${API_BASE}/proxy`, {
168
- body: options.body,
169
- method: options.method,
170
- headers: {
171
- authority: options.headers.authority,
172
- Authorization: `Bearer ${session?.token}`,
173
- "X-Target-Url": url.toString(),
174
- "X-Sender-Host": options.headers.origin,
175
- "X-Sender-Origin": options.headers.origin,
176
- "content-type": options.headers["content-type"],
177
- },
178
- })
179
- }) as typeof fetch,
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`]) {
@@ -73,7 +73,7 @@ export function LandingPage() {
73
73
  </Button>
74
74
  </a>
75
75
  <PrefetchPageLink
76
- href="/seveibar/usb-c-flashlight#3d"
76
+ href="/seveibar/led-water-accelerometer#3d"
77
77
  className="w-[70vw] min-[500px]:w-auto"
78
78
  >
79
79
  <Button