@tscircuit/props 0.0.677 → 0.0.679

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.
@@ -1,15 +1,18 @@
1
1
  import { assemblyCadAssemblyProps } from "./cadassembly"
2
2
  import { assemblyDeviceProps } from "./device"
3
+ import { assemblyMotorProps } from "./motor"
3
4
  import { assemblyScreenProps } from "./screen"
4
5
  import { assemblySubassemblyProps } from "./subassembly"
5
6
 
6
7
  export * from "./device"
8
+ export * from "./motor"
7
9
  export * from "./screen"
8
10
  export * from "./subassembly"
9
11
  export * from "./cadassembly"
10
12
 
11
13
  export const assemblyProps = {
12
14
  device: assemblyDeviceProps,
15
+ motor: assemblyMotorProps,
13
16
  screen: assemblyScreenProps,
14
17
  subassembly: assemblySubassemblyProps,
15
18
  cadassembly: assemblyCadAssemblyProps,
@@ -0,0 +1,57 @@
1
+ import {
2
+ type CadModelAxisDirection,
3
+ cadModelAxisDirection,
4
+ } from "lib/common/cadModel"
5
+ import { expectTypesMatch } from "lib/typecheck"
6
+ import { z } from "zod"
7
+
8
+ export type AssemblyMotorStandard = "nema8" | "nema17" | "nema23"
9
+
10
+ export interface AssemblyMotorProps {
11
+ /** Stable assembly identity used by selectors. */
12
+ name: string
13
+ /** Human-facing alternate to the stable name. */
14
+ displayName?: string
15
+ /** NEMA frame standard; required when model is omitted, exclusive with model. */
16
+ standard?: AssemblyMotorStandard
17
+ /** Advanced modelprinter string, trimmed; exclusive with standard. */
18
+ model?: string
19
+ /**
20
+ * Direction from the motor body toward the shaft tip in the right-handed
21
+ * circuit frame: +X right, +Y top, +Z above the board. This is a direction,
22
+ * not a position; it does not specify translation or rotation about the
23
+ * shaft. Defaults to "z+", the native shaft axis of the NEMA models.
24
+ */
25
+ shaftFacingDirection?: CadModelAxisDirection
26
+ }
27
+
28
+ export const assemblyMotorProps = z
29
+ .object({
30
+ name: z.string().refine((value) => value.trim().length > 0, {
31
+ message: "name cannot be empty",
32
+ }),
33
+ displayName: z.string().optional(),
34
+ standard: z.enum(["nema8", "nema17", "nema23"]).optional(),
35
+ model: z.string().trim().min(1).optional(),
36
+ shaftFacingDirection: cadModelAxisDirection.default("z+"),
37
+ })
38
+ .superRefine((motor, context) => {
39
+ if (motor.standard === undefined && motor.model === undefined) {
40
+ context.addIssue({
41
+ code: z.ZodIssueCode.custom,
42
+ message: "Provide standard or model",
43
+ path: ["standard"],
44
+ })
45
+ }
46
+ if (motor.standard !== undefined && motor.model !== undefined) {
47
+ context.addIssue({
48
+ code: z.ZodIssueCode.custom,
49
+ message: "Provide either standard or model, not both",
50
+ path: ["model"],
51
+ })
52
+ }
53
+ })
54
+
55
+ export type AssemblyMotorPropsInput = z.input<typeof assemblyMotorProps>
56
+
57
+ expectTypesMatch<AssemblyMotorProps, AssemblyMotorPropsInput>(true)
@@ -78,6 +78,17 @@ export const boardOutlinePoint = z
78
78
  export interface BoardProps
79
79
  extends Omit<SubcircuitGroupProps, "subcircuit" | "connections" | "outline"> {
80
80
  title?: string
81
+ /**
82
+ * Assembly mounting target, such as "NEMA17.backface". Trimmed; omitted
83
+ * leaves the board unattached. The target face is resolved by the consumer.
84
+ */
85
+ mountedTo?: string
86
+ /**
87
+ * Nonnegative finite clearance between the target mounting face and the
88
+ * nearest PCB surface, in millimeters or a unit string. Parsed to mm.
89
+ * Omitted leaves the gap unset; only meaningful when mountedTo is supplied.
90
+ */
91
+ mountGap?: Distance
81
92
  /** Fabricator preset, preserved as supplied. Omitted leaves the preset unset. */
82
93
  fabricatorPreset?:
83
94
  | "jlcpcb_economy"
@@ -153,6 +164,20 @@ export interface BoardProps
153
164
  export const boardProps = subcircuitGroupProps
154
165
  .omit({ connections: true })
155
166
  .extend({
167
+ mountedTo: z
168
+ .string()
169
+ .trim()
170
+ .min(1)
171
+ .optional()
172
+ .describe(
173
+ 'Assembly mounting target, such as "NEMA17.backface". Trimmed; omitted leaves the board unattached. The target face is resolved by the consumer.',
174
+ ),
175
+ mountGap: distance
176
+ .pipe(z.number().nonnegative().finite())
177
+ .optional()
178
+ .describe(
179
+ "Nonnegative finite clearance between the target mounting face and the nearest PCB surface, in millimeters or a unit string, parsed to mm. Omitted leaves the gap unset; only meaningful when mountedTo is supplied.",
180
+ ),
156
181
  fabricatorPreset: z
157
182
  .enum([
158
183
  "jlcpcb_economy",
@@ -3,7 +3,7 @@ import { distance, type Distance } from "lib/common/distance"
3
3
  import { expectTypesMatch } from "lib/typecheck"
4
4
  import { z } from "zod"
5
5
 
6
- /** A bend on a flat flex PCB. Does not change fabrication coordinates. */
6
+ /** A bend on a flat flex PCB, with optional tear-relief cutouts. */
7
7
  export interface PcbBendProps {
8
8
  name?: string
9
9
  /** Start/end of the bend-zone centerline in the parent PCB coordinate system. */
@@ -15,6 +15,14 @@ export interface PcbBendProps {
15
15
  bendAngle: number | string
16
16
  /** Positive neutral-surface radius, in mm or a distance string. */
17
17
  bendRadius: Distance
18
+ /**
19
+ * Radius of circular tear-relief cutouts centered at both bend endpoints in
20
+ * the flat PCB. Removes material to round the edge where each cutout meets
21
+ * the board outline. Finite and positive, in mm or a distance string;
22
+ * parsed to mm. Omit to leave the outline unchanged (no tear reliefs).
23
+ * Independent of bendRadius and bendSide; no aliases or conflicting props.
24
+ */
25
+ tearReliefRadius?: Distance
18
26
  /** Moving side, looking from (x1, y1) toward (x2, y2) in the flat layout. */
19
27
  bendSide: "left" | "right"
20
28
  }
@@ -30,6 +38,7 @@ export const pcbBendProps = z
30
38
  y2: finiteDistance,
31
39
  bendAngle: rotation.pipe(z.number().finite()),
32
40
  bendRadius: distance.pipe(z.number().finite().positive()),
41
+ tearReliefRadius: distance.pipe(z.number().finite().positive()).optional(),
33
42
  bendSide: z.enum(["left", "right"]),
34
43
  })
35
44
  .refine(({ x1, y1, x2, y2 }) => x1 !== x2 || y1 !== y2, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.677",
3
+ "version": "0.0.679",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",