@tscircuit/fake-snippets 0.0.89 → 0.0.91
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/bun.lock +84 -108
- package/dist/bundle.js +493 -372
- package/fake-snippets-api/routes/api/autocomplete/create_autocomplete.ts +135 -0
- package/package.json +8 -10
- package/src/App.tsx +47 -2
- package/src/ContextProviders.tsx +0 -2
- package/src/components/CircuitJsonImportDialog.tsx +1 -1
- package/src/components/PackageBuildsPage/package-build-header.tsx +2 -12
- package/src/components/PageSearchComponent.tsx +2 -2
- package/src/components/SearchComponent.tsx +2 -2
- package/src/components/TrendingPackagesCarousel.tsx +2 -2
- package/src/components/dialogs/import-component-dialog.tsx +25 -0
- package/src/components/package-port/CodeAndPreview.tsx +1 -16
- package/src/components/package-port/CodeEditor.tsx +34 -8
- package/src/components/package-port/CodeEditorHeader.tsx +75 -13
- package/src/components/package-port/EditorNav.tsx +58 -65
- package/src/components/package-port/GlobalFindReplace.tsx +1 -1
- package/src/components/package-port/QuickOpen.tsx +1 -1
- package/src/hooks/use-axios.ts +2 -2
- package/src/hooks/use-code-completion-ai-api.ts +3 -3
- package/src/hooks/use-delete-package.ts +6 -2
- package/src/hooks/use-packages-base-api-url.ts +3 -0
- package/src/hooks/use-request-ai-review-mutation.ts +1 -1
- package/src/hooks/use-sign-in.ts +2 -2
- package/src/hooks/use-toast.tsx +1 -0
- package/src/hooks/useFileManagement.ts +10 -5
- package/src/lib/utils/findTargetFile.ts +1 -1
- package/src/lib/utils/package-utils.ts +10 -0
- package/src/main.tsx +0 -3
- package/src/pages/dashboard.tsx +12 -2
- package/src/pages/dev-login.tsx +2 -2
- package/src/pages/latest.tsx +2 -2
- package/src/pages/search.tsx +2 -2
- package/src/pages/trending.tsx +2 -2
- package/src/pages/user-profile.tsx +2 -2
- package/src/types/package.ts +4 -0
- package/vite.config.ts +0 -19
- package/src/build-watcher.ts +0 -52
- package/src/global.d.ts +0 -3
package/vite.config.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { defineConfig, Plugin, UserConfig } from "vite"
|
|
|
3
3
|
import type { PluginOption } from "vite"
|
|
4
4
|
import path, { extname } from "path"
|
|
5
5
|
import { readFileSync } from "fs"
|
|
6
|
-
import { execSync } from "child_process"
|
|
7
6
|
import react from "@vitejs/plugin-react"
|
|
8
7
|
import { ViteImageOptimizer } from "vite-plugin-image-optimizer"
|
|
9
8
|
import { getNodeHandler } from "winterspec/adapters/node"
|
|
@@ -119,23 +118,6 @@ function vercelSsrDevPlugin(): Plugin {
|
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
function buildIdPlugin(): Plugin {
|
|
123
|
-
return {
|
|
124
|
-
name: "build-id",
|
|
125
|
-
transformIndexHtml(html) {
|
|
126
|
-
try {
|
|
127
|
-
const hash = execSync("git rev-parse --short HEAD").toString().trim()
|
|
128
|
-
return html.replace(
|
|
129
|
-
/<\/head>/i,
|
|
130
|
-
` <meta name="tscircuit-build" content="${hash}"></head>`,
|
|
131
|
-
)
|
|
132
|
-
} catch {
|
|
133
|
-
return html
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
121
|
export default defineConfig(async (): Promise<UserConfig> => {
|
|
140
122
|
let proxyConfig: Record<string, any> | undefined
|
|
141
123
|
|
|
@@ -169,7 +151,6 @@ export default defineConfig(async (): Promise<UserConfig> => {
|
|
|
169
151
|
},
|
|
170
152
|
}),
|
|
171
153
|
vercelSsrDevPlugin(),
|
|
172
|
-
buildIdPlugin(),
|
|
173
154
|
]
|
|
174
155
|
|
|
175
156
|
if (process.env.VITE_BUNDLE_ANALYZE === "true" || 1) {
|
package/src/build-watcher.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { toast } from "sonner"
|
|
2
|
-
|
|
3
|
-
export function setupBuildWatcher() {
|
|
4
|
-
const meta = document.querySelector<HTMLMetaElement>(
|
|
5
|
-
'meta[name="tscircuit-build"]',
|
|
6
|
-
)
|
|
7
|
-
const currentId = meta?.content || ""
|
|
8
|
-
;(window as any).TSC_BUILD_ID = currentId
|
|
9
|
-
|
|
10
|
-
async function fetchBuildId(): Promise<string | null> {
|
|
11
|
-
try {
|
|
12
|
-
const res = await fetch("/api/generated-index", { cache: "no-store" })
|
|
13
|
-
const text = await res.text()
|
|
14
|
-
const match = text.match(
|
|
15
|
-
/<meta name="tscircuit-build" content="([^"]+)"/i,
|
|
16
|
-
)
|
|
17
|
-
return match ? match[1] : null
|
|
18
|
-
} catch (err) {
|
|
19
|
-
console.error("Failed to fetch build identifier", err)
|
|
20
|
-
return null
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let updateToastShown = false
|
|
25
|
-
|
|
26
|
-
async function checkForUpdate() {
|
|
27
|
-
const serverId = await fetchBuildId()
|
|
28
|
-
if (
|
|
29
|
-
serverId &&
|
|
30
|
-
serverId !== (window as any).TSC_BUILD_ID &&
|
|
31
|
-
!updateToastShown
|
|
32
|
-
) {
|
|
33
|
-
updateToastShown = true
|
|
34
|
-
toast("A new version of tscircuit.com is available.", {
|
|
35
|
-
action: {
|
|
36
|
-
label: "Reload",
|
|
37
|
-
onClick: () => window.location.reload(),
|
|
38
|
-
},
|
|
39
|
-
duration: Infinity,
|
|
40
|
-
position: "bottom-left",
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
document.addEventListener("visibilitychange", () => {
|
|
46
|
-
if (document.visibilityState === "visible") {
|
|
47
|
-
checkForUpdate()
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
setInterval(checkForUpdate, 5 * 60 * 1000)
|
|
52
|
-
}
|
package/src/global.d.ts
DELETED