@tscircuit/props 0.0.579 → 0.0.580
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/dist/index.d.ts +455 -255
- package/dist/index.js +1045 -1002
- package/dist/index.js.map +1 -1
- package/lib/common/commonShape.ts +50 -0
- package/lib/enclosure/cutout-aperture.ts +63 -0
- package/lib/enclosure/index.ts +4 -1
- package/lib/index.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { distance, type Distance } from "lib/common/distance"
|
|
2
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
|
|
5
|
+
export interface PillShapeProps {
|
|
6
|
+
shape: "pill"
|
|
7
|
+
width: Distance
|
|
8
|
+
height: Distance
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RectShapeProps {
|
|
12
|
+
shape: "rect"
|
|
13
|
+
width: Distance
|
|
14
|
+
height: Distance
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface CircleShapeProps {
|
|
18
|
+
shape: "circle"
|
|
19
|
+
radius: Distance
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type CommonShapeProps =
|
|
23
|
+
| PillShapeProps
|
|
24
|
+
| RectShapeProps
|
|
25
|
+
| CircleShapeProps
|
|
26
|
+
|
|
27
|
+
export const pillShapeProps = z.object({
|
|
28
|
+
shape: z.literal("pill"),
|
|
29
|
+
width: distance,
|
|
30
|
+
height: distance,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export const rectShapeProps = z.object({
|
|
34
|
+
shape: z.literal("rect"),
|
|
35
|
+
width: distance,
|
|
36
|
+
height: distance,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
export const circleShapeProps = z.object({
|
|
40
|
+
shape: z.literal("circle"),
|
|
41
|
+
radius: distance,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
export const commonShapeProps = z.discriminatedUnion("shape", [
|
|
45
|
+
pillShapeProps,
|
|
46
|
+
rectShapeProps,
|
|
47
|
+
circleShapeProps,
|
|
48
|
+
])
|
|
49
|
+
|
|
50
|
+
expectTypesMatch<CommonShapeProps, z.input<typeof commonShapeProps>>(true)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
circleShapeProps,
|
|
3
|
+
type CircleShapeProps,
|
|
4
|
+
type CommonShapeProps,
|
|
5
|
+
pillShapeProps,
|
|
6
|
+
type PillShapeProps,
|
|
7
|
+
rectShapeProps,
|
|
8
|
+
type RectShapeProps,
|
|
9
|
+
} from "lib/common/commonShape"
|
|
10
|
+
import { distance, type Distance } from "lib/common/distance"
|
|
11
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
12
|
+
import { z } from "zod"
|
|
13
|
+
|
|
14
|
+
export const enclosureCutoutApertureShapes = ["pill", "rect", "circle"] as const
|
|
15
|
+
|
|
16
|
+
export type EnclosureCutoutApertureShape = CommonShapeProps["shape"]
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Describes the nominal enclosure opening required by a component.
|
|
20
|
+
*
|
|
21
|
+
* Numeric values are interpreted as mm.
|
|
22
|
+
*/
|
|
23
|
+
export interface PillEnclosureCutoutApertureProps extends PillShapeProps {
|
|
24
|
+
/** Additional clearance around the nominal opening. */
|
|
25
|
+
margin?: Distance
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RectEnclosureCutoutApertureProps extends RectShapeProps {
|
|
29
|
+
/** Additional clearance around the nominal opening. */
|
|
30
|
+
margin?: Distance
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CircleEnclosureCutoutApertureProps extends CircleShapeProps {
|
|
34
|
+
/** Additional clearance around the nominal opening. */
|
|
35
|
+
margin?: Distance
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type EnclosureCutoutApertureProps =
|
|
39
|
+
| PillEnclosureCutoutApertureProps
|
|
40
|
+
| RectEnclosureCutoutApertureProps
|
|
41
|
+
| CircleEnclosureCutoutApertureProps
|
|
42
|
+
|
|
43
|
+
const apertureOnlyProps = {
|
|
44
|
+
margin: distance.optional(),
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const enclosureCutoutApertureProps = z.discriminatedUnion("shape", [
|
|
48
|
+
pillShapeProps.extend(apertureOnlyProps),
|
|
49
|
+
rectShapeProps.extend(apertureOnlyProps),
|
|
50
|
+
circleShapeProps.extend(apertureOnlyProps),
|
|
51
|
+
])
|
|
52
|
+
|
|
53
|
+
type InferredEnclosureCutoutApertureProps = z.input<
|
|
54
|
+
typeof enclosureCutoutApertureProps
|
|
55
|
+
>
|
|
56
|
+
export type ParsedEnclosureCutoutApertureProps = z.output<
|
|
57
|
+
typeof enclosureCutoutApertureProps
|
|
58
|
+
>
|
|
59
|
+
|
|
60
|
+
expectTypesMatch<
|
|
61
|
+
EnclosureCutoutApertureProps,
|
|
62
|
+
InferredEnclosureCutoutApertureProps
|
|
63
|
+
>(true)
|
package/lib/enclosure/index.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { enclosureCutoutApertureProps } from "./cutout-aperture"
|
|
1
2
|
import { enclosureFdmBoxProps } from "./fdm/box"
|
|
2
3
|
|
|
4
|
+
export * from "./cutout-aperture"
|
|
3
5
|
export * from "./fdm"
|
|
4
6
|
|
|
5
7
|
export const enclosureProps = {
|
|
8
|
+
cutoutaperture: enclosureCutoutApertureProps,
|
|
6
9
|
fdm: {
|
|
7
|
-
|
|
10
|
+
box: enclosureFdmBoxProps,
|
|
8
11
|
},
|
|
9
12
|
} as const
|
package/lib/index.ts
CHANGED