@tscircuit/props 0.0.684 → 0.0.686

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.
@@ -0,0 +1,26 @@
1
+ import { expectTypesMatch } from "lib/typecheck"
2
+ import { z } from "zod"
3
+
4
+ export type AssemblyCableStandard = "usb_c"
5
+
6
+ export interface AssemblyCableProps {
7
+ /** Stable assembly identity for the cable. */
8
+ name: string
9
+ /** Start connector selector or named assembly reference, e.g. MOTOR.wireside. */
10
+ from: string
11
+ /** End connector selector or named assembly reference. */
12
+ to: string
13
+ /** Optional USB-C-to-USB-C preset. Omit to infer the cable from its endpoints. */
14
+ standard?: AssemblyCableStandard
15
+ }
16
+
17
+ export const assemblyCableProps = z.object({
18
+ name: z.string().trim().min(1),
19
+ from: z.string().trim().min(1),
20
+ to: z.string().trim().min(1),
21
+ standard: z.literal("usb_c").optional(),
22
+ })
23
+
24
+ export type AssemblyCablePropsInput = z.input<typeof assemblyCableProps>
25
+
26
+ expectTypesMatch<AssemblyCableProps, AssemblyCablePropsInput>(true)
@@ -1,19 +1,25 @@
1
1
  import { assemblyCadAssemblyProps } from "./cadassembly"
2
+ import { assemblyCableProps } from "./cable"
2
3
  import { assemblyDeviceProps } from "./device"
4
+ import { assemblyPrintedPartProps } from "./printedpart"
3
5
  import { assemblyMotorProps } from "./motor"
4
6
  import { assemblyScreenProps } from "./screen"
5
7
  import { assemblySubassemblyProps } from "./subassembly"
6
8
 
7
9
  export * from "./board-mounting"
10
+ export * from "./cable"
8
11
  export * from "./device"
9
12
  export * from "./motor"
13
+ export * from "./printedpart"
10
14
  export * from "./screen"
11
15
  export * from "./subassembly"
12
16
  export * from "./cadassembly"
13
17
 
14
18
  export const assemblyProps = {
19
+ cable: assemblyCableProps,
15
20
  device: assemblyDeviceProps,
16
21
  motor: assemblyMotorProps,
22
+ printedpart: assemblyPrintedPartProps,
17
23
  screen: assemblyScreenProps,
18
24
  subassembly: assemblySubassemblyProps,
19
25
  cadassembly: assemblyCadAssemblyProps,
@@ -0,0 +1,86 @@
1
+ import { type CadModelProp, cadModelProp } from "lib/common/cadModel"
2
+ import { url } from "lib/common/url"
3
+ import { distance, type Distance } from "lib/common/distance"
4
+ import { expectTypesMatch } from "lib/typecheck"
5
+ import { isValidElement, type ReactElement } from "react"
6
+ import { z } from "zod"
7
+
8
+ /** Provide exactly one of jscad, model, modelUrl, or cadModel. */
9
+ export interface AssemblyPrintedPartProps {
10
+ /** Stable identity used by assembly mounting selectors. */
11
+ name: string
12
+ displayName?: string
13
+ /** Pure jscad-fiber JSX in right-handed local XYZ, dimensions in millimeters.
14
+ * Named reference rectangles define attachment faces; they add no material.
15
+ * Hooks, async components, and raw kernel geometry are not supported.
16
+ */
17
+ jscad?: ReactElement
18
+ /** Modelprinter/footprinter string or model URL. */
19
+ model?: string
20
+ modelUrl?: string
21
+ cadModel?: CadModelProp
22
+ /** Assembly mounting target. */
23
+ mountedTo?: string
24
+ /** Name of this part's reference rectangle to mate with mountedTo.
25
+ * Both props must be supplied together; outward normals oppose and local
26
+ * in-plane X directions align. Without them the part uses its local origin.
27
+ */
28
+ mountFace?: string
29
+ /** Nonnegative surface clearance in mm or a unit string; defaults to zero.
30
+ * Requires mountedTo. Positive values separate the mating faces.
31
+ */
32
+ mountGap?: Distance
33
+ }
34
+
35
+ export const assemblyPrintedPartProps = z
36
+ .object({
37
+ name: z.string().trim().min(1),
38
+ displayName: z.string().optional(),
39
+ jscad: z
40
+ .custom<ReactElement>(isValidElement, "Expected jscad-fiber JSX")
41
+ .optional(),
42
+ model: z.string().trim().min(1).optional(),
43
+ modelUrl: url
44
+ .refine((value) => value.trim().length > 0, "modelUrl cannot be empty")
45
+ .optional(),
46
+ cadModel: cadModelProp.optional(),
47
+ mountedTo: z
48
+ .string()
49
+ .trim()
50
+ .regex(/^.+\.[^.]+$/, "Expected part.face")
51
+ .optional(),
52
+ mountFace: z.string().trim().min(1).optional(),
53
+ mountGap: distance.pipe(z.number().nonnegative().finite()).optional(),
54
+ })
55
+ .superRefine((part, ctx) => {
56
+ if (
57
+ [part.jscad, part.model, part.modelUrl, part.cadModel].filter(
58
+ (value) => value !== undefined,
59
+ ).length !== 1
60
+ ) {
61
+ ctx.addIssue({
62
+ code: z.ZodIssueCode.custom,
63
+ path: ["jscad"],
64
+ message: "Provide exactly one of jscad, model, modelUrl, or cadModel",
65
+ })
66
+ }
67
+ if ((part.mountedTo === undefined) !== (part.mountFace === undefined)) {
68
+ ctx.addIssue({
69
+ code: z.ZodIssueCode.custom,
70
+ path: ["mountFace"],
71
+ message: "Provide mountedTo and mountFace together",
72
+ })
73
+ }
74
+ if (part.mountGap !== undefined && part.mountedTo === undefined) {
75
+ ctx.addIssue({
76
+ code: z.ZodIssueCode.custom,
77
+ path: ["mountGap"],
78
+ message: "mountGap requires mountedTo",
79
+ })
80
+ }
81
+ })
82
+
83
+ export type AssemblyPrintedPartPropsInput = z.input<
84
+ typeof assemblyPrintedPartProps
85
+ >
86
+ expectTypesMatch<AssemblyPrintedPartProps, AssemblyPrintedPartPropsInput>(true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.684",
3
+ "version": "0.0.686",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",