@tscircuit/props 0.0.677 → 0.0.678
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 +11 -0
- package/dist/index.d.ts +185 -80
- package/dist/index.js +1264 -1228
- package/dist/index.js.map +1 -1
- package/lib/assembly/index.ts +3 -0
- package/lib/assembly/motor.ts +57 -0
- package/lib/components/board.ts +25 -0
- package/package.json +1 -1
package/lib/assembly/index.ts
CHANGED
|
@@ -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)
|
package/lib/components/board.ts
CHANGED
|
@@ -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",
|