circuit-json-to-tscircuit 0.0.48 → 0.0.49
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/dist/cli/main.js +2 -1
- package/package.json +2 -1
- package/tests/fixtures/create-ti-evm-roundtrip.ts +86 -0
- package/tests/fixtures/ti-evms/README.md +10 -0
- package/tests/fixtures/ti-evms/drv8307evm.circuit.json.gz +0 -0
- package/tests/fixtures/ti-evms/lm251772evm-pd.circuit.json.gz +0 -0
- package/tests/fixtures/ti-evms/lm5155evm-fly.circuit.json.gz +0 -0
- package/tests/fixtures/ti-evms/lmg342x-bb-evm.circuit.json.gz +0 -0
- package/tests/ti-evms/__snapshots__/ti-drv8307evm-roundtrip-pcb-comparison.snap.svg +8 -0
- package/tests/ti-evms/__snapshots__/ti-drv8307evm-roundtrip-schematic-comparison.snap.svg +57 -0
- package/tests/ti-evms/__snapshots__/ti-lm251772evm-pd-roundtrip-pcb-comparison.snap.svg +8 -0
- package/tests/ti-evms/__snapshots__/ti-lm251772evm-pd-roundtrip-schematic-comparison.snap.svg +99 -0
- package/tests/ti-evms/__snapshots__/ti-lm5155evm-fly-roundtrip-pcb-comparison.snap.svg +8 -0
- package/tests/ti-evms/__snapshots__/ti-lm5155evm-fly-roundtrip-schematic-comparison.snap.svg +57 -0
- package/tests/ti-evms/__snapshots__/ti-lmg342x-bb-evm-roundtrip-pcb-comparison.snap.svg +8 -0
- package/tests/ti-evms/__snapshots__/ti-lmg342x-bb-evm-roundtrip-schematic-comparison.snap.svg +57 -0
- package/tests/ti-evms/ti-drv8307evm-roundtrip.test.tsx +799 -0
- package/tests/ti-evms/ti-lm251772evm-pd-roundtrip.test.tsx +1087 -0
- package/tests/ti-evms/ti-lm5155evm-fly-roundtrip.test.tsx +738 -0
- package/tests/ti-evms/ti-lmg342x-bb-evm-roundtrip.test.tsx +1083 -0
package/dist/cli/main.js
CHANGED
|
@@ -16,7 +16,7 @@ var package_default = {
|
|
|
16
16
|
"./cli": "./dist/cli/main.js"
|
|
17
17
|
},
|
|
18
18
|
type: "module",
|
|
19
|
-
version: "0.0.
|
|
19
|
+
version: "0.0.48",
|
|
20
20
|
repository: {
|
|
21
21
|
type: "git",
|
|
22
22
|
url: "https://github.com/tscircuit/circuit-json-to-tscircuit.git"
|
|
@@ -42,6 +42,7 @@ var package_default = {
|
|
|
42
42
|
commander: "^13.1.0",
|
|
43
43
|
prettier: "^3.9.5",
|
|
44
44
|
shiki: "^4.3.1",
|
|
45
|
+
"stack-svgs": "^0.0.1",
|
|
45
46
|
tscircuit: "^0.0.1873",
|
|
46
47
|
tsup: "^8.3.5"
|
|
47
48
|
},
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"./cli": "./dist/cli/main.js"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.49",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/tscircuit/circuit-json-to-tscircuit.git"
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"commander": "^13.1.0",
|
|
33
33
|
"prettier": "^3.9.5",
|
|
34
34
|
"shiki": "^4.3.1",
|
|
35
|
+
"stack-svgs": "^0.0.1",
|
|
35
36
|
"tscircuit": "^0.0.1873",
|
|
36
37
|
"tsup": "^8.3.5"
|
|
37
38
|
},
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises"
|
|
2
|
+
import { join } from "node:path"
|
|
3
|
+
import { gunzipSync } from "node:zlib"
|
|
4
|
+
import type { CircuitJson } from "circuit-json"
|
|
5
|
+
import {
|
|
6
|
+
convertCircuitJsonToPcbSvg,
|
|
7
|
+
convertCircuitJsonToSchematicSvg,
|
|
8
|
+
} from "circuit-to-svg"
|
|
9
|
+
import { convertCircuitJsonToTscircuit } from "lib"
|
|
10
|
+
import { stackSvgsHorizontally } from "stack-svgs"
|
|
11
|
+
import { runTscircuitCode } from "tscircuit"
|
|
12
|
+
|
|
13
|
+
interface TiEvmRoundtripResult {
|
|
14
|
+
generatedTscircuit: string
|
|
15
|
+
pcbComparisonSvg: string
|
|
16
|
+
schematicComparisonSvg: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function createTiEvmRoundtrip({
|
|
20
|
+
componentName,
|
|
21
|
+
fixtureName,
|
|
22
|
+
}: {
|
|
23
|
+
componentName: string
|
|
24
|
+
fixtureName: string
|
|
25
|
+
}): Promise<TiEvmRoundtripResult> {
|
|
26
|
+
const compressedFixture = await readFile(
|
|
27
|
+
join(import.meta.dir, "ti-evms", `${fixtureName}.circuit.json.gz`),
|
|
28
|
+
)
|
|
29
|
+
const sourceCircuitJson = JSON.parse(
|
|
30
|
+
gunzipSync(compressedFixture).toString("utf8"),
|
|
31
|
+
) as CircuitJson
|
|
32
|
+
const generatedTscircuit = convertCircuitJsonToTscircuit(sourceCircuitJson, {
|
|
33
|
+
componentName,
|
|
34
|
+
})
|
|
35
|
+
const renderedCircuitJson = (await runTscircuitCode(
|
|
36
|
+
generatedTscircuit,
|
|
37
|
+
)) as CircuitJson
|
|
38
|
+
|
|
39
|
+
const sourcePcbSvg = convertCircuitJsonToPcbSvg(sourceCircuitJson, {
|
|
40
|
+
matchBoardAspectRatio: true,
|
|
41
|
+
})
|
|
42
|
+
const renderedPcbSvg = convertCircuitJsonToPcbSvg(renderedCircuitJson, {
|
|
43
|
+
matchBoardAspectRatio: true,
|
|
44
|
+
})
|
|
45
|
+
const sourceSchematicSvg = convertCircuitJsonToSchematicSvg(sourceCircuitJson)
|
|
46
|
+
const renderedSchematicSvg =
|
|
47
|
+
convertCircuitJsonToSchematicSvg(renderedCircuitJson)
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
generatedTscircuit,
|
|
51
|
+
pcbComparisonSvg: createComparisonSvg({
|
|
52
|
+
fixtureName,
|
|
53
|
+
kind: "PCB",
|
|
54
|
+
renderedSvg: renderedPcbSvg,
|
|
55
|
+
sourceSvg: sourcePcbSvg,
|
|
56
|
+
}),
|
|
57
|
+
schematicComparisonSvg: createComparisonSvg({
|
|
58
|
+
fixtureName,
|
|
59
|
+
kind: "schematic",
|
|
60
|
+
renderedSvg: renderedSchematicSvg,
|
|
61
|
+
sourceSvg: sourceSchematicSvg,
|
|
62
|
+
}),
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function createComparisonSvg({
|
|
67
|
+
fixtureName,
|
|
68
|
+
kind,
|
|
69
|
+
renderedSvg,
|
|
70
|
+
sourceSvg,
|
|
71
|
+
}: {
|
|
72
|
+
fixtureName: string
|
|
73
|
+
kind: "PCB" | "schematic"
|
|
74
|
+
renderedSvg: string
|
|
75
|
+
sourceSvg: string
|
|
76
|
+
}): string {
|
|
77
|
+
return stackSvgsHorizontally([sourceSvg, renderedSvg], {
|
|
78
|
+
gap: 24,
|
|
79
|
+
normalizeSize: true,
|
|
80
|
+
targetSize: 800,
|
|
81
|
+
rootAttributes: {
|
|
82
|
+
"aria-label": `${fixtureName} ${kind}: source Circuit JSON on left, generated tscircuit render on right`,
|
|
83
|
+
role: "img",
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# TI EVM Circuit JSON fixtures
|
|
2
|
+
|
|
3
|
+
These fixtures contain the PCB and primary electrical schematic converted from
|
|
4
|
+
Texas Instruments' published Altium design files. They were generated with
|
|
5
|
+
`tscircuit/altium-to-circuit-json` at commit
|
|
6
|
+
`9a578b5762e1dcca06e6d3f84f1d2950d0acc301`.
|
|
7
|
+
|
|
8
|
+
The upstream files and checksums are maintained in that repository's
|
|
9
|
+
`scripts/references/reference-manifest.ts`. The gzip files only avoid committing
|
|
10
|
+
several megabytes of repetitive JSON; tests expand them before conversion.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|