@tscircuit/fake-snippets 0.0.49 → 0.0.51

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.
@@ -7,22 +7,12 @@ import {
7
7
  usePackageStarsByName,
8
8
  } from "@/hooks/use-package-stars"
9
9
  import { LockClosedIcon } from "@radix-ui/react-icons"
10
- import { GitFork, Star } from "lucide-react"
10
+ import { GitFork, Package, Star } from "lucide-react"
11
11
  import { Link } from "wouter"
12
12
  import { useOrderDialog } from "@tscircuit/runframe"
13
13
  import { useEffect } from "react"
14
-
15
- interface PackageInfo {
16
- name: string
17
- unscoped_name: string
18
- owner_github_username: string
19
- star_count: string
20
- description: string
21
- ai_description: string
22
- creator_account_id?: string
23
- owner_org_id?: string
24
- package_id: string
25
- }
14
+ import { useGlobalStore } from "@/hooks/use-global-store"
15
+ import { PackageInfo } from "@/lib/types"
26
16
 
27
17
  interface PackageHeaderProps {
28
18
  packageInfo?: PackageInfo
@@ -37,6 +27,7 @@ export default function PackageHeader({
37
27
  }: PackageHeaderProps) {
38
28
  const author = packageInfo?.owner_github_username
39
29
  const packageName = packageInfo?.unscoped_name
30
+ const sessionToken = useGlobalStore((s) => s.session?.token)
40
31
 
41
32
  const { OrderDialog, isOpen, open, close, stage, setStage } = useOrderDialog()
42
33
  const { data: starData, isLoading: isStarDataLoading } =
@@ -70,7 +61,11 @@ export default function PackageHeader({
70
61
  window.TSCIRCUIT_REGISTRY_API_BASE_URL =
71
62
  import.meta.env.VITE_TSCIRCUIT_REGISTRY_API_URL ??
72
63
  `${window.location.origin}/api`
73
- }, [])
64
+ window.TSCIRCUIT_REGISTRY_TOKEN = sessionToken ?? ""
65
+ // TODO: replace with production stripe checkout base url
66
+ window.TSCIRCUIT_STRIPE_CHECKOUT_BASE_URL =
67
+ import.meta.env.VITE_TSCIRCUIT_TEST_STRIPE_CHECKOUT_BASE_URL
68
+ }, [sessionToken])
74
69
 
75
70
  return (
76
71
  <header className="bg-white border-b border-gray-200 py-4">
@@ -109,13 +104,9 @@ export default function PackageHeader({
109
104
  )}
110
105
  </div>
111
106
  <div className="items-center space-x-2 hidden md:flex">
112
- <Button
113
- size="sm"
114
- variant="default"
115
- className="bg-blue-600 hover:bg-blue-700"
116
- onClick={open}
117
- >
118
- Place Order ~$50
107
+ <Button variant="outline" size="sm" onClick={open}>
108
+ <Package className="w-4 h-4 mr-2" />
109
+ Order ~$50
119
110
  </Button>
120
111
  <Button
121
112
  variant="outline"
@@ -184,6 +175,7 @@ export default function PackageHeader({
184
175
  onClose={close}
185
176
  stage={stage}
186
177
  setStage={setStage}
178
+ packageReleaseId={packageInfo?.latest_package_release_id}
187
179
  />
188
180
  </header>
189
181
  )
@@ -5,7 +5,6 @@ import MainContentHeader from "./main-content-header"
5
5
  import Sidebar from "./sidebar"
6
6
  import MobileSidebar from "./mobile-sidebar"
7
7
  import ImportantFilesView from "./important-files-view"
8
- import { ShikiCodeViewer } from "./ShikiCodeViewer"
9
8
 
10
9
  // Tab Views
11
10
  import FilesView from "./tab-views/files-view"
@@ -16,10 +15,10 @@ import BOMView from "./tab-views/bom-view"
16
15
  import { isPackageFileImportant } from "../utils/is-package-file-important"
17
16
  import Header from "@/components/Header"
18
17
  import Footer from "@/components/Footer"
19
- import ViewSnippetHeader from "@/components/ViewSnippetHeader"
20
18
  import PackageHeader from "./package-header"
21
19
  import { useGlobalStore } from "@/hooks/use-global-store"
22
20
  import { useLocation } from "wouter"
21
+ import { PackageInfo } from "@/lib/types"
23
22
 
24
23
  interface PackageFile {
25
24
  package_file_id: string
@@ -30,19 +29,6 @@ interface PackageFile {
30
29
  created_at: string // iso-8601
31
30
  }
32
31
 
33
- interface PackageInfo {
34
- name: string
35
- unscoped_name: string
36
- owner_github_username: string
37
- star_count: string
38
- description: string
39
- ai_description: string
40
- ai_usage_instructions: string
41
- creator_account_id?: string
42
- owner_org_id?: string
43
- package_id: string
44
- }
45
-
46
32
  interface RepoPageContentProps {
47
33
  packageFiles?: PackageFile[]
48
34
  importantFilePaths?: string[]
@@ -9,22 +9,7 @@ import { useEditPackageDetailsDialog } from "@/components/dialogs/edit-package-d
9
9
  import { useState, useEffect, useMemo } from "react"
10
10
  import { usePackageFile } from "@/hooks/use-package-files"
11
11
  import { getLicenseFromLicenseContent } from "@/lib/getLicenseFromLicenseContent"
12
-
13
- export interface PackageInfo {
14
- name: string
15
- unscoped_name: string
16
- owner_github_username: string
17
- star_count: string
18
- description: string
19
- ai_description: string
20
- creator_account_id?: string
21
- owner_org_id?: string
22
- is_package?: boolean
23
- website?: string
24
- license?: string
25
- package_id?: string
26
- }
27
-
12
+ import { PackageInfo } from "@/lib/types"
28
13
  interface SidebarAboutSectionProps {
29
14
  packageInfo?: PackageInfo
30
15
  isLoading?: boolean
@@ -139,6 +139,10 @@ export const CodeEditor = ({
139
139
  resolveJsonModule: true,
140
140
  })
141
141
 
142
+ // Add alias for tscircuit -> @tscircuit/core
143
+ const tscircuitAliasDeclaration = `declare module "tscircuit" { export * from "@tscircuit/core"; }`
144
+ env.createFile("tscircuit-alias.d.ts", tscircuitAliasDeclaration)
145
+
142
146
  // Initialize ATA
143
147
  const ataConfig: ATABootstrapConfig = {
144
148
  projectName: "my-project",
@@ -339,10 +343,21 @@ export const CodeEditor = ({
339
343
  },
340
344
  }),
341
345
  EditorView.theme({
342
- ".cm-content .cm-underline": {
343
- textDecoration: "underline",
344
- textDecorationColor: "rgba(0, 0, 255, 0.3)",
345
- cursor: "pointer",
346
+ ".cm-tooltip-hover": {
347
+ maxWidth: "600px",
348
+ padding: "12px",
349
+ maxHeight: "400px",
350
+ borderRadius: "0.5rem",
351
+ backgroundColor: "#fff",
352
+ color: "#0f172a",
353
+ border: "1px solid #e2e8f0",
354
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.08)",
355
+ fontSize: "14px",
356
+ fontFamily: "monospace",
357
+ whiteSpace: "pre-wrap",
358
+ lineHeight: "1.6",
359
+ overflow: "auto",
360
+ zIndex: "9999",
346
361
  },
347
362
  }),
348
363
  EditorView.decorations.of((view) => {
@@ -383,8 +398,7 @@ export const CodeEditor = ({
383
398
 
384
399
  viewRef.current = view
385
400
 
386
- // Initial ATA run for index.tsx
387
- if (currentFile === "index.tsx") {
401
+ if (currentFile.endsWith(".tsx") || currentFile.endsWith(".ts")) {
388
402
  ata(`${defaultImports}${code}`)
389
403
  }
390
404
  // files.forEach(({path, content}) => {
@@ -0,0 +1,26 @@
1
+ import { useState, useEffect } from "react"
2
+ import { getSingletonHighlighter, Highlighter } from "shiki"
3
+
4
+ let cachedHighlighter: Highlighter | null = null
5
+
6
+ export const useShikiHighlighter = () => {
7
+ const [highlighter, setHighlighter] = useState<Highlighter | null>(null)
8
+ const [isLoading, setIsLoading] = useState(true)
9
+
10
+ useEffect(() => {
11
+ const fetchHighlighter = async () => {
12
+ if (!cachedHighlighter) {
13
+ cachedHighlighter = await getSingletonHighlighter({
14
+ themes: ["github-dark", "github-light"],
15
+ langs: ["typescript", "tsx"],
16
+ })
17
+ }
18
+ setHighlighter(cachedHighlighter)
19
+ setIsLoading(false)
20
+ }
21
+
22
+ fetchHighlighter()
23
+ }, [])
24
+
25
+ return { highlighter, isLoading }
26
+ }
package/src/index.css CHANGED
@@ -7,6 +7,12 @@
7
7
  }
8
8
  }
9
9
 
10
+ .shiki {
11
+ font-family: "Fira Code", monospace;
12
+ font-size: 14px;
13
+ line-height: 1.6;
14
+ }
15
+
10
16
  @keyframes fadeIn {
11
17
  from {
12
18
  opacity: 0;
@@ -0,0 +1,10 @@
1
+ import posthog from "posthog-js"
2
+
3
+ if (!posthog.__loaded) {
4
+ posthog.init("phc_htd8AQjSfVEsFCLQMAiUooG4Q0DKBCjqYuQglc9V3Wo", {
5
+ api_host: "https://postpig.tscircuit.com",
6
+ person_profiles: "always",
7
+ })
8
+ }
9
+
10
+ export { posthog }
package/src/lib/types.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  declare global {
2
2
  interface Window {
3
3
  TSCIRCUIT_REGISTRY_API_BASE_URL: string
4
+ TSCIRCUIT_REGISTRY_TOKEN: string
5
+ TSCIRCUIT_STRIPE_CHECKOUT_BASE_URL: string
4
6
  TSCIRCUIT_3D_OBJECT_REF: any
5
7
  __DEBUG_CODE_EDITOR_FS_MAP: Map<string, string>
6
8
  prettier: {
@@ -9,3 +11,17 @@ declare global {
9
11
  prettierPlugins: any
10
12
  }
11
13
  }
14
+
15
+ export interface PackageInfo {
16
+ name: string
17
+ unscoped_name: string
18
+ owner_github_username: string
19
+ star_count: string
20
+ description: string
21
+ ai_description: string
22
+ ai_usage_instructions: string
23
+ creator_account_id?: string
24
+ owner_org_id?: string
25
+ package_id: string
26
+ latest_package_release_id: string
27
+ }
@@ -53,7 +53,7 @@ export const UserProfilePage = () => {
53
53
  return response.data.snippets
54
54
  },
55
55
  {
56
- enabled: activeTab === "starred", // Only fetch when starred tab is active
56
+ enabled: activeTab === "starred",
57
57
  },
58
58
  )
59
59
 
@@ -76,8 +76,18 @@ export const UserProfilePage = () => {
76
76
  ?.sort((a, b) => {
77
77
  switch (filter) {
78
78
  case "most-recent":
79
+ if (activeTab === "starred") {
80
+ const aTime = a.starred_at || a.updated_at
81
+ const bTime = b.starred_at || b.updated_at
82
+ return bTime.localeCompare(aTime)
83
+ }
79
84
  return b.updated_at.localeCompare(a.updated_at)
80
85
  case "least-recent":
86
+ if (activeTab === "starred") {
87
+ return (a.starred_at || a.updated_at).localeCompare(
88
+ b.starred_at || b.updated_at,
89
+ )
90
+ }
81
91
  return a.updated_at.localeCompare(b.updated_at)
82
92
  case "most-starred":
83
93
  return (b.star_count || 0) - (a.star_count || 0)
@@ -43,5 +43,5 @@ export default {
43
43
  },
44
44
  },
45
45
  },
46
- plugins: ["tailwindcss-animate"],
46
+ plugins: ["tailwindcss-animate", require("@tailwindcss/typography")],
47
47
  }