@tscircuit/props 0.0.706 → 0.0.708

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,15 @@
1
+ import { assemblyDrawingTitleBlockProps } from "./titleblock"
2
+ import { assemblyDrawingPageProps } from "./page"
3
+ import { assemblyDrawingPartViewProps } from "./partview"
4
+
5
+ export * from "./page"
6
+ export * from "./page-size"
7
+ export * from "./titleblock"
8
+ export * from "./partview"
9
+
10
+ /** Drawing namespace; pages contain configured part views. */
11
+ export const assemblyDrawingProps = {
12
+ page: assemblyDrawingPageProps,
13
+ titleblock: assemblyDrawingTitleBlockProps,
14
+ partview: assemblyDrawingPartViewProps,
15
+ } as const
@@ -0,0 +1,37 @@
1
+ import { z } from "zod"
2
+
3
+ /** Landscape dimensions in mm. ISO A-series / ASME Y14.1 decimal-inch sheets. */
4
+ export const assemblyDrawingPageSizes = {
5
+ iso_a0: [1189, 841],
6
+ iso_a1: [841, 594],
7
+ iso_a2: [594, 420],
8
+ iso_a3: [420, 297],
9
+ iso_a4: [297, 210],
10
+ ansi_a: [279.4, 215.9],
11
+ ansi_b: [431.8, 279.4],
12
+ ansi_c: [558.8, 431.8],
13
+ ansi_d: [863.6, 558.8],
14
+ ansi_e: [1117.6, 863.6],
15
+ } as const
16
+ export const assemblyDrawingPageSize = z.enum([
17
+ "iso_a0",
18
+ "iso_a1",
19
+ "iso_a2",
20
+ "iso_a3",
21
+ "iso_a4",
22
+ "ansi_a",
23
+ "ansi_b",
24
+ "ansi_c",
25
+ "ansi_d",
26
+ "ansi_e",
27
+ ])
28
+ export type AssemblyDrawingPageSize = z.infer<typeof assemblyDrawingPageSize>
29
+ export function getAssemblyDrawingPageDimensions(
30
+ size: AssemblyDrawingPageSize,
31
+ orientation: "landscape" | "portrait" = "landscape",
32
+ ) {
33
+ const [width, height] = assemblyDrawingPageSizes[size]
34
+ return orientation === "portrait"
35
+ ? { width: height, height: width }
36
+ : { width, height }
37
+ }
@@ -0,0 +1,64 @@
1
+ import { z } from "zod"
2
+ import {
3
+ assemblyDrawingPageSize,
4
+ getAssemblyDrawingPageDimensions,
5
+ type AssemblyDrawingPageSize,
6
+ } from "./page-size"
7
+ import { distance } from "circuit-json"
8
+ import type { Distance } from "lib/common/distance"
9
+ import { expectTypesMatch } from "lib/typecheck"
10
+
11
+ /** A paper-space drawing page containing configured part views. */
12
+ export interface AssemblyDrawingPageProps {
13
+ name?: string
14
+ displayName?: string
15
+ /** Standard sheet size; landscape by default. Mutually exclusive with width/height. */
16
+ size?: AssemblyDrawingPageSize
17
+ orientation?: "landscape" | "portrait"
18
+ /** Custom paper dimensions in mm when numeric; unit strings are accepted. */
19
+ width?: Distance
20
+ height?: Distance
21
+ children?: any
22
+ }
23
+
24
+ export const assemblyDrawingPageProps = z
25
+ .object({
26
+ name: z.string().optional(),
27
+ displayName: z.string().optional(),
28
+ size: assemblyDrawingPageSize.optional(),
29
+ orientation: z.enum(["landscape", "portrait"]).optional(),
30
+ width: distance.pipe(z.number().finite().positive()).optional(),
31
+ height: distance.pipe(z.number().finite().positive()).optional(),
32
+ children: z.any().optional(),
33
+ })
34
+ .superRefine((page, ctx) => {
35
+ if (
36
+ page.size
37
+ ? page.width != null || page.height != null
38
+ : page.width == null || page.height == null
39
+ )
40
+ ctx.addIssue({
41
+ code: "custom",
42
+ message: "Specify size or both width and height, exclusively",
43
+ })
44
+ if (!page.size && page.orientation)
45
+ ctx.addIssue({
46
+ code: "custom",
47
+ path: ["orientation"],
48
+ message: "Orientation requires a standard size",
49
+ })
50
+ })
51
+ .transform((page) => ({
52
+ ...page,
53
+ ...(page.size
54
+ ? getAssemblyDrawingPageDimensions(page.size, page.orientation)
55
+ : { width: page.width!, height: page.height! }),
56
+ }))
57
+
58
+ export type InferredAssemblyDrawingPageProps = z.input<
59
+ typeof assemblyDrawingPageProps
60
+ >
61
+ expectTypesMatch<
62
+ AssemblyDrawingPageProps,
63
+ z.input<typeof assemblyDrawingPageProps>
64
+ >(true)
@@ -0,0 +1,118 @@
1
+ import { z } from "zod"
2
+ import { distance } from "circuit-json"
3
+ import type { Distance } from "lib/common/distance"
4
+ import { expectTypesMatch } from "lib/typecheck"
5
+
6
+ /** Axis names use tscircuit CAD coordinates: mm, +Z up. The camera sits on
7
+ * the named side of the model and looks toward its center. */
8
+ export type AssemblyDrawingPartViewDirection =
9
+ | "x+"
10
+ | "x-"
11
+ | "y+"
12
+ | "y-"
13
+ | "z+"
14
+ | "z-"
15
+ | "isometric"
16
+
17
+ export interface AssemblyDrawingSectionPlane {
18
+ axis: "x" | "y" | "z"
19
+ /** Plane coordinate in CAD world space, numeric mm or a distance string. */
20
+ offset: Distance
21
+ /** Retain coordinates <= offset or >= offset, respectively. */
22
+ keepSide: "less" | "greater"
23
+ /** Physical distance between 45-degree strokes on the model. Defaults to 1mm. */
24
+ hatchSpacing?: Distance
25
+ }
26
+
27
+ export const assemblyDrawingSectionPlane = z.object({
28
+ axis: z.enum(["x", "y", "z"]),
29
+ offset: distance.pipe(z.number().finite()),
30
+ keepSide: z.enum(["less", "greater"]),
31
+ hatchSpacing: distance.pipe(z.number().finite().positive()).default(1),
32
+ })
33
+
34
+ /** An orthographic viewport within an assembly.drawing.page. */
35
+ export interface AssemblyDrawingPartViewProps {
36
+ name?: string
37
+ displayName?: string
38
+ /** Selector for the board, group or assembly geometry shown in this view. */
39
+ partRef: string
40
+ direction: AssemblyDrawingPartViewDirection
41
+ /** Viewport center relative to the paper center, mm; +X right, +Y up. Defaults to 0 on axes without a relative reference. */
42
+ centerX?: Distance
43
+ centerY?: Distance
44
+ /** Sibling part-view selector; infer centerX with this viewport left of the reference. Conflicts with rightOfRef and centerX. */
45
+ leftOfRef?: string
46
+ /** Sibling part-view selector; infer centerX with this viewport right of the reference. Conflicts with leftOfRef and centerX. */
47
+ rightOfRef?: string
48
+ /** Sibling part-view selector; infer centerY with this viewport above the reference. Conflicts with belowRef and centerY. */
49
+ aboveRef?: string
50
+ /** Sibling part-view selector; infer centerY with this viewport below the reference. Conflicts with aboveRef and centerY. */
51
+ belowRef?: string
52
+ /** Paper-space viewport size; dimensions must be positive. */
53
+ width: Distance
54
+ height: Distance
55
+ /** Draw obscured edges as dashed strokes. Defaults to false. */
56
+ showHiddenEdges?: boolean
57
+ /** A planar cut with diagonal hatching on closed cut surfaces. */
58
+ section?: AssemblyDrawingSectionPlane
59
+ }
60
+
61
+ export const assemblyDrawingPartViewProps = z
62
+ .object({
63
+ name: z.string().optional(),
64
+ displayName: z.string().optional(),
65
+ partRef: z.string().min(1),
66
+ direction: z.enum(["x+", "x-", "y+", "y-", "z+", "z-", "isometric"]),
67
+ centerX: distance.pipe(z.number().finite()).optional(),
68
+ centerY: distance.pipe(z.number().finite()).optional(),
69
+ leftOfRef: z.string().trim().min(1).optional(),
70
+ rightOfRef: z.string().trim().min(1).optional(),
71
+ aboveRef: z.string().trim().min(1).optional(),
72
+ belowRef: z.string().trim().min(1).optional(),
73
+ width: distance.pipe(z.number().finite().positive()),
74
+ height: distance.pipe(z.number().finite().positive()),
75
+ showHiddenEdges: z.boolean().default(false),
76
+ section: assemblyDrawingSectionPlane.optional(),
77
+ })
78
+ .superRefine((view, ctx) => {
79
+ for (const [center, negative, positive] of [
80
+ ["centerX", "leftOfRef", "rightOfRef"],
81
+ ["centerY", "belowRef", "aboveRef"],
82
+ ] as const) {
83
+ if (view[negative] !== undefined && view[positive] !== undefined)
84
+ ctx.addIssue({
85
+ code: "custom",
86
+ path: [positive],
87
+ message: `${negative} and ${positive} are mutually exclusive`,
88
+ })
89
+ if (
90
+ view[center] !== undefined &&
91
+ (view[negative] !== undefined || view[positive] !== undefined)
92
+ )
93
+ ctx.addIssue({
94
+ code: "custom",
95
+ path: [center],
96
+ message: `${center} cannot be combined with ${negative} or ${positive}`,
97
+ })
98
+ }
99
+ })
100
+ .transform((view) => ({
101
+ ...view,
102
+ ...(view.leftOfRef || view.rightOfRef
103
+ ? {}
104
+ : { centerX: view.centerX ?? 0 }),
105
+ ...(view.aboveRef || view.belowRef ? {} : { centerY: view.centerY ?? 0 }),
106
+ }))
107
+
108
+ export type InferredAssemblyDrawingPartViewProps = z.input<
109
+ typeof assemblyDrawingPartViewProps
110
+ >
111
+ expectTypesMatch<
112
+ AssemblyDrawingSectionPlane,
113
+ z.input<typeof assemblyDrawingSectionPlane>
114
+ >(true)
115
+ expectTypesMatch<
116
+ AssemblyDrawingPartViewProps,
117
+ z.input<typeof assemblyDrawingPartViewProps>
118
+ >(true)
@@ -0,0 +1,43 @@
1
+ import { z } from "zod"
2
+ import { expectTypesMatch } from "lib/typecheck"
3
+
4
+ /** Optional page child. Metadata fields reference ISO 7200:2004. */
5
+ export interface AssemblyDrawingTitleBlockProps {
6
+ name?: string
7
+ title: string
8
+ legalOwner?: string
9
+ identificationNumber?: string
10
+ revisionIndex?: string
11
+ dateOfIssue?: string
12
+ creator?: string
13
+ approvalPerson?: string
14
+ sheetNumber?: number
15
+ numberOfSheets?: number
16
+ }
17
+ export const assemblyDrawingTitleBlockProps = z
18
+ .object({
19
+ name: z.string().optional(),
20
+ title: z.string().min(1),
21
+ legalOwner: z.string().optional(),
22
+ identificationNumber: z.string().optional(),
23
+ revisionIndex: z.string().optional(),
24
+ dateOfIssue: z.string().optional(),
25
+ creator: z.string().optional(),
26
+ approvalPerson: z.string().optional(),
27
+ sheetNumber: z.number().int().positive().optional(),
28
+ numberOfSheets: z.number().int().positive().optional(),
29
+ })
30
+ .refine(
31
+ (block) =>
32
+ block.sheetNumber == null ||
33
+ block.numberOfSheets == null ||
34
+ block.sheetNumber <= block.numberOfSheets,
35
+ {
36
+ message: "sheetNumber must not exceed numberOfSheets",
37
+ path: ["sheetNumber"],
38
+ },
39
+ )
40
+ expectTypesMatch<
41
+ AssemblyDrawingTitleBlockProps,
42
+ z.input<typeof assemblyDrawingTitleBlockProps>
43
+ >(true)
@@ -0,0 +1,11 @@
1
+ import { assemblyExplosionMoveProps } from "./move"
2
+ import { assemblyExplosionStageProps } from "./stage"
3
+
4
+ export * from "./move"
5
+ export * from "./stage"
6
+
7
+ /** Explosion elements; no separate explosion container is needed. */
8
+ export const assemblyExplosionProps = {
9
+ stage: assemblyExplosionStageProps,
10
+ move: assemblyExplosionMoveProps,
11
+ } as const
@@ -0,0 +1,72 @@
1
+ import { type Distance, distance } from "lib/common/distance"
2
+ import { expectTypesMatch } from "lib/typecheck"
3
+ import { z } from "zod"
4
+
5
+ /** One straight, incremental movement within an explosion stage. */
6
+ export interface AssemblyExplosionMoveProps {
7
+ /** Parts or subassemblies to move together, relative to the stage owner.
8
+ * Accepts a comma-separated string or an array; parsed as a nonempty array of
9
+ * trimmed references. Supply exactly one of targetRefs or targetRef.
10
+ */
11
+ targetRefs?: string | string[]
12
+ /** Single-target compatibility alias for targetRefs. Parsed as targetRefs:
13
+ * [targetRef]; cannot be combined with targetRefs. React reserves ref.
14
+ */
15
+ targetRef?: string
16
+ /** Signed X displacement in the stage owner's frame, in mm or a unit string.
17
+ * Omitted axes mean zero in the consumer; parsed props remain omitted.
18
+ */
19
+ offX?: Distance
20
+ /** Signed Y displacement in the stage owner's frame, in mm or a unit string. */
21
+ offY?: Distance
22
+ /** Signed Z displacement in the stage owner's frame, in mm or a unit string. */
23
+ offZ?: Distance
24
+ }
25
+
26
+ const offset = distance.pipe(z.number().finite())
27
+ const reference = z.string().trim().min(1)
28
+ const references = z
29
+ .union([
30
+ z.string().transform((value) => value.split(",")),
31
+ z.array(z.string()),
32
+ ])
33
+ .pipe(z.array(reference).min(1))
34
+
35
+ export const assemblyExplosionMoveProps = z
36
+ .object({
37
+ targetRefs: references.optional(),
38
+ targetRef: reference.optional(),
39
+ offX: offset.optional(),
40
+ offY: offset.optional(),
41
+ offZ: offset.optional(),
42
+ })
43
+ .refine(
44
+ (move) =>
45
+ (move.targetRefs !== undefined) !== (move.targetRef !== undefined),
46
+ {
47
+ message: "Provide exactly one of targetRefs or targetRef",
48
+ path: ["targetRefs"],
49
+ },
50
+ )
51
+ .refine(
52
+ (move) =>
53
+ move.offX !== undefined ||
54
+ move.offY !== undefined ||
55
+ move.offZ !== undefined,
56
+ {
57
+ message: "Provide at least one of offX, offY, or offZ",
58
+ path: ["offX"],
59
+ },
60
+ )
61
+ .transform(({ targetRef, targetRefs, ...move }) => ({
62
+ ...move,
63
+ targetRefs: targetRefs ?? [targetRef!],
64
+ }))
65
+
66
+ export type AssemblyExplosionMovePropsInput = z.input<
67
+ typeof assemblyExplosionMoveProps
68
+ >
69
+
70
+ expectTypesMatch<AssemblyExplosionMoveProps, AssemblyExplosionMovePropsInput>(
71
+ true,
72
+ )
@@ -0,0 +1,30 @@
1
+ import { expectTypesMatch } from "lib/typecheck"
2
+ import type { ReactNode } from "react"
3
+ import { z } from "zod"
4
+
5
+ /** A named explosion stage owned by its containing device or subassembly. */
6
+ export interface AssemblyExplosionStageProps {
7
+ /** Stable stage identity, unique within the owning assembly. */
8
+ name: string
9
+ /** Stage that must execute after this one; qualified names may cross assembly scopes. */
10
+ nextStageRef?: string
11
+ /** Stage that must execute before this one; qualified names may cross assembly scopes. */
12
+ prevStageRef?: string
13
+ /** Ordered explosion moves; preserved unchanged for the consumer. */
14
+ children?: ReactNode
15
+ }
16
+
17
+ export const assemblyExplosionStageProps = z.object({
18
+ name: z.string().trim().min(1),
19
+ nextStageRef: z.string().trim().min(1).optional(),
20
+ prevStageRef: z.string().trim().min(1).optional(),
21
+ children: z.custom<ReactNode>().optional(),
22
+ })
23
+
24
+ export type AssemblyExplosionStagePropsInput = z.input<
25
+ typeof assemblyExplosionStageProps
26
+ >
27
+
28
+ expectTypesMatch<AssemblyExplosionStageProps, AssemblyExplosionStagePropsInput>(
29
+ true,
30
+ )
@@ -1,3 +1,4 @@
1
+ import { assemblyDrawingProps } from "./drawing"
1
2
  import { assemblyCadAssemblyProps } from "./cadassembly"
2
3
  import { assemblyCableProps } from "./cable"
3
4
  import { assemblyBoltProps } from "./bolt"
@@ -9,7 +10,9 @@ import { assemblyPrintedPartProps } from "./printedpart"
9
10
  import { assemblyMotorProps } from "./motor"
10
11
  import { assemblyScreenProps } from "./screen"
11
12
  import { assemblySubassemblyProps } from "./subassembly"
13
+ import { assemblyExplosionProps } from "./explosion"
12
14
 
15
+ export * from "./drawing"
13
16
  export * from "./board-mounting"
14
17
  export * from "./bolt"
15
18
  export * from "./fastener"
@@ -22,8 +25,11 @@ export * from "./printedpart"
22
25
  export * from "./screen"
23
26
  export * from "./subassembly"
24
27
  export * from "./cadassembly"
28
+ export * from "./explosion"
25
29
 
26
30
  export const assemblyProps = {
31
+ drawing: assemblyDrawingProps,
32
+ explosion: assemblyExplosionProps,
27
33
  bolt: assemblyBoltProps,
28
34
  fastener: assemblyFastenerProps,
29
35
  cable: assemblyCableProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.706",
3
+ "version": "0.0.708",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",