@tscircuit/footprinter 0.0.3 → 0.0.5
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 +17 -0
- package/package.json +4 -1
- package/src/fn/dip.ts +12 -0
- package/src/footprinter.ts +1 -1
- package/tests/dip.test.ts +3 -3
- package/tests/fixtures/get-test-fixture.ts +14 -0
- package/tests/fixtures/index.ts +2 -0
- package/tests/slop/slop1.test.ts +18 -0
- package/dist/index.cjs +0 -11615
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -33
package/README.md
CHANGED
|
@@ -43,3 +43,20 @@ should always confirm these footprints against the datasheet.
|
|
|
43
43
|
|
|
44
44
|
- Pins are CCW starting at the top left
|
|
45
45
|
- Y is upward-positive, X is rightward-positive
|
|
46
|
+
|
|
47
|
+
## Slop
|
|
48
|
+
|
|
49
|
+
Slop is a "sloppy" definition, it really doesn't have enough
|
|
50
|
+
information to draw a footprint, i.e. it's missing critical dimensions.
|
|
51
|
+
|
|
52
|
+
footprinter is extremely tolerant to Slop, because it's useful
|
|
53
|
+
when you're iterating incrementally towards a fully constrained
|
|
54
|
+
design, or when you're using footprinter strings as an output format
|
|
55
|
+
for an AI.
|
|
56
|
+
|
|
57
|
+
Generally when footprinter is interpreting a sloppy definition, it will use
|
|
58
|
+
industry best practices or otherwise "reasonable" defaults. In theory, upgrading
|
|
59
|
+
footprinter could cause the defaults to change, which is why sloppy definitions
|
|
60
|
+
are generally not desirable.
|
|
61
|
+
|
|
62
|
+
Currently it's not possible to see if a given definition is sloppy.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/footprinter",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"scripts": {
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
"author": "",
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"devDependencies": {
|
|
15
|
+
"@tscircuit/log-soup": "^1.0.1",
|
|
15
16
|
"@tscircuit/soup": "^0.0.17",
|
|
17
|
+
"@tscircuit/soup-util": "^0.0.11",
|
|
18
|
+
"@types/node": "^20.12.13",
|
|
16
19
|
"ava": "^6.1.3",
|
|
17
20
|
"esbuild": "^0.21.4",
|
|
18
21
|
"esbuild-register": "^3.5.0",
|
package/src/fn/dip.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { AnySoupElement } from "@tscircuit/soup"
|
|
2
2
|
import { platedhole } from "../helpers/platedhole"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
import { length } from "@tscircuit/soup"
|
|
5
|
+
|
|
6
|
+
const dip_def = z.object({
|
|
7
|
+
dip: z.literal(true),
|
|
8
|
+
num_pins: z.number(),
|
|
9
|
+
w: length,
|
|
10
|
+
p: length.optional(),
|
|
11
|
+
id: length.optional(),
|
|
12
|
+
od: length.optional(),
|
|
13
|
+
})
|
|
3
14
|
|
|
4
15
|
export const getCcwDipCoords = (
|
|
5
16
|
pinCount: number,
|
|
@@ -40,6 +51,7 @@ export const dip = (params: {
|
|
|
40
51
|
id?: string | number
|
|
41
52
|
od?: string | number
|
|
42
53
|
}): AnySoupElement[] => {
|
|
54
|
+
params = dip_def.parse(params)
|
|
43
55
|
const platedHoles: AnySoupElement[] = []
|
|
44
56
|
for (let i = 0; i < params.num_pins; i++) {
|
|
45
57
|
const { x, y } = getCcwDipCoords(
|
package/src/footprinter.ts
CHANGED
|
@@ -47,7 +47,7 @@ export const string = (def: string): Footprinter => {
|
|
|
47
47
|
let fp = footprinter()
|
|
48
48
|
|
|
49
49
|
const def_parts = def.split("_").map((s) => {
|
|
50
|
-
const m = s.match(/([a-z]+)([\(\d
|
|
50
|
+
const m = s.match(/([a-z]+)([\(\d\.\+].*)?/)
|
|
51
51
|
const [_, fn, v] = m ?? []
|
|
52
52
|
return { fn: m?.[1]!, v: m?.[2]! }
|
|
53
53
|
})
|
package/tests/dip.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import test from "ava"
|
|
2
2
|
import { fp } from "../src/footprinter"
|
|
3
|
-
import { AnySoupElement } from "@tscircuit/soup"
|
|
3
|
+
import type { AnySoupElement } from "@tscircuit/soup"
|
|
4
4
|
import { toPinPositionString } from "./fixtures"
|
|
5
5
|
|
|
6
6
|
test("dip params", (t) => {
|
|
@@ -26,8 +26,8 @@ test("dip footprint", (t) => {
|
|
|
26
26
|
)
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
test("dip4_w3", (t) => {
|
|
30
|
-
const soup = fp.string("dip4_w3").soup()
|
|
29
|
+
test("dip4_w3.00mm", (t) => {
|
|
30
|
+
const soup = fp.string("dip4_w3.00mm").soup()
|
|
31
31
|
const ps = toPinPositionString(soup)
|
|
32
32
|
|
|
33
33
|
t.is(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ExecutionContext } from "ava"
|
|
2
|
+
import { fp } from "../../src"
|
|
3
|
+
import { logSoup } from "@tscircuit/log-soup"
|
|
4
|
+
import type { AnySoupElement } from "@tscircuit/soup"
|
|
5
|
+
|
|
6
|
+
export const getTestFixture = async (t: ExecutionContext) => {
|
|
7
|
+
return {
|
|
8
|
+
fp,
|
|
9
|
+
logSoup: (soup: AnySoupElement[]) => {
|
|
10
|
+
if (process.env.CI) return
|
|
11
|
+
return logSoup(`footprinter: ${t.title}`, soup)
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
}
|
package/tests/fixtures/index.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import test from "ava"
|
|
2
|
+
import { getTestFixture } from "../fixtures"
|
|
3
|
+
import type { AnySoupElement } from "@tscircuit/soup"
|
|
4
|
+
|
|
5
|
+
export const SLOP_LIST = ["dip3"]
|
|
6
|
+
|
|
7
|
+
test("slop1", async (t) => {
|
|
8
|
+
const { fp, logSoup } = await getTestFixture(t)
|
|
9
|
+
|
|
10
|
+
const soups: AnySoupElement[][] = []
|
|
11
|
+
|
|
12
|
+
for (const slop of SLOP_LIST) {
|
|
13
|
+
const soup = fp.string(slop).soup()
|
|
14
|
+
soups.push(soup)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
await logSoup(soups[0]!)
|
|
18
|
+
})
|