easyeda 0.0.30 → 0.0.31

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # easyeda-converter
2
2
 
3
- Convert easyeda JSON PCB footprints into [tscircuit json soup](https://docs.tscircuit.com/api-reference/advanced/soup)
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
- // get raweasy json
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
- // convert to tscircuit soup
21
- const soupJson = convertEasyEdaJsonToTscircuitSoupJson(rawEasyJson)
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
- | `*.soup.json` | The tscircuit's easy-to-use JSON format [(docs)](https://docs.tscircuit.com/api-reference/advanced/soup) |
60
- | `*.kicad_mod` | A KiCad footprint file |
61
- | `*.ts` | A tscircuit component file |
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.