@tscircuit/fake-snippets 0.0.1 → 0.0.3
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/.github/CODEOWNERS +1 -1
- package/.github/workflows/bun-pver-release.yml +27 -0
- package/bun.lockb +0 -0
- package/dist/bundle.js +27 -5
- package/fake-snippets-api/routes/api/snippets/create.ts +24 -2
- package/fake-snippets-api/routes/api/snippets/images/[author]/[snippet_name]/[typeFormat].ts +8 -2
- package/package.json +5 -5
- package/src/components/DownloadButtonAndMenu.tsx +1 -1
- package/src/components/ViewSnippetHeader.tsx +21 -0
- package/src/lib/download-fns/download-gltf.ts +3 -2
- package/dist/assets/editor_example_1-1000w.webp +0 -0
- package/dist/assets/editor_example_1-1200w.webp +0 -0
- package/dist/assets/editor_example_1-1600w.webp +0 -0
- package/dist/assets/editor_example_1-2000w.webp +0 -0
- package/dist/assets/editor_example_1-400w.webp +0 -0
- package/dist/assets/editor_example_1-600w.webp +0 -0
- package/dist/assets/editor_example_1-800w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1000w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1200w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1600w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-2000w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-400w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-600w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-800w.webp +0 -0
- package/dist/assets/editor_example_2-1000w.webp +0 -0
- package/dist/assets/editor_example_2-1200w.webp +0 -0
- package/dist/assets/editor_example_2-1600w.webp +0 -0
- package/dist/assets/editor_example_2-2000w.webp +0 -0
- package/dist/assets/editor_example_2-400w.webp +0 -0
- package/dist/assets/editor_example_2-600w.webp +0 -0
- package/dist/assets/editor_example_2-800w.webp +0 -0
- package/dist/assets/example_schematic-1000w.webp +0 -0
- package/dist/assets/example_schematic-1200w.webp +0 -0
- package/dist/assets/example_schematic-1600w.webp +0 -0
- package/dist/assets/example_schematic-2000w.webp +0 -0
- package/dist/assets/example_schematic-400w.webp +0 -0
- package/dist/assets/example_schematic-600w.webp +0 -0
- package/dist/assets/example_schematic-800w.webp +0 -0
- package/dist/robots.txt +0 -9
- package/dist/sitemap.xml +0 -118
|
@@ -16,7 +16,7 @@ export default withRouteSpec({
|
|
|
16
16
|
}),
|
|
17
17
|
jsonResponse: z.object({
|
|
18
18
|
ok: z.boolean(),
|
|
19
|
-
snippet: snippetSchema,
|
|
19
|
+
snippet: snippetSchema.optional(),
|
|
20
20
|
}),
|
|
21
21
|
})(async (req, ctx) => {
|
|
22
22
|
let {
|
|
@@ -28,9 +28,24 @@ export default withRouteSpec({
|
|
|
28
28
|
circuit_json,
|
|
29
29
|
dts,
|
|
30
30
|
} = req.jsonBody
|
|
31
|
+
|
|
31
32
|
if (!unscoped_name) {
|
|
32
33
|
unscoped_name = `untitled-${snippet_type}-${ctx.db.idCounter + 1}`
|
|
33
34
|
}
|
|
35
|
+
|
|
36
|
+
const existingSnippet = ctx.db.snippets.find(
|
|
37
|
+
(snippet) =>
|
|
38
|
+
snippet.unscoped_name === unscoped_name &&
|
|
39
|
+
snippet.owner_name === ctx.auth.github_username,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if (existingSnippet) {
|
|
43
|
+
return ctx.error(400, {
|
|
44
|
+
error_code: "snippet_already_exists",
|
|
45
|
+
message: "You have already forked this snippet in your account.",
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
34
49
|
const newSnippet: z.input<typeof snippetSchema> = {
|
|
35
50
|
snippet_id: `snippet_${ctx.db.idCounter + 1}`,
|
|
36
51
|
name: `${ctx.auth.github_username}/${unscoped_name}`,
|
|
@@ -46,7 +61,14 @@ export default withRouteSpec({
|
|
|
46
61
|
dts,
|
|
47
62
|
}
|
|
48
63
|
|
|
49
|
-
|
|
64
|
+
try {
|
|
65
|
+
ctx.db.addSnippet(newSnippet)
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return ctx.error(500, {
|
|
68
|
+
error_code: "snippet_creation_failed",
|
|
69
|
+
message: `Failed to create snippet: ${error}`,
|
|
70
|
+
})
|
|
71
|
+
}
|
|
50
72
|
|
|
51
73
|
return ctx.json({
|
|
52
74
|
ok: true,
|
package/fake-snippets-api/routes/api/snippets/images/[author]/[snippet_name]/[typeFormat].ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AnyCircuitElement } from "circuit-json"
|
|
2
2
|
import {
|
|
3
|
+
convertCircuitJsonToAssemblySvg,
|
|
3
4
|
convertCircuitJsonToPcbSvg,
|
|
4
5
|
convertCircuitJsonToSchematicSvg,
|
|
5
6
|
} from "circuit-to-svg"
|
|
@@ -41,10 +42,11 @@ export default withRouteSpec({
|
|
|
41
42
|
|
|
42
43
|
// Check if the type is valid
|
|
43
44
|
const type = typeFormat.split(".")[0]
|
|
44
|
-
|
|
45
|
+
const typesValid = ["schematic", "pcb", "assembly"]
|
|
46
|
+
if (!typesValid.includes(type)) {
|
|
45
47
|
return ctx.error(400, {
|
|
46
48
|
error_code: "invalid_type",
|
|
47
|
-
message:
|
|
49
|
+
message: `Type must be '${typesValid.join("' or '")}'`,
|
|
48
50
|
})
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -58,6 +60,10 @@ export default withRouteSpec({
|
|
|
58
60
|
svg = convertCircuitJsonToPcbSvg(
|
|
59
61
|
snippet.circuit_json as AnyCircuitElement[],
|
|
60
62
|
)
|
|
63
|
+
} else if (type === "assembly") {
|
|
64
|
+
svg = convertCircuitJsonToAssemblySvg(
|
|
65
|
+
snippet.circuit_json as AnyCircuitElement[],
|
|
66
|
+
)
|
|
61
67
|
} else {
|
|
62
68
|
return ctx.error(500, {
|
|
63
69
|
error_code: "unknown_error",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/fake-snippets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@radix-ui/react-toggle": "^1.1.0",
|
|
62
62
|
"@radix-ui/react-toggle-group": "^1.1.0",
|
|
63
63
|
"@radix-ui/react-tooltip": "^1.1.2",
|
|
64
|
-
"@tscircuit/3d-viewer": "^0.0.
|
|
64
|
+
"@tscircuit/3d-viewer": "^0.0.96",
|
|
65
65
|
"@tscircuit/footprinter": "^0.0.99",
|
|
66
66
|
"@tscircuit/layout": "^0.0.29",
|
|
67
67
|
"@tscircuit/math-utils": "^0.0.10",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"codemirror": "^6.0.1",
|
|
88
88
|
"country-list": "^2.3.0",
|
|
89
89
|
"date-fns": "^4.1.0",
|
|
90
|
-
"dsn-converter": "^0.0.
|
|
90
|
+
"dsn-converter": "^0.0.57",
|
|
91
91
|
"easyeda": "^0.0.62",
|
|
92
92
|
"embla-carousel-react": "^8.3.0",
|
|
93
93
|
"extract-codefence": "^0.0.4",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"@babel/standalone": "^7.26.2",
|
|
130
130
|
"@biomejs/biome": "^1.9.2",
|
|
131
131
|
"@playwright/test": "^1.48.0",
|
|
132
|
-
"@tscircuit/core": "^0.0.
|
|
132
|
+
"@tscircuit/core": "^0.0.269",
|
|
133
133
|
"@tscircuit/prompt-benchmarks": "^0.0.20",
|
|
134
134
|
"@types/babel__standalone": "^7.1.7",
|
|
135
135
|
"@types/bun": "^1.1.10",
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
"@typescript/vfs": "^1.6.0",
|
|
143
143
|
"@vitejs/plugin-react": "^4.3.1",
|
|
144
144
|
"autoprefixer": "^10.4.20",
|
|
145
|
-
"circuit-to-svg": "^0.0.
|
|
145
|
+
"circuit-to-svg": "^0.0.101",
|
|
146
146
|
"globals": "^15.9.0",
|
|
147
147
|
"postcss": "^8.4.47",
|
|
148
148
|
"prismjs": "^1.29.0",
|
|
@@ -86,7 +86,7 @@ export function DownloadButtonAndMenu({
|
|
|
86
86
|
<Download className="mr-1 h-3 w-3" />
|
|
87
87
|
<span className="flex-grow mr-6">3D Model</span>
|
|
88
88
|
<span className="text-[0.6rem] bg-green-500 opacity-80 text-white font-mono rounded-md px-1 text-center py-0.5 mr-1">
|
|
89
|
-
|
|
89
|
+
glb
|
|
90
90
|
</span>
|
|
91
91
|
</DropdownMenuItem>
|
|
92
92
|
<DropdownMenuItem
|
|
@@ -40,6 +40,13 @@ export default function ViewSnippetHeader() {
|
|
|
40
40
|
owner_name: session.github_username,
|
|
41
41
|
code: snippet.code,
|
|
42
42
|
})
|
|
43
|
+
|
|
44
|
+
if (!data.ok) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
data.error || "Unknown error occurred while forking snippet.",
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
43
50
|
return data.snippet
|
|
44
51
|
},
|
|
45
52
|
{
|
|
@@ -51,6 +58,20 @@ export default function ViewSnippetHeader() {
|
|
|
51
58
|
onSuccess?.(forkedSnippet)
|
|
52
59
|
},
|
|
53
60
|
onError: (error: any) => {
|
|
61
|
+
// Check if the error message contains 'already exists'
|
|
62
|
+
if (error.message?.includes("already forked")) {
|
|
63
|
+
toast({
|
|
64
|
+
title: "Snippet already exists",
|
|
65
|
+
description: error.message,
|
|
66
|
+
variant: "destructive", // You can style this variant differently
|
|
67
|
+
})
|
|
68
|
+
} else {
|
|
69
|
+
toast({
|
|
70
|
+
title: "Error",
|
|
71
|
+
description: "Failed to fork snippet. Please try again.",
|
|
72
|
+
variant: "destructive", // Use destructive variant for errors
|
|
73
|
+
})
|
|
74
|
+
}
|
|
54
75
|
console.error("Error forking snippet:", error)
|
|
55
76
|
},
|
|
56
77
|
},
|
|
@@ -13,7 +13,7 @@ export const downloadGltf = async (
|
|
|
13
13
|
|
|
14
14
|
if (!threeJsObject) {
|
|
15
15
|
throw new Error(
|
|
16
|
-
"
|
|
16
|
+
"To download the 3D model, please open the 3D view first and run the snippet",
|
|
17
17
|
)
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -45,5 +45,6 @@ export const downloadGltf = async (
|
|
|
45
45
|
|
|
46
46
|
const gltfBlob = await gltfPromise
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const extension = options.binary ? ".glb" : ".gltf"
|
|
49
|
+
saveAs(gltfBlob, fileName + extension)
|
|
49
50
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/robots.txt
DELETED
package/dist/sitemap.xml
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
3
|
-
<url>
|
|
4
|
-
<loc>https://tscircuit.com/</loc>
|
|
5
|
-
<changefreq>weekly</changefreq>
|
|
6
|
-
<priority>1.0</priority>
|
|
7
|
-
</url>
|
|
8
|
-
<url>
|
|
9
|
-
<loc>https://tscircuit.com/editor</loc>
|
|
10
|
-
<changefreq>weekly</changefreq>
|
|
11
|
-
<priority>0.9</priority>
|
|
12
|
-
</url>
|
|
13
|
-
<url>
|
|
14
|
-
<loc>https://tscircuit.com/playground</loc>
|
|
15
|
-
<changefreq>weekly</changefreq>
|
|
16
|
-
<priority>0.9</priority>
|
|
17
|
-
</url>
|
|
18
|
-
<url>
|
|
19
|
-
<loc>https://tscircuit.com/quickstart</loc>
|
|
20
|
-
<changefreq>monthly</changefreq>
|
|
21
|
-
<priority>0.8</priority>
|
|
22
|
-
</url>
|
|
23
|
-
<url>
|
|
24
|
-
<loc>https://tscircuit.com/dashboard</loc>
|
|
25
|
-
<changefreq>weekly</changefreq>
|
|
26
|
-
<priority>0.7</priority>
|
|
27
|
-
</url>
|
|
28
|
-
<url>
|
|
29
|
-
<loc>https://tscircuit.com/newest</loc>
|
|
30
|
-
<changefreq>daily</changefreq>
|
|
31
|
-
<priority>0.8</priority>
|
|
32
|
-
</url>
|
|
33
|
-
<url>
|
|
34
|
-
<loc>https://tscircuit.com/search</loc>
|
|
35
|
-
<changefreq>weekly</changefreq>
|
|
36
|
-
<priority>0.7</priority>
|
|
37
|
-
</url>
|
|
38
|
-
<url>
|
|
39
|
-
<loc>https://tscircuit.com/settings</loc>
|
|
40
|
-
<changefreq>monthly</changefreq>
|
|
41
|
-
<priority>0.6</priority>
|
|
42
|
-
</url>
|
|
43
|
-
<url>
|
|
44
|
-
<loc>https://tscircuit.com/community/join-redirect</loc>
|
|
45
|
-
<changefreq>monthly</changefreq>
|
|
46
|
-
<priority>0.6</priority>
|
|
47
|
-
</url>
|
|
48
|
-
<url>
|
|
49
|
-
<loc>https://tscircuit.com/legal/terms-of-service</loc>
|
|
50
|
-
<changefreq>yearly</changefreq>
|
|
51
|
-
<priority>0.3</priority>
|
|
52
|
-
</url>
|
|
53
|
-
<url>
|
|
54
|
-
<loc>https://tscircuit.com/legal/privacy-policy</loc>
|
|
55
|
-
<changefreq>yearly</changefreq>
|
|
56
|
-
<priority>0.3</priority>
|
|
57
|
-
</url>
|
|
58
|
-
<url>
|
|
59
|
-
<loc>https://tscircuit.com/techmannih/regulator-SPX1117M3L50TR</loc>
|
|
60
|
-
<lastmod>2025-01-07T02:12:09.440Z</lastmod>
|
|
61
|
-
<changefreq>weekly</changefreq>
|
|
62
|
-
<priority>0.7</priority>
|
|
63
|
-
</url>
|
|
64
|
-
<url>
|
|
65
|
-
<loc>https://tscircuit.com/seveibar/HS91L02W2C01</loc>
|
|
66
|
-
<lastmod>2025-01-06T01:41:28.137Z</lastmod>
|
|
67
|
-
<changefreq>weekly</changefreq>
|
|
68
|
-
<priority>0.7</priority>
|
|
69
|
-
</url>
|
|
70
|
-
<url>
|
|
71
|
-
<loc>https://tscircuit.com/AnasSarkiz/grid-of-LEDs-with-an-ESP32</loc>
|
|
72
|
-
<lastmod>2025-01-15T12:29:08.815Z</lastmod>
|
|
73
|
-
<changefreq>weekly</changefreq>
|
|
74
|
-
<priority>0.7</priority>
|
|
75
|
-
</url>
|
|
76
|
-
<url>
|
|
77
|
-
<loc>https://tscircuit.com/techmannih/blinking-led-circuit</loc>
|
|
78
|
-
<lastmod>2025-01-05T02:51:31.724Z</lastmod>
|
|
79
|
-
<changefreq>weekly</changefreq>
|
|
80
|
-
<priority>0.7</priority>
|
|
81
|
-
</url>
|
|
82
|
-
<url>
|
|
83
|
-
<loc>https://tscircuit.com/imrishabh18/testing-123456</loc>
|
|
84
|
-
<lastmod>2024-12-03T11:47:21.770Z</lastmod>
|
|
85
|
-
<changefreq>weekly</changefreq>
|
|
86
|
-
<priority>0.7</priority>
|
|
87
|
-
</url>
|
|
88
|
-
<url>
|
|
89
|
-
<loc>https://tscircuit.com/Abse2001/OR-Gate-Chip</loc>
|
|
90
|
-
<lastmod>2024-12-01T19:50:12.221Z</lastmod>
|
|
91
|
-
<changefreq>weekly</changefreq>
|
|
92
|
-
<priority>0.7</priority>
|
|
93
|
-
</url>
|
|
94
|
-
<url>
|
|
95
|
-
<loc>https://tscircuit.com/anas-sarkez/Arduino_Nano</loc>
|
|
96
|
-
<lastmod>2024-11-23T21:51:52.436Z</lastmod>
|
|
97
|
-
<changefreq>weekly</changefreq>
|
|
98
|
-
<priority>0.7</priority>
|
|
99
|
-
</url>
|
|
100
|
-
<url>
|
|
101
|
-
<loc>https://tscircuit.com/seveibar/smd-usb-c</loc>
|
|
102
|
-
<lastmod>2024-11-14T21:18:02.296Z</lastmod>
|
|
103
|
-
<changefreq>weekly</changefreq>
|
|
104
|
-
<priority>0.7</priority>
|
|
105
|
-
</url>
|
|
106
|
-
<url>
|
|
107
|
-
<loc>https://tscircuit.com/seveibar/a555timer</loc>
|
|
108
|
-
<lastmod>2024-10-14T17:46:25.789Z</lastmod>
|
|
109
|
-
<changefreq>weekly</changefreq>
|
|
110
|
-
<priority>0.7</priority>
|
|
111
|
-
</url>
|
|
112
|
-
<url>
|
|
113
|
-
<loc>https://tscircuit.com/seveibar/Key</loc>
|
|
114
|
-
<lastmod>2025-01-02T19:16:31.127Z</lastmod>
|
|
115
|
-
<changefreq>weekly</changefreq>
|
|
116
|
-
<priority>0.7</priority>
|
|
117
|
-
</url>
|
|
118
|
-
</urlset>
|