@tscircuit/footprinter 0.0.1
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 +45 -0
- package/ava.config.js +5 -0
- package/dist/index.cjs +11615 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +33 -0
- package/package.json +25 -0
- package/src/fn/bga.ts +71 -0
- package/src/fn/cap.ts +7 -0
- package/src/fn/diode.ts +8 -0
- package/src/fn/dip.ts +56 -0
- package/src/fn/led.ts +6 -0
- package/src/fn/res.ts +6 -0
- package/src/footprinter.ts +102 -0
- package/src/helpers/passive-fn.ts +175 -0
- package/src/helpers/platedhole.ts +21 -0
- package/src/helpers/rectpad.ts +20 -0
- package/src/helpers/zod/bga-def.ts +48 -0
- package/src/helpers/zod/dim-2d.ts +17 -0
- package/src/helpers/zod/function-call.ts +16 -0
- package/src/index.ts +1 -0
- package/tests/bga.test.ts +49 -0
- package/tests/cap.test.ts +30 -0
- package/tests/dip.test.ts +42 -0
- package/tests/fixtures/index.ts +30 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import test from "ava"
|
|
2
|
+
import { fp } from "../src/footprinter"
|
|
3
|
+
import { AnySoupElement } from "@tscircuit/soup"
|
|
4
|
+
import { toPinPositionString } from "./fixtures"
|
|
5
|
+
|
|
6
|
+
test("cap footprint", (t) => {
|
|
7
|
+
const soup = fp().cap().imperial("0402").soup()
|
|
8
|
+
const ps = toPinPositionString(soup)
|
|
9
|
+
|
|
10
|
+
t.is(
|
|
11
|
+
ps,
|
|
12
|
+
`
|
|
13
|
+
1 : -0.50 0.00
|
|
14
|
+
2 : 0.50 0.00
|
|
15
|
+
`.trim()
|
|
16
|
+
)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test("cap_imperial0402", (t) => {
|
|
20
|
+
const soup = fp.string("cap_imperial0402").soup()
|
|
21
|
+
const ps = toPinPositionString(soup)
|
|
22
|
+
|
|
23
|
+
t.is(
|
|
24
|
+
ps,
|
|
25
|
+
`
|
|
26
|
+
1 : -0.50 0.00
|
|
27
|
+
2 : 0.50 0.00
|
|
28
|
+
`.trim()
|
|
29
|
+
)
|
|
30
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import test from "ava"
|
|
2
|
+
import { fp } from "../src/footprinter"
|
|
3
|
+
import { AnySoupElement } from "@tscircuit/soup"
|
|
4
|
+
import { toPinPositionString } from "./fixtures"
|
|
5
|
+
|
|
6
|
+
test("dip params", (t) => {
|
|
7
|
+
t.deepEqual(fp().dip(4).w(7.62).params(), {
|
|
8
|
+
dip: true,
|
|
9
|
+
num_pins: 4,
|
|
10
|
+
w: 7.62,
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test("dip footprint", (t) => {
|
|
15
|
+
const soup = fp().dip(4).w(4).p(2).soup()
|
|
16
|
+
const ps = toPinPositionString(soup)
|
|
17
|
+
|
|
18
|
+
t.is(
|
|
19
|
+
ps,
|
|
20
|
+
`
|
|
21
|
+
1 : -2.00 1.00
|
|
22
|
+
2 : -2.00 -1.00
|
|
23
|
+
3 : 2.00 -1.00
|
|
24
|
+
4 : 2.00 1.00
|
|
25
|
+
`.trim()
|
|
26
|
+
)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test("dip4_w3", (t) => {
|
|
30
|
+
const soup = fp.string("dip4_w3").soup()
|
|
31
|
+
const ps = toPinPositionString(soup)
|
|
32
|
+
|
|
33
|
+
t.is(
|
|
34
|
+
ps,
|
|
35
|
+
`
|
|
36
|
+
1 : -1.50 1.27
|
|
37
|
+
2 : -1.50 -1.27
|
|
38
|
+
3 : 1.50 -1.27
|
|
39
|
+
4 : 1.50 1.27
|
|
40
|
+
`.trim()
|
|
41
|
+
)
|
|
42
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AnySoupElement } from "@tscircuit/soup"
|
|
2
|
+
|
|
3
|
+
export const toPinPositionString = (soup: AnySoupElement[]) => {
|
|
4
|
+
return soup
|
|
5
|
+
.map((e: AnySoupElement) => {
|
|
6
|
+
if (e.type === "pcb_plated_hole") {
|
|
7
|
+
return {
|
|
8
|
+
x: e.x,
|
|
9
|
+
y: e.y,
|
|
10
|
+
pn: e.port_hints?.[0],
|
|
11
|
+
}
|
|
12
|
+
} else if (e.type === "pcb_smtpad") {
|
|
13
|
+
return {
|
|
14
|
+
x: e.x,
|
|
15
|
+
y: e.y,
|
|
16
|
+
pn: e.port_hints?.[0],
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// TODO other types
|
|
20
|
+
})
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.sort((a: any, b: any) => a.pn - b.pn)
|
|
23
|
+
.map(
|
|
24
|
+
(e: any) =>
|
|
25
|
+
`${e.pn.padEnd(2)}: ${e.x.toFixed(2).padStart(5)} ${e.y
|
|
26
|
+
.toFixed(2)
|
|
27
|
+
.padStart(5)}`
|
|
28
|
+
)
|
|
29
|
+
.join("\n")
|
|
30
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Base Options recommended for all projects
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"target": "es2022",
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"moduleDetection": "force",
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"verbatimModuleSyntax": true,
|
|
12
|
+
// Enable strict type checking so you can catch bugs early
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noImplicitAny": false,
|
|
15
|
+
"noUncheckedIndexedAccess": true,
|
|
16
|
+
"noImplicitOverride": true,
|
|
17
|
+
// We are not transpiling, so preserve our source code and do not emit files
|
|
18
|
+
"module": "preserve",
|
|
19
|
+
"noEmit": true,
|
|
20
|
+
"lib": ["es2022"]
|
|
21
|
+
},
|
|
22
|
+
// Include the necessary files for your project
|
|
23
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
24
|
+
"exclude": ["node_modules"]
|
|
25
|
+
}
|