-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from tscircuit/usage
Major Refactor, improve code separation, add tests, add build, release, add stringification, add README usage examples
- Loading branch information
Showing
24 changed files
with
1,493 additions
and
1,087 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Created using @tscircuit/plop (npm install -g @tscircuit/plop) | ||
name: Format Check | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
format-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
|
||
- name: Install dependencies | ||
run: bun install | ||
|
||
- name: Run format check | ||
run: bun run format:check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Created using @tscircuit/plop (npm install -g @tscircuit/plop) | ||
name: Publish to npm | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm install -g pver | ||
- run: bun install --frozen-lockfile | ||
- run: pver release | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Created using @tscircuit/plop (npm install -g @tscircuit/plop) | ||
name: Bun Test | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
|
||
- name: Install dependencies | ||
run: bun install | ||
|
||
- name: Run tests | ||
run: bun test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Created using @tscircuit/plop (npm install -g @tscircuit/plop) | ||
name: Type Check | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
type-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
|
||
- name: Install dependencies | ||
run: bun i | ||
|
||
- name: Run type check | ||
run: bunx tsc --noEmit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,3 +173,6 @@ dist | |
|
||
# Finder (MacOS) folder config | ||
.DS_Store | ||
.aider* | ||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,102 @@ | ||
# dsn-converter | ||
|
||
Convert to and frmo DSN to tscircuit components or circuit JSON | ||
A TypeScript library for converting between DSN files and Circuit JSON format. | ||
|
||
## Overview | ||
|
||
dsn-converter is a powerful tool that enables bidirectional conversion between Specctr DSN format and Circuit JSON. This makes it possible to: | ||
|
||
- Parse Specctra DSN files into a workable JSON format | ||
- Convert Circuit JSON back into KiCad-compatible DSN files | ||
- Visualize PCB designs using SVG rendering | ||
|
||
## Installation | ||
|
||
```bash | ||
# Using bun | ||
bun add dsn-converter | ||
|
||
# Using npm | ||
npm install dsn-converter | ||
``` | ||
|
||
## Usage | ||
|
||
### Converting DSN to Circuit JSON | ||
|
||
```typescript | ||
import { parseDsnToCircuitJson } from "dsn-converter" | ||
|
||
const dsnContent = await Bun.file("your-design.dsn").text() | ||
|
||
const circuitJson = parseDsnToCircuitJson(dsnContent) | ||
|
||
await Bun.write("output.circuit.json", JSON.stringify(circuitJson, null, 2)) | ||
``` | ||
|
||
### Converting Circuit JSON to DSN | ||
|
||
```typescript | ||
import { circuitJsonToDsnString } from "dsn-converter" | ||
|
||
const dsnString = circuitJsonToDsnString(circuitJson) | ||
|
||
await Bun.write("output.dsn", dsnString) | ||
``` | ||
|
||
## Features | ||
|
||
- **Complete DSN Support**: Handles all major DSN file components including: | ||
|
||
- Component placement | ||
- PCB layers | ||
- Traces and wiring | ||
- Padstacks and SMT pads | ||
- Net definitions | ||
- Board boundaries | ||
|
||
- **Accurate Conversions**: Maintains precise measurements and positions during conversion | ||
|
||
- **Type Safety**: Full TypeScript support with comprehensive type definitions | ||
|
||
## Data Structure | ||
|
||
### DSN Format | ||
|
||
The DSN format is represented as a structured JSON with the following main sections: | ||
|
||
- `parser`: Contains file metadata | ||
- `resolution`: Defines measurement units | ||
- `structure`: Describes board layers and rules | ||
- `placement`: Component positions | ||
- `library`: Component and padstack definitions | ||
- `network`: Net connections | ||
- `wiring`: Trace routing | ||
|
||
### Circuit JSON | ||
|
||
The Circuit JSON format includes: | ||
|
||
- PCB traces | ||
- SMT pads | ||
- Component definitions | ||
- Layer information | ||
- Routing data | ||
|
||
## Development | ||
|
||
```bash | ||
# Install dependencies | ||
bun install | ||
|
||
# Run tests | ||
bun test | ||
|
||
# Run specific test file | ||
bun test tests/dsn-pcb/parse-dsn-pcb.test.ts | ||
``` | ||
|
||
## Acknowledgments | ||
|
||
- Built with [Bun](https://bun.sh) | ||
- Uses [tscircuit](https://github.com/tscircuit/tscircuit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.