@tscircuit/props 0.0.183 → 0.0.185
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 +56 -0
- package/dist/index.d.ts +237 -4
- package/dist/index.js +169 -129
- package/dist/index.js.map +1 -1
- package/lib/components/cutout.ts +77 -0
- package/lib/components/silkscreen-text.ts +2 -3
- package/lib/index.ts +1 -0
- package/package.json +1 -1
|
@@ -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>
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { length } from "circuit-json"
|
|
2
2
|
import { pcbLayoutProps } from "lib/common/layout"
|
|
3
|
+
import { nine_point_anchor } from "lib/common/nine_point_anchor"
|
|
3
4
|
import { z } from "zod"
|
|
4
5
|
|
|
5
6
|
export const silkscreenTextProps = pcbLayoutProps.extend({
|
|
6
7
|
text: z.string(),
|
|
7
|
-
anchorAlignment:
|
|
8
|
-
.enum(["center", "top_left", "top_right", "bottom_left", "bottom_right"])
|
|
9
|
-
.default("center"),
|
|
8
|
+
anchorAlignment: nine_point_anchor.default("center"),
|
|
10
9
|
font: z.enum(["tscircuit2024"]).optional(),
|
|
11
10
|
fontSize: length.optional(),
|
|
12
11
|
})
|
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"
|