@tscircuit/fake-snippets 0.0.71 → 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.
Files changed (43) hide show
  1. package/bun-tests/fake-snippets-api/routes/package_files/create_or_update.test.ts +26 -0
  2. package/bun.lock +58 -58
  3. package/dist/bundle.js +56 -5
  4. package/dist/index.d.ts +15 -2
  5. package/dist/index.js +47 -1
  6. package/dist/schema.d.ts +8 -0
  7. package/dist/schema.js +1 -0
  8. package/fake-snippets-api/lib/db/db-client.ts +47 -0
  9. package/fake-snippets-api/lib/db/schema.ts +1 -0
  10. package/fake-snippets-api/lib/package_file/generate-fs-sha.ts +20 -0
  11. package/fake-snippets-api/lib/public-mapping/public-map-package.ts +1 -0
  12. package/fake-snippets-api/routes/api/package_files/create.ts +3 -0
  13. package/fake-snippets-api/routes/api/package_files/create_or_update.ts +9 -3
  14. package/fake-snippets-api/routes/api/package_files/delete.ts +3 -0
  15. package/fake-snippets-api/routes/api/packages/create.ts +1 -0
  16. package/package.json +11 -11
  17. package/src/App.tsx +5 -0
  18. package/src/components/FileSidebar.tsx +111 -37
  19. package/src/components/JLCPCBImportDialog.tsx +1 -1
  20. package/src/components/PackageBuildsPage/DeploymentDetailsPage.tsx +56 -0
  21. package/src/components/PackageBuildsPage/build-preview-content.tsx +11 -0
  22. package/src/components/PackageBuildsPage/collapsible-section.tsx +70 -0
  23. package/src/components/PackageBuildsPage/deployment-details-panel.tsx +84 -0
  24. package/src/components/PackageBuildsPage/deployment-header.tsx +75 -0
  25. package/src/components/PackageCard.tsx +1 -10
  26. package/src/components/TrendingPackagesCarousel.tsx +5 -16
  27. package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +1 -1
  28. package/src/components/ViewPackagePage/components/preview-image-squares.tsx +2 -6
  29. package/src/components/package-port/CodeAndPreview.tsx +78 -267
  30. package/src/components/package-port/CodeEditor.tsx +30 -19
  31. package/src/components/package-port/CodeEditorHeader.tsx +7 -6
  32. package/src/components/package-port/EditorNav.tsx +17 -13
  33. package/src/components/ui/tree-view.tsx +3 -3
  34. package/src/hooks/use-current-package-id.ts +2 -8
  35. package/src/hooks/use-preview-images.ts +3 -15
  36. package/src/hooks/useFileManagement.ts +257 -38
  37. package/src/hooks/usePackageFilesLoader.ts +2 -2
  38. package/src/hooks/useUpdatePackageFilesMutation.ts +50 -24
  39. package/src/lib/utils/checkIfManualEditsImported.ts +9 -0
  40. package/src/pages/editor.tsx +2 -10
  41. package/src/pages/package-builds.tsx +33 -0
  42. package/src/pages/package-editor.tsx +2 -14
  43. package/src/hooks/use-get-fsmap-hash-for-package.ts +0 -19
@@ -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?${new URLSearchParams(
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?${new URLSearchParams(
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
- }