easyeda 0.0.30 → 0.0.32
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 +79 -15
- package/dist/chunk-3ZPJFTXV.js +2295 -0
- package/dist/chunk-3ZPJFTXV.js.map +1 -0
- package/dist/cli/main.js +84 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/lib/{index.d.cts → index.d.ts} +4 -2
- package/dist/lib/index.js +41 -0
- package/dist/lib/index.js.map +1 -0
- package/package.json +7 -7
- package/dist/cli/main.cjs +0 -31492
- package/dist/cli/main.cjs.map +0 -1
- package/dist/lib/index.cjs +0 -31454
- package/dist/lib/index.cjs.map +0 -1
- /package/dist/cli/{main.d.cts → main.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# easyeda-converter
|
|
2
2
|
|
|
3
|
-
Convert
|
|
3
|
+
Convert EasyEDA JSON PCB footprints into [Circuit JSON](https://github.com/tscircuit/circuit-json) or TypeScript React components.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install -g easyeda
|
|
@@ -8,17 +8,47 @@ npm install -g easyeda
|
|
|
8
8
|
|
|
9
9
|
## Library Usage
|
|
10
10
|
|
|
11
|
+
### Fetching EasyEDA Component Data
|
|
12
|
+
|
|
11
13
|
```ts
|
|
12
|
-
import {
|
|
13
|
-
fetchEasyEDAComponent,
|
|
14
|
-
convertEasyEdaJsonToTscircuitSoupJson,
|
|
15
|
-
} from "easyeda"
|
|
14
|
+
import { fetchEasyEDAComponent } from "easyeda"
|
|
16
15
|
|
|
17
|
-
//
|
|
16
|
+
// Get raw EasyEDA JSON for a component
|
|
18
17
|
const rawEasyJson = await fetchEasyEDAComponent("C46749")
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Converting to Circuit JSON
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { convertEasyEdaJsonToCircuitJson } from "easyeda"
|
|
19
24
|
|
|
20
|
-
//
|
|
21
|
-
const soupJson =
|
|
25
|
+
// Convert to tscircuit soup
|
|
26
|
+
const soupJson = convertEasyEdaJsonToCircuitJson(rawEasyJson)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Converting to TypeScript React Component
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { convertRawEasyEdaToTs } from "easyeda"
|
|
33
|
+
|
|
34
|
+
// Convert to TypeScript React component
|
|
35
|
+
const tsxComponent = await convertRawEasyEdaToTs(rawEasyJson)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Full Example: Fetching and Converting to TSX
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { fetchEasyEDAComponent, convertRawEasyEdaToTs } from "easyeda"
|
|
42
|
+
|
|
43
|
+
async function convertPartNumberToTsx(partNumber: string) {
|
|
44
|
+
const rawEasyJson = await fetchEasyEDAComponent(partNumber)
|
|
45
|
+
const tsxComponent = await convertRawEasyEdaToTs(rawEasyJson)
|
|
46
|
+
return tsxComponent
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Usage
|
|
50
|
+
const ne555TsxComponent = await convertPartNumberToTsx("C46749")
|
|
51
|
+
console.log(ne555TsxComponent)
|
|
22
52
|
```
|
|
23
53
|
|
|
24
54
|
## CLI
|
|
@@ -52,10 +82,44 @@ easyeda download -i C46749 -o C46749.raweasy.json
|
|
|
52
82
|
|
|
53
83
|
## File Formats
|
|
54
84
|
|
|
55
|
-
| Format | Description
|
|
56
|
-
| ------------------- |
|
|
57
|
-
| `*.raweasy.json` | The raw JSON from the EasyEDA API
|
|
58
|
-
| `*.bettereasy.json` | The raw JSON from the EasyEDA API, but with the footprint and schematic data decoded
|
|
59
|
-
| `*.
|
|
60
|
-
| `*.kicad_mod` | A KiCad footprint file
|
|
61
|
-
| `*.
|
|
85
|
+
| Format | Description |
|
|
86
|
+
| ------------------- | ------------------------------------------------------------------------------------------- |
|
|
87
|
+
| `*.raweasy.json` | The raw JSON from the EasyEDA API |
|
|
88
|
+
| `*.bettereasy.json` | The raw JSON from the EasyEDA API, but with the footprint and schematic data decoded |
|
|
89
|
+
| `*.circuit.json` | The tscircuit's easy-to-use JSON format [(docs)](https://github.com/tscircuit/circuit-json) |
|
|
90
|
+
| `*.kicad_mod` | A KiCad footprint file |
|
|
91
|
+
| `*.tsx` | A TypeScript React component file |
|
|
92
|
+
|
|
93
|
+
## Advanced Usage
|
|
94
|
+
|
|
95
|
+
### Customizing Conversion Options
|
|
96
|
+
|
|
97
|
+
When converting EasyEDA JSON to tscircuit soup, you can pass additional options:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { convertEasyEdaJsonToCircuitJson } from "easyeda"
|
|
101
|
+
|
|
102
|
+
const soupJson = convertEasyEdaJsonToCircuitJson(rawEasyJson, {
|
|
103
|
+
useModelCdn: true, // Use CDN for 3D models
|
|
104
|
+
shouldRecenter: false, // Don't recenter the component
|
|
105
|
+
})
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Working with Generated TypeScript Components
|
|
109
|
+
|
|
110
|
+
The generated TypeScript React components can be imported and used in your tscircuit projects:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { NE555 } from "./NE555"
|
|
114
|
+
|
|
115
|
+
const MyCircuit = () => {
|
|
116
|
+
return (
|
|
117
|
+
<circuit>
|
|
118
|
+
<NE555 name="U1" />
|
|
119
|
+
{/* Other components */}
|
|
120
|
+
</circuit>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
These components include proper typing for props and integrate seamlessly with the tscircuit ecosystem.
|