0.0.123 • Published 3 months ago

easyeda v0.0.123

Weekly downloads
-
License
-
Repository
github
Last release
3 months ago

easyeda-converter

Convert EasyEDA JSON PCB footprints into Circuit JSON or TypeScript React components.

npm install -g easyeda

Library Usage

Fetching EasyEDA Component Data

import { fetchEasyEDAComponent } from "easyeda"

// Get raw EasyEDA JSON for a component
const rawEasyJson = await fetchEasyEDAComponent("C46749")

Converting to Circuit JSON

import { convertEasyEdaJsonToCircuitJson } from "easyeda"

// Convert to tscircuit soup
const soupJson = convertEasyEdaJsonToCircuitJson(rawEasyJson)

Converting to TypeScript React Component

import { convertRawEasyEdaToTs } from "easyeda"

// Convert to TypeScript React component
const tsxComponent = await convertRawEasyEdaToTs(rawEasyJson)

Full Example: Fetching and Converting to TSX

import { fetchEasyEDAComponent, convertRawEasyEdaToTs } from "easyeda"

async function convertPartNumberToTsx(partNumber: string) {
  const rawEasyJson = await fetchEasyEDAComponent(partNumber)
  const tsxComponent = await convertRawEasyEdaToTs(rawEasyJson)
  return tsxComponent
}

// Usage
const ne555TsxComponent = await convertPartNumberToTsx("C46749")
console.log(ne555TsxComponent)

CLI

Install the CLI with npm install -g easyeda, you can then call the cli with either easyeda or easyeda-converter.

# Convert a schematic and footprint for JLCPCB part number C46749 (NE555) to tscircuit component
easyeda convert -i C46749 -o C46749.tsx
easyeda convert -i C46749 -t tsx

# Convert a footprint and schematic for JLCPCB part number C46749 (NE555) to tscircuit soup JSON
# More info: https://docs.tscircuit.com/api-reference/advanced/soup
easyeda convert -i C46749 -o C46749.soup.json

# Convert a footprint for JLCPCB part number C46749 (NE555) to KiCad footprint
easyeda convert -i C46749 -o C46749.kicad_mod

# Download the C46749 footprint and schematic and convert to readable JSON
easyeda convert -i C46749 -o C46749.bettereasy.json

# Can also convert from files!
easyeda convert -i ./C46749.raweasy.json -o C46749.soup.json

# Get exactly what is returned from the JLC API
# The footprint, schematic and some other data is encoded in strings, you
# probably want to convert to *.bettereasy.json
easyeda download -i C46749 -o C46749.raweasy.json

File Formats

FormatDescription
*.raweasy.jsonThe raw JSON from the EasyEDA API
*.bettereasy.jsonThe raw JSON from the EasyEDA API, but with the footprint and schematic data decoded
*.circuit.jsonThe tscircuit's easy-to-use JSON format (docs)
*.kicad_modA KiCad footprint file
*.tsxA TypeScript React component file

Advanced Usage

Customizing Conversion Options

When converting EasyEDA JSON to tscircuit soup, you can pass additional options:

import { convertEasyEdaJsonToCircuitJson } from "easyeda"

const soupJson = convertEasyEdaJsonToCircuitJson(rawEasyJson, {
  useModelCdn: true, // Use CDN for 3D models
  shouldRecenter: false, // Don't recenter the component
})

Working with Generated TypeScript Components

The generated TypeScript React components can be imported and used in your tscircuit projects:

import { NE555 } from "./NE555"

const MyCircuit = () => {
  return (
    <circuit>
      <NE555 name="U1" />
      {/* Other components */}
    </circuit>
  )
}

These components include proper typing for props and integrate seamlessly with the tscircuit ecosystem.

Development

Adding a test for a new part

Just run the following command. Use git status to see the files it introduces.

bun run add-test-for-part C46749

You can then run the test with bun test path/to/file.test.ts until you can successfully get the part working!

0.0.123

3 months ago

0.0.122

3 months ago

0.0.121

3 months ago

0.0.120

4 months ago

0.0.119

4 months ago

0.0.117

4 months ago

0.0.116

4 months ago

0.0.118

4 months ago

0.0.115

4 months ago

0.0.114

4 months ago

0.0.113

4 months ago

0.0.112

4 months ago

0.0.111

4 months ago

0.0.110

4 months ago

0.0.109

5 months ago

0.0.108

5 months ago

0.0.107

5 months ago

0.0.106

5 months ago

0.0.105

5 months ago

0.0.104

5 months ago

0.0.103

5 months ago

0.0.102

5 months ago

0.0.101

5 months ago

0.0.100

5 months ago

0.0.95

6 months ago

0.0.96

6 months ago

0.0.97

6 months ago

0.0.98

5 months ago

0.0.99

5 months ago

0.0.88

6 months ago

0.0.89

6 months ago

0.0.90

6 months ago

0.0.91

6 months ago

0.0.92

6 months ago

0.0.93

6 months ago

0.0.94

6 months ago

0.0.87

7 months ago

0.0.84

7 months ago

0.0.85

7 months ago

0.0.86

7 months ago

0.0.82

7 months ago

0.0.83

7 months ago

0.0.80

7 months ago

0.0.81

7 months ago

0.0.75

7 months ago

0.0.76

7 months ago

0.0.77

7 months ago

0.0.78

7 months ago

0.0.79

7 months ago

0.0.73

7 months ago

0.0.74

7 months ago

0.0.70

7 months ago

0.0.71

7 months ago

0.0.72

7 months ago

0.0.67

7 months ago

0.0.68

7 months ago

0.0.69

7 months ago

0.0.62

8 months ago

0.0.63

8 months ago

0.0.64

8 months ago

0.0.65

8 months ago

0.0.66

8 months ago

0.0.60

8 months ago

0.0.61

8 months ago

0.0.59

8 months ago

0.0.58

8 months ago

0.0.55

8 months ago

0.0.56

8 months ago

0.0.57

8 months ago

0.0.51

8 months ago

0.0.52

8 months ago

0.0.53

8 months ago

0.0.54

8 months ago

0.0.50

8 months ago

0.0.49

8 months ago

0.0.40

8 months ago

0.0.41

8 months ago

0.0.42

8 months ago

0.0.43

8 months ago

0.0.44

8 months ago

0.0.45

8 months ago

0.0.46

8 months ago

0.0.47

8 months ago

0.0.37

8 months ago

0.0.38

8 months ago

0.0.39

8 months ago

0.0.30

8 months ago

0.0.31

8 months ago

0.0.32

8 months ago

0.0.33

8 months ago

0.0.34

8 months ago

0.0.35

8 months ago

0.0.36

8 months ago

0.0.27

9 months ago

0.0.28

9 months ago

0.0.29

9 months ago

0.0.48

8 months ago

0.0.26

11 months ago

0.0.25

11 months ago

0.0.24

11 months ago

0.0.23

11 months ago

0.0.22

11 months ago

0.0.21

11 months ago

0.0.20

11 months ago

0.0.19

11 months ago

0.0.18

11 months ago

0.0.17

11 months ago

0.0.16

11 months ago

0.0.15

11 months ago

0.0.14

11 months ago

0.0.13

11 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago