@tscircuit/props 0.0.182 → 0.0.184

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.
@@ -0,0 +1,77 @@
1
+ import { z } from "zod"
2
+ import { distance, type Distance } from "lib/common/distance"
3
+ import { point, type Point } from "lib/common/point"
4
+ import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
5
+ import { expectTypesMatch } from "lib/typecheck"
6
+
7
+ export interface RectCutoutProps
8
+ extends Omit<PcbLayoutProps, "layer" | "pcbRotation"> {
9
+ name?: string
10
+ shape: "rect"
11
+ width: Distance
12
+ height: Distance
13
+ }
14
+
15
+ export const rectCutoutProps = pcbLayoutProps
16
+ .omit({
17
+ layer: true,
18
+ pcbRotation: true,
19
+ })
20
+ .extend({
21
+ name: z.string().optional(),
22
+ shape: z.literal("rect"),
23
+ width: distance,
24
+ height: distance,
25
+ })
26
+ expectTypesMatch<RectCutoutProps, z.input<typeof rectCutoutProps>>(true)
27
+
28
+ export interface CircleCutoutProps
29
+ extends Omit<PcbLayoutProps, "layer" | "pcbRotation"> {
30
+ name?: string
31
+ shape: "circle"
32
+ radius: Distance
33
+ }
34
+
35
+ export const circleCutoutProps = pcbLayoutProps
36
+ .omit({
37
+ layer: true,
38
+ pcbRotation: true,
39
+ })
40
+ .extend({
41
+ name: z.string().optional(),
42
+ shape: z.literal("circle"),
43
+ radius: distance,
44
+ })
45
+ expectTypesMatch<CircleCutoutProps, z.input<typeof circleCutoutProps>>(true)
46
+
47
+ export interface PolygonCutoutProps
48
+ extends Omit<PcbLayoutProps, "layer" | "pcbRotation"> {
49
+ name?: string
50
+ shape: "polygon"
51
+ points: Point[]
52
+ }
53
+
54
+ export const polygonCutoutProps = pcbLayoutProps
55
+ .omit({
56
+ layer: true,
57
+ pcbRotation: true,
58
+ })
59
+ .extend({
60
+ name: z.string().optional(),
61
+ shape: z.literal("polygon"),
62
+ points: z.array(point),
63
+ })
64
+ expectTypesMatch<PolygonCutoutProps, z.input<typeof polygonCutoutProps>>(true)
65
+
66
+ export type CutoutProps =
67
+ | RectCutoutProps
68
+ | CircleCutoutProps
69
+ | PolygonCutoutProps
70
+
71
+ export const cutoutProps = z.discriminatedUnion("shape", [
72
+ rectCutoutProps,
73
+ circleCutoutProps,
74
+ polygonCutoutProps,
75
+ ])
76
+
77
+ export type CutoutPropsInput = z.input<typeof cutoutProps>
@@ -55,7 +55,7 @@ export interface CircularHoleWithRectPlatedProps
55
55
  rectPadHeight: number | string
56
56
  holeShape?: "circle"
57
57
  padShape?: "rect"
58
- shape?: "circularHoleWithRectPad"
58
+ shape?: "circular_hole_with_rect_pad"
59
59
  portHints?: PortHints
60
60
  }
61
61
 
@@ -112,17 +112,17 @@ export const platedHoleProps = z
112
112
  rectPadHeight: distance,
113
113
  holeShape: z.literal("circle").optional(),
114
114
  padShape: z.literal("rect").optional(),
115
- shape: z.literal("circularHoleWithRectPad").optional(),
115
+ shape: z.literal("circular_hole_with_rect_pad").optional(),
116
116
  portHints: portHints.optional(),
117
117
  })
118
118
  .refine(
119
119
  (prop) => {
120
- return prop.shape === "circularHoleWithRectPad"
120
+ return prop.shape === "circular_hole_with_rect_pad"
121
121
  ? prop.holeDiameter && prop.rectPadWidth && prop.rectPadHeight
122
122
  : true
123
123
  },
124
124
  {
125
- message: "Missing required fields for circularHoleWithRectPad",
125
+ message: "Missing required fields for circular_hole_with_rect_pad",
126
126
  },
127
127
  ),
128
128
  ])
package/lib/index.ts CHANGED
@@ -23,6 +23,7 @@ export * from "./components/group"
23
23
  export * from "./components/net"
24
24
  export * from "./components/constrainedlayout"
25
25
  export * from "./components/constraint"
26
+ export * from "./components/cutout"
26
27
  export * from "./components/smtpad"
27
28
  export * from "./components/solderpaste"
28
29
  export * from "./components/hole"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.182",
3
+ "version": "0.0.184",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",