@tscircuit/fake-snippets 0.0.44 → 0.0.46
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/workflows/bun-pver-release.yml +1 -0
- package/bun.lock +43 -11
- package/dist/bundle.js +405 -335
- package/dist/schema.d.ts +1845 -0
- package/dist/schema.js +251 -0
- package/fake-snippets-api/routes/api/_fake/received_quotes.ts +66 -0
- package/fake-snippets-api/routes/api/package_releases/update.ts +25 -18
- package/package.json +8 -3
- package/src/components/CodeAndPreview.tsx +0 -1
- package/src/components/CodeEditor.tsx +0 -1
- package/src/components/CodeEditorHeader.tsx +0 -25
- package/src/components/EditorNav.tsx +10 -8
- package/src/components/ErrorOutline.tsx +35 -0
- package/src/components/FileSidebar.tsx +46 -16
- package/src/components/NotFound.tsx +37 -0
- package/src/components/PreviewContent.tsx +0 -6
- package/src/components/TrendingSnippetCarousel.tsx +1 -1
- package/src/components/ViewPackagePage/components/package-header.tsx +24 -3
- package/src/components/ViewPackagePage/utils/is-hidden-file.ts +0 -1
- package/src/components/dialogs/package-visibility-settings-dialog.tsx +10 -1
- package/src/components/dialogs/view-ts-files-dialog.tsx +0 -6
- package/src/components/package-port/CodeAndPreview.tsx +24 -9
- package/src/components/package-port/CodeEditor.tsx +26 -38
- package/src/components/package-port/CodeEditorHeader.tsx +117 -39
- package/src/components/package-port/EditorNav.tsx +10 -8
- package/src/components/ui/tree-view.tsx +5 -1
- package/src/{prettier.ts → lib/types.ts} +3 -1
- package/src/lib/utils/findTargetFile.ts +62 -0
- package/src/lib/utils/load-prettier.ts +3 -0
- package/src/pages/404.tsx +2 -33
- package/src/pages/package-editor.tsx +14 -3
- package/src/pages/user-profile.tsx +66 -27
- package/src/components/FootprintDialog.tsx +0 -339
- package/src/components/ParametersEditor.tsx +0 -140
- package/src/lib/utils/parseFootprintParams.ts +0 -52
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { Input } from "./ui/input"
|
|
2
|
-
|
|
3
|
-
interface ParametersEditorProps {
|
|
4
|
-
params: Record<string, any>
|
|
5
|
-
updateParam: (
|
|
6
|
-
key: string,
|
|
7
|
-
value: string | number | boolean | string[],
|
|
8
|
-
) => void
|
|
9
|
-
paramNames: Record<string, string>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const ParametersEditor = ({
|
|
13
|
-
params,
|
|
14
|
-
updateParam,
|
|
15
|
-
paramNames,
|
|
16
|
-
}: ParametersEditorProps) => {
|
|
17
|
-
const renderStringInput = (key: string, value: string) => {
|
|
18
|
-
if (key === "grid") {
|
|
19
|
-
let rows = "",
|
|
20
|
-
cols = ""
|
|
21
|
-
if (typeof value === "string") {
|
|
22
|
-
;[rows = "", cols = ""] = value.split("x").map(String)
|
|
23
|
-
} else if (typeof value === "number") {
|
|
24
|
-
rows = cols = String(value)
|
|
25
|
-
} else if (value && typeof value === "object") {
|
|
26
|
-
const grid = value as { x: number; y: number }
|
|
27
|
-
rows = String(grid.x || "")
|
|
28
|
-
cols = String(grid.y || "")
|
|
29
|
-
}
|
|
30
|
-
return (
|
|
31
|
-
<div className="flex gap-2 flex-1">
|
|
32
|
-
<Input
|
|
33
|
-
type="number"
|
|
34
|
-
value={rows || ""}
|
|
35
|
-
onChange={(e) => {
|
|
36
|
-
const newRows = e.target.value || "0"
|
|
37
|
-
const newCols = cols || "0"
|
|
38
|
-
updateParam(key, `${newRows}x${newCols}`)
|
|
39
|
-
}}
|
|
40
|
-
placeholder="Rows"
|
|
41
|
-
className="flex-1"
|
|
42
|
-
/>
|
|
43
|
-
<span className="flex items-center">×</span>
|
|
44
|
-
<Input
|
|
45
|
-
type="number"
|
|
46
|
-
value={cols || ""}
|
|
47
|
-
onChange={(e) => {
|
|
48
|
-
const newRows = rows || "0"
|
|
49
|
-
const newCols = e.target.value || "0"
|
|
50
|
-
updateParam(key, `${newRows}x${newCols}`)
|
|
51
|
-
}}
|
|
52
|
-
placeholder="Cols"
|
|
53
|
-
className="flex-1"
|
|
54
|
-
/>
|
|
55
|
-
</div>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (key === "missing") {
|
|
60
|
-
const missingArray = Array.isArray(value) ? value : []
|
|
61
|
-
return (
|
|
62
|
-
<div className="flex flex-wrap gap-2 items-center">
|
|
63
|
-
{missingArray.map((item, index) => (
|
|
64
|
-
<Input
|
|
65
|
-
key={index}
|
|
66
|
-
type="number"
|
|
67
|
-
value={item}
|
|
68
|
-
onChange={(e) => {
|
|
69
|
-
if (!e.target.value) {
|
|
70
|
-
const newArray = missingArray.filter((_, i) => i !== index)
|
|
71
|
-
updateParam(key, newArray)
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
const newArray = [...missingArray]
|
|
75
|
-
newArray[index] = e.target.value
|
|
76
|
-
updateParam(key, newArray)
|
|
77
|
-
}}
|
|
78
|
-
className="w-16 h-8 text-center p-1"
|
|
79
|
-
/>
|
|
80
|
-
))}
|
|
81
|
-
<button
|
|
82
|
-
onClick={() => {
|
|
83
|
-
updateParam(key, [...missingArray, "0"])
|
|
84
|
-
}}
|
|
85
|
-
className="w-8 h-8 flex items-center justify-center rounded border border-gray-200 hover:bg-gray-50"
|
|
86
|
-
>
|
|
87
|
-
+
|
|
88
|
-
</button>
|
|
89
|
-
</div>
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<Input
|
|
95
|
-
type="text"
|
|
96
|
-
value={value}
|
|
97
|
-
onChange={(e) => updateParam(key, e.target.value)}
|
|
98
|
-
className="flex-1"
|
|
99
|
-
/>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<div className="space-y-2">
|
|
105
|
-
<label className="text-sm font-medium">Parameters</label>
|
|
106
|
-
{Object.entries(params)
|
|
107
|
-
.filter(
|
|
108
|
-
([key]) => key !== "fn" && (key !== "num_pins" || !key.match(/\d/)),
|
|
109
|
-
)
|
|
110
|
-
.map(([key, value]) => {
|
|
111
|
-
return (
|
|
112
|
-
<div key={key} className="flex gap-2 items-center">
|
|
113
|
-
<label className="text-sm">
|
|
114
|
-
{paramNames[key] ? `${paramNames[key]} (${key})` : key}:
|
|
115
|
-
</label>
|
|
116
|
-
{typeof value === "boolean" ? (
|
|
117
|
-
<input
|
|
118
|
-
type="checkbox"
|
|
119
|
-
checked={value}
|
|
120
|
-
onChange={(e) => updateParam(key, e.target.checked)}
|
|
121
|
-
className="h-4 w-4"
|
|
122
|
-
/>
|
|
123
|
-
) : typeof value === "number" ? (
|
|
124
|
-
<Input
|
|
125
|
-
type="number"
|
|
126
|
-
value={value}
|
|
127
|
-
onChange={(e) => updateParam(key, e.target.value)}
|
|
128
|
-
className="flex-1"
|
|
129
|
-
/>
|
|
130
|
-
) : (
|
|
131
|
-
renderStringInput(key, value)
|
|
132
|
-
)}
|
|
133
|
-
</div>
|
|
134
|
-
)
|
|
135
|
-
})}
|
|
136
|
-
</div>
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export default ParametersEditor
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export interface FootprintParams {
|
|
2
|
-
[key: string]: string | number | boolean | string[]
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Parses and normalizes footprint parameters
|
|
7
|
-
* @param params Raw parameters from footprint
|
|
8
|
-
* @returns Normalized parameters with proper formatting
|
|
9
|
-
*/
|
|
10
|
-
export function parseFootprintParams(params: FootprintParams): FootprintParams {
|
|
11
|
-
if (params.grid) {
|
|
12
|
-
const grid = params.grid
|
|
13
|
-
if (typeof grid === "object" && grid !== null) {
|
|
14
|
-
const { x, y } = grid as any
|
|
15
|
-
params.grid = `${x}x${y}`
|
|
16
|
-
} else if (typeof grid === "string") {
|
|
17
|
-
const gridMatch = grid.match(/^(\d+)(?:x(\d+)?)?$/)
|
|
18
|
-
if (gridMatch) {
|
|
19
|
-
const [, x, y = x] = gridMatch
|
|
20
|
-
params.grid = `${x}x${y}`
|
|
21
|
-
}
|
|
22
|
-
} else if (typeof grid === "number") {
|
|
23
|
-
params.grid = `${grid}x${grid}`
|
|
24
|
-
}
|
|
25
|
-
delete params.grid3x3
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if ("missing" in params && typeof params.missing === "string") {
|
|
29
|
-
const value = params.missing
|
|
30
|
-
if (value === "") {
|
|
31
|
-
params.missing = []
|
|
32
|
-
} else if (!Array.isArray(value)) {
|
|
33
|
-
if (value.startsWith("missing(") && value.endsWith(")")) {
|
|
34
|
-
const pinsStr = value.slice(8, -1)
|
|
35
|
-
params.missing = pinsStr ? pinsStr.split(",").map((p) => p.trim()) : []
|
|
36
|
-
} else {
|
|
37
|
-
params.missing = value
|
|
38
|
-
.split(",")
|
|
39
|
-
.map((p) => p.trim())
|
|
40
|
-
.filter(Boolean)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
46
|
-
if (typeof value === "string" && !isNaN(Number(value)) && key !== "grid") {
|
|
47
|
-
params[key] = Number(Number(value).toFixed(2))
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
return params
|
|
52
|
-
}
|