@tscircuit/footprinter 0.0.3 → 0.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/footprinter",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "description": "",
6
6
  "main": "dist/index.cjs",
7
7
  "scripts": {
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(
@@ -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
@@ -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(