@tscircuit/runframe 0.0.11 → 0.0.12
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/README.md +31 -1
- package/package.json +10 -2
- package/.github/workflows/bun-formatcheck.yml +0 -26
- package/.github/workflows/bun-pver-release.yml +0 -25
- package/.github/workflows/bun-typecheck.yml +0 -26
- package/biome.json +0 -57
- package/bun.lockb +0 -0
- package/cosmos.config.json +0 -3
- package/cosmos.decorator.tsx +0 -3
- package/examples/resistor.fixture.tsx +0 -12
- package/examples/runframe-with-api-1.fixture.tsx +0 -41
- package/examples/runframe1-basic.fixture.tsx +0 -19
- package/index.html +0 -13
- package/lib/components/BomTable.tsx +0 -69
- package/lib/components/CircuitJsonPreview.tsx +0 -348
- package/lib/components/CircuitJsonTableViewer/CircuitJsonTableViewer.tsx +0 -315
- package/lib/components/CircuitJsonTableViewer/ClickableText.tsx +0 -20
- package/lib/components/CircuitJsonTableViewer/HeaderCell.tsx +0 -26
- package/lib/components/CircuitJsonTableViewer/Modal.tsx +0 -38
- package/lib/components/ErrorFallback.tsx +0 -25
- package/lib/components/ErrorTabContent.tsx +0 -86
- package/lib/components/PcbViewerWithContainerHeight.tsx +0 -47
- package/lib/components/PreviewEmptyState.tsx +0 -14
- package/lib/components/RunFrame.tsx +0 -68
- package/lib/components/RunFrameWithApi/index.tsx +0 -44
- package/lib/components/RunFrameWithApi/standalone.tsx +0 -6
- package/lib/components/RunFrameWithApi/store.ts +0 -122
- package/lib/components/RunFrameWithApi/types.ts +0 -43
- package/lib/components/ui/button.tsx +0 -57
- package/lib/components/ui/dropdown-menu.tsx +0 -203
- package/lib/components/ui/tabs.tsx +0 -53
- package/lib/dev/render-to-circuit-json.ts +0 -7
- package/lib/hooks/use-styles.ts +0 -17
- package/lib/preview.ts +0 -1
- package/lib/runner.ts +0 -2
- package/lib/utils/index.ts +0 -6
- package/lib/utils/pcbManualEditEventHandler.ts +0 -156
- package/postcss.config.js +0 -8
- package/renovate.json +0 -15
- package/scripts/build-css.ts +0 -26
- package/src/main.tsx +0 -13
- package/tailwind.config.js +0 -3
- package/tsconfig.json +0 -45
- package/vite.config.ts +0 -72
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Schematic, 3D and other previews.
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
14
14
|
```tsx
|
|
15
|
-
import { RunFrame } from "@tscircuit/runframe"
|
|
15
|
+
import { RunFrame } from "@tscircuit/runframe/runner"
|
|
16
16
|
|
|
17
17
|
const App = () => (
|
|
18
18
|
<RunFrame
|
|
@@ -34,6 +34,36 @@ circuit.add(
|
|
|
34
34
|
)
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
### Using CircuitJsonPreview Directly
|
|
38
|
+
|
|
39
|
+
If you already have circuit JSON and just want to display it:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { CircuitJsonPreview } from "@tscircuit/runframe/preview"
|
|
43
|
+
|
|
44
|
+
const App = () => (
|
|
45
|
+
<CircuitJsonPreview
|
|
46
|
+
circuitJson={myCircuitJson}
|
|
47
|
+
// Optional props
|
|
48
|
+
showCodeTab={false} // Show/hide the code editor tab
|
|
49
|
+
showJsonTab={true} // Show/hide the raw JSON viewer tab
|
|
50
|
+
className="h-screen" // Container className
|
|
51
|
+
headerClassName="px-4" // Header className
|
|
52
|
+
isFullScreen={false} // Toggle fullscreen mode
|
|
53
|
+
onToggleFullScreen={() => void} // Fullscreen toggle callback
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The CircuitJsonPreview component provides:
|
|
59
|
+
|
|
60
|
+
- PCB view with interactive component placement
|
|
61
|
+
- Schematic view
|
|
62
|
+
- 3D view
|
|
63
|
+
- Bill of Materials (BOM) table
|
|
64
|
+
- Circuit JSON viewer
|
|
65
|
+
- Error display
|
|
66
|
+
|
|
37
67
|
> Note: You should have tailwind installed in the parent project, this library
|
|
38
68
|
> works without installing tailwind but without the "css reset" things will look
|
|
39
69
|
> a bit off (e.g. you might see serif fonts), create an issue if that's
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/runframe",
|
|
3
|
-
"main": "dist/
|
|
3
|
+
"main": "dist/preview.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.12",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/preview.js",
|
|
8
|
+
"./preview": "./dist/preview.js",
|
|
9
|
+
"./runner": "./dist/runner.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
6
14
|
"scripts": {
|
|
7
15
|
"start": "cosmos",
|
|
8
16
|
"build": "bun run build:css && bun run build:standalone && bun run build:lib",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
-
name: Format Check
|
|
3
|
-
|
|
4
|
-
on:
|
|
5
|
-
push:
|
|
6
|
-
branches: [main]
|
|
7
|
-
pull_request:
|
|
8
|
-
branches: [main]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
format-check:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v3
|
|
16
|
-
|
|
17
|
-
- name: Setup bun
|
|
18
|
-
uses: oven-sh/setup-bun@v1
|
|
19
|
-
with:
|
|
20
|
-
bun-version: latest
|
|
21
|
-
|
|
22
|
-
- name: Install dependencies
|
|
23
|
-
run: bun install
|
|
24
|
-
|
|
25
|
-
- name: Run format check
|
|
26
|
-
run: bun run format:check
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
-
name: Publish to npm
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
jobs:
|
|
8
|
-
publish:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v3
|
|
12
|
-
- name: Setup bun
|
|
13
|
-
uses: oven-sh/setup-bun@v1
|
|
14
|
-
with:
|
|
15
|
-
bun-version: latest
|
|
16
|
-
- uses: actions/setup-node@v3
|
|
17
|
-
with:
|
|
18
|
-
node-version: 20
|
|
19
|
-
registry-url: https://registry.npmjs.org/
|
|
20
|
-
- run: npm install -g pver
|
|
21
|
-
- run: bun install --frozen-lockfile
|
|
22
|
-
- run: bun run build
|
|
23
|
-
- run: pver release
|
|
24
|
-
env:
|
|
25
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
-
name: Type Check
|
|
3
|
-
|
|
4
|
-
on:
|
|
5
|
-
push:
|
|
6
|
-
branches: [main]
|
|
7
|
-
pull_request:
|
|
8
|
-
branches: [main]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
type-check:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v3
|
|
16
|
-
|
|
17
|
-
- name: Setup bun
|
|
18
|
-
uses: oven-sh/setup-bun@v1
|
|
19
|
-
with:
|
|
20
|
-
bun-version: latest
|
|
21
|
-
|
|
22
|
-
- name: Install dependencies
|
|
23
|
-
run: bun i
|
|
24
|
-
|
|
25
|
-
- name: Run type check
|
|
26
|
-
run: bunx tsc --noEmit
|
package/biome.json
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
|
|
3
|
-
"organizeImports": {
|
|
4
|
-
"enabled": true
|
|
5
|
-
},
|
|
6
|
-
"formatter": {
|
|
7
|
-
"enabled": true,
|
|
8
|
-
"indentStyle": "space"
|
|
9
|
-
},
|
|
10
|
-
"files": {
|
|
11
|
-
"ignore": ["cosmos-export", "dist", "package.json"]
|
|
12
|
-
},
|
|
13
|
-
"javascript": {
|
|
14
|
-
"formatter": {
|
|
15
|
-
"jsxQuoteStyle": "double",
|
|
16
|
-
"quoteProperties": "asNeeded",
|
|
17
|
-
"trailingCommas": "all",
|
|
18
|
-
"semicolons": "asNeeded",
|
|
19
|
-
"arrowParentheses": "always",
|
|
20
|
-
"bracketSpacing": true,
|
|
21
|
-
"bracketSameLine": false
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"linter": {
|
|
25
|
-
"enabled": true,
|
|
26
|
-
"rules": {
|
|
27
|
-
"recommended": true,
|
|
28
|
-
"suspicious": {
|
|
29
|
-
"noExplicitAny": "off",
|
|
30
|
-
"noArrayIndexKey": "off"
|
|
31
|
-
},
|
|
32
|
-
"complexity": {
|
|
33
|
-
"noForEach": "info"
|
|
34
|
-
},
|
|
35
|
-
"correctness": {
|
|
36
|
-
"useExhaustiveDependencies": "off"
|
|
37
|
-
},
|
|
38
|
-
"a11y": {
|
|
39
|
-
"useKeyWithClickEvents": "off"
|
|
40
|
-
},
|
|
41
|
-
"style": {
|
|
42
|
-
"noUselessElse": "off",
|
|
43
|
-
"noNonNullAssertion": "off",
|
|
44
|
-
"useNumberNamespace": "off",
|
|
45
|
-
"noUnusedTemplateLiteral": "off",
|
|
46
|
-
"useFilenamingConvention": {
|
|
47
|
-
"level": "error",
|
|
48
|
-
"options": {
|
|
49
|
-
"strictCase": true,
|
|
50
|
-
"requireAscii": true,
|
|
51
|
-
"filenameCases": ["kebab-case", "export"]
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
package/bun.lockb
DELETED
|
Binary file
|
package/cosmos.config.json
DELETED
package/cosmos.decorator.tsx
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CircuitJsonPreview } from "lib/components/CircuitJsonPreview"
|
|
2
|
-
import { renderToCircuitJson } from "lib/dev/render-to-circuit-json"
|
|
3
|
-
|
|
4
|
-
export default () => (
|
|
5
|
-
<CircuitJsonPreview
|
|
6
|
-
circuitJson={renderToCircuitJson(
|
|
7
|
-
<board width="10mm" height="10mm">
|
|
8
|
-
<resistor name="R1" resistance="1k" footprint="0402" />
|
|
9
|
-
</board>,
|
|
10
|
-
)}
|
|
11
|
-
/>
|
|
12
|
-
)
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { RunFrameWithApi } from "lib/components/RunFrameWithApi"
|
|
2
|
-
import { useState, useEffect } from "react"
|
|
3
|
-
|
|
4
|
-
export default () => {
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
setTimeout(async () => {
|
|
7
|
-
fetch("/api/files/upsert", {
|
|
8
|
-
method: "POST",
|
|
9
|
-
headers: { "Content-Type": "application/json" },
|
|
10
|
-
body: JSON.stringify({
|
|
11
|
-
file_path: "main.tsx",
|
|
12
|
-
text_content: `
|
|
13
|
-
circuit.add(
|
|
14
|
-
<board width="10mm" height="10mm">
|
|
15
|
-
<resistor name="R1" resistance="1k" footprint="0402" />
|
|
16
|
-
<capacitor name="C1" capacitance="1uF" footprint="0603" pcbX={4} />
|
|
17
|
-
<trace from=".R1 .pin1" to=".C1 .pin1" />
|
|
18
|
-
</board>
|
|
19
|
-
)`,
|
|
20
|
-
}),
|
|
21
|
-
})
|
|
22
|
-
}, 500)
|
|
23
|
-
}, [])
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
typeof window !== "undefined" &&
|
|
27
|
-
window.location.origin.includes("vercel.app")
|
|
28
|
-
) {
|
|
29
|
-
return (
|
|
30
|
-
<div>
|
|
31
|
-
<h1>RunFrame with API</h1>
|
|
32
|
-
<p>
|
|
33
|
-
We don't currently deploy the API to vercel, try locally! The vite
|
|
34
|
-
plugin will automatically load it.
|
|
35
|
-
</p>
|
|
36
|
-
</div>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return <RunFrameWithApi />
|
|
41
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { RunFrame } from "lib/components/RunFrame"
|
|
2
|
-
import React from "react"
|
|
3
|
-
|
|
4
|
-
export default () => (
|
|
5
|
-
<RunFrame
|
|
6
|
-
fsMap={{
|
|
7
|
-
"main.tsx": `
|
|
8
|
-
circuit.add(
|
|
9
|
-
<board width="10mm" height="10mm">
|
|
10
|
-
<resistor name="R1" resistance="1k" footprint="0402" />
|
|
11
|
-
<capacitor name="C1" capacitance="1uF" footprint="0603" pcbX={4} />
|
|
12
|
-
<trace from=".R1 .pin1" to=".C1 .pin1" />
|
|
13
|
-
</board>
|
|
14
|
-
)
|
|
15
|
-
`,
|
|
16
|
-
}}
|
|
17
|
-
entrypoint="main.tsx"
|
|
18
|
-
/>
|
|
19
|
-
)
|
package/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>@tscircuit/runframe</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="root"></div>
|
|
10
|
-
<script src="https://cdn.tailwindcss.com"></script>
|
|
11
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { SupplierName } from "@tscircuit/props"
|
|
2
|
-
import type { AnyCircuitElement } from "circuit-json"
|
|
3
|
-
|
|
4
|
-
interface BomTableProps {
|
|
5
|
-
circuitJson: AnyCircuitElement[]
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const linkify = (supplier: string, partNumber: string) => {
|
|
9
|
-
if (supplier === "jlcpcb") {
|
|
10
|
-
return (
|
|
11
|
-
<a
|
|
12
|
-
className="underline text-blue-500"
|
|
13
|
-
target="_blank"
|
|
14
|
-
rel="noreferrer"
|
|
15
|
-
href={`https://jlcpcb.com/partdetail/${partNumber}`}
|
|
16
|
-
>
|
|
17
|
-
{partNumber}
|
|
18
|
-
</a>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
return partNumber
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const BomTable: React.FC<BomTableProps> = ({ circuitJson }) => {
|
|
25
|
-
const sourceComponents = circuitJson.filter(
|
|
26
|
-
(el) => el.type === "source_component",
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
const supplierColumns = new Set<SupplierName>()
|
|
30
|
-
for (const comp of sourceComponents) {
|
|
31
|
-
if (comp.supplier_part_numbers) {
|
|
32
|
-
for (const supplier of Object.keys(comp.supplier_part_numbers)) {
|
|
33
|
-
supplierColumns.add(supplier as SupplierName)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div className="overflow-x-auto">
|
|
40
|
-
<table className="w-full text-left text-sm">
|
|
41
|
-
<thead>
|
|
42
|
-
<tr className="border-b">
|
|
43
|
-
<th className="p-2">Name</th>
|
|
44
|
-
{Array.from(supplierColumns).map((supplier) => (
|
|
45
|
-
<th key={supplier} className="p-2 capitalize">
|
|
46
|
-
{supplier}
|
|
47
|
-
</th>
|
|
48
|
-
))}
|
|
49
|
-
</tr>
|
|
50
|
-
</thead>
|
|
51
|
-
<tbody>
|
|
52
|
-
{sourceComponents.map((comp) => (
|
|
53
|
-
<tr key={comp.source_component_id} className="border-b">
|
|
54
|
-
<td className="p-2">{comp.name}</td>
|
|
55
|
-
{Array.from(supplierColumns).map((supplier) => (
|
|
56
|
-
<td key={supplier} className="p-2">
|
|
57
|
-
{linkify(
|
|
58
|
-
supplier,
|
|
59
|
-
comp.supplier_part_numbers?.[supplier]?.[0] || "",
|
|
60
|
-
)}
|
|
61
|
-
</td>
|
|
62
|
-
))}
|
|
63
|
-
</tr>
|
|
64
|
-
))}
|
|
65
|
-
</tbody>
|
|
66
|
-
</table>
|
|
67
|
-
</div>
|
|
68
|
-
)
|
|
69
|
-
}
|