@tscircuit/props 0.0.635 → 0.0.637
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 +20 -3
- package/dist/index.d.ts +705 -572
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/lib/components/board.ts +78 -1
- package/package.json +1 -1
package/lib/components/board.ts
CHANGED
|
@@ -23,8 +23,60 @@ export type BoardColor = AutocompleteString<BoardColorPreset>
|
|
|
23
23
|
|
|
24
24
|
const boardColor = z.custom<BoardColor>((value) => typeof value === "string")
|
|
25
25
|
|
|
26
|
+
export interface BoardOutlinePoint extends Point {
|
|
27
|
+
/** Marks this outline point as the center of a castellated plated hole */
|
|
28
|
+
isCastellatedHole?: boolean
|
|
29
|
+
/** Diameter of the drilled hole. Required when `isCastellatedHole` is true. */
|
|
30
|
+
holeDiameter?: Distance
|
|
31
|
+
/** Diameter of the copper pad. Required when `isCastellatedHole` is true. */
|
|
32
|
+
padDiameter?: Distance
|
|
33
|
+
/** Connection target or targets for the castellated hole */
|
|
34
|
+
connectsTo?: string | string[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const boardOutlinePoint = z
|
|
38
|
+
.object({
|
|
39
|
+
...point.shape,
|
|
40
|
+
isCastellatedHole: z.boolean().optional(),
|
|
41
|
+
holeDiameter: distance.optional(),
|
|
42
|
+
padDiameter: distance.optional(),
|
|
43
|
+
connectsTo: z.string().or(z.array(z.string())).optional(),
|
|
44
|
+
})
|
|
45
|
+
.superRefine((outlinePoint, ctx) => {
|
|
46
|
+
if (outlinePoint.isCastellatedHole) {
|
|
47
|
+
if (outlinePoint.holeDiameter === undefined) {
|
|
48
|
+
ctx.addIssue({
|
|
49
|
+
code: z.ZodIssueCode.custom,
|
|
50
|
+
path: ["holeDiameter"],
|
|
51
|
+
message: "holeDiameter is required for a castellated hole",
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
if (outlinePoint.padDiameter === undefined) {
|
|
55
|
+
ctx.addIssue({
|
|
56
|
+
code: z.ZodIssueCode.custom,
|
|
57
|
+
path: ["padDiameter"],
|
|
58
|
+
message: "padDiameter is required for a castellated hole",
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (
|
|
65
|
+
outlinePoint.holeDiameter !== undefined ||
|
|
66
|
+
outlinePoint.padDiameter !== undefined ||
|
|
67
|
+
outlinePoint.connectsTo !== undefined
|
|
68
|
+
) {
|
|
69
|
+
ctx.addIssue({
|
|
70
|
+
code: z.ZodIssueCode.custom,
|
|
71
|
+
path: ["isCastellatedHole"],
|
|
72
|
+
message:
|
|
73
|
+
"isCastellatedHole must be true when castellated hole props are provided",
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
26
78
|
export interface BoardProps
|
|
27
|
-
extends Omit<SubcircuitGroupProps, "subcircuit" | "connections"> {
|
|
79
|
+
extends Omit<SubcircuitGroupProps, "subcircuit" | "connections" | "outline"> {
|
|
28
80
|
title?: string
|
|
29
81
|
material?: "fr4" | "fr1" | "flex"
|
|
30
82
|
/** Number of layers for the PCB */
|
|
@@ -39,6 +91,18 @@ export interface BoardProps
|
|
|
39
91
|
boardAnchorPosition?: Point
|
|
40
92
|
anchorAlignment?: z.infer<typeof ninePointAnchor>
|
|
41
93
|
boardAnchorAlignment?: z.infer<typeof ninePointAnchor>
|
|
94
|
+
/**
|
|
95
|
+
* Points defining the board edge. Set `isCastellatedHole` on a point to
|
|
96
|
+
* place a castellated plated hole centered on that location.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* { x: "-5mm", y: 0, isCastellatedHole: true,
|
|
101
|
+
* holeDiameter: "0.8mm", padDiameter: "1.2mm",
|
|
102
|
+
* connectsTo: "net.GND" }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
outline?: BoardOutlinePoint[]
|
|
42
106
|
/** Color applied to both top and bottom solder masks */
|
|
43
107
|
solderMaskColor?: BoardColor
|
|
44
108
|
/** Color of the top solder mask */
|
|
@@ -55,6 +119,11 @@ export interface BoardProps
|
|
|
55
119
|
doubleSidedAssembly?: boolean
|
|
56
120
|
/** Whether vias may be placed inside PCB pads */
|
|
57
121
|
isViaInPadAllowed?: boolean
|
|
122
|
+
/**
|
|
123
|
+
* Whether implicit copper pours should be generated automatically. Defaults
|
|
124
|
+
* to false.
|
|
125
|
+
*/
|
|
126
|
+
automaticPoursEnabled?: boolean
|
|
58
127
|
/** Whether this board should be omitted from the schematic view */
|
|
59
128
|
schematicDisabled?: boolean
|
|
60
129
|
}
|
|
@@ -86,6 +155,7 @@ export const boardProps = subcircuitGroupProps
|
|
|
86
155
|
boardAnchorAlignment: ninePointAnchor
|
|
87
156
|
.optional()
|
|
88
157
|
.describe("Prefer using anchorAlignment when possible"),
|
|
158
|
+
outline: z.array(boardOutlinePoint).optional(),
|
|
89
159
|
title: z.string().optional(),
|
|
90
160
|
solderMaskColor: boardColor.optional(),
|
|
91
161
|
topSolderMaskColor: boardColor.optional(),
|
|
@@ -100,8 +170,15 @@ export const boardProps = subcircuitGroupProps
|
|
|
100
170
|
.describe(
|
|
101
171
|
"Allows intentional via-in-pad designs to pass DRC. Omitted or false keeps via-in-pad disallowed.",
|
|
102
172
|
),
|
|
173
|
+
automaticPoursEnabled: z
|
|
174
|
+
.boolean()
|
|
175
|
+
.default(false)
|
|
176
|
+
.describe(
|
|
177
|
+
"Whether implicit copper pours should be generated automatically. Defaults to false.",
|
|
178
|
+
),
|
|
103
179
|
schematicDisabled: z.boolean().optional(),
|
|
104
180
|
})
|
|
105
181
|
|
|
106
182
|
type InferredBoardProps = z.input<typeof boardProps>
|
|
183
|
+
expectTypesMatch<BoardOutlinePoint, z.input<typeof boardOutlinePoint>>(true)
|
|
107
184
|
expectTypesMatch<BoardProps, InferredBoardProps>(true)
|