@tscircuit/props 0.0.713 → 0.0.715
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 +17 -0
- package/dist/index.d.ts +168 -2
- package/dist/index.js +55 -2
- package/dist/index.js.map +1 -1
- package/lib/assembly/cable.ts +45 -7
- package/lib/components/autoroutingphase.ts +64 -1
- package/package.json +1 -1
package/lib/assembly/cable.ts
CHANGED
|
@@ -14,15 +14,53 @@ export interface AssemblyCableProps {
|
|
|
14
14
|
standard?: AssemblyCableStandard
|
|
15
15
|
/** Explicit cable model specification. Omit to infer the cable from its endpoints. */
|
|
16
16
|
model?: string
|
|
17
|
+
waypoints?: { x: number; y: number; z: number }[]
|
|
18
|
+
/** Reference endpoint for waypoint offsets. Required when waypoints is defined. */
|
|
19
|
+
waypointAnchor?: "start" | "end"
|
|
20
|
+
/** Board orientation for waypoint axes. Required when waypoints is defined. */
|
|
21
|
+
waypointAxisOrientation?: "board_at_start" | "board_at_end"
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
export const assemblyCableProps = z
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
export const assemblyCableProps = z
|
|
25
|
+
.object({
|
|
26
|
+
name: z.string().trim().min(1),
|
|
27
|
+
from: z.string().trim().min(1),
|
|
28
|
+
to: z.string().trim().min(1),
|
|
29
|
+
standard: z.literal("usb_c").optional(),
|
|
30
|
+
model: z.string().trim().min(1).optional(),
|
|
31
|
+
waypoints: z
|
|
32
|
+
.array(
|
|
33
|
+
z.object({
|
|
34
|
+
x: z.number().finite(),
|
|
35
|
+
y: z.number().finite(),
|
|
36
|
+
z: z.number().finite(),
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
.optional(),
|
|
40
|
+
waypointAnchor: z.enum(["start", "end"]).optional(),
|
|
41
|
+
waypointAxisOrientation: z
|
|
42
|
+
.enum(["board_at_start", "board_at_end"])
|
|
43
|
+
.optional(),
|
|
44
|
+
})
|
|
45
|
+
.superRefine((cable, context) => {
|
|
46
|
+
if (cable.waypoints === undefined) return
|
|
47
|
+
|
|
48
|
+
if (cable.waypointAnchor === undefined) {
|
|
49
|
+
context.addIssue({
|
|
50
|
+
code: z.ZodIssueCode.custom,
|
|
51
|
+
path: ["waypointAnchor"],
|
|
52
|
+
message: "waypointAnchor is required when waypoints is defined",
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
if (cable.waypointAxisOrientation === undefined) {
|
|
56
|
+
context.addIssue({
|
|
57
|
+
code: z.ZodIssueCode.custom,
|
|
58
|
+
path: ["waypointAxisOrientation"],
|
|
59
|
+
message:
|
|
60
|
+
"waypointAxisOrientation is required when waypoints is defined",
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
})
|
|
26
64
|
|
|
27
65
|
export type AssemblyCablePropsInput = z.input<typeof assemblyCableProps>
|
|
28
66
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { distance, type Distance } from "../common/distance"
|
|
1
2
|
import { expectTypesMatch } from "lib/typecheck"
|
|
2
3
|
import { z } from "zod"
|
|
3
4
|
import { type FanoutProps, fanoutProps } from "../common/fanoutProps"
|
|
@@ -56,6 +57,23 @@ export interface AutoroutingPhaseProps extends RoutingTolerances, FanoutProps {
|
|
|
56
57
|
// Reroutes traces selected by region or connection. The simplify autorouter
|
|
57
58
|
// may omit a selector to simplify every existing trace in the phase.
|
|
58
59
|
reroute?: boolean
|
|
60
|
+
/**
|
|
61
|
+
* Select the test-point autorouter. Requires reroute=true; omitted/false leaves
|
|
62
|
+
* existing routing unchanged. Optional connection(s) select traces, otherwise
|
|
63
|
+
* all routed traces are selected. Conflicts with region, pcbTracePaths,
|
|
64
|
+
* autorouter and algorithmFn. No alias for the unreleased pcbTestPoints object.
|
|
65
|
+
*/
|
|
66
|
+
addTestPoints?: boolean
|
|
67
|
+
/** Test-point layer; defaults to bottom when addTestPoints is enabled. */
|
|
68
|
+
testPointLayer?: "top" | "bottom"
|
|
69
|
+
/** Probe pad diameter, mm or unit string; defaults to 1 mm. Must be positive. */
|
|
70
|
+
testPointDiameter?: Distance
|
|
71
|
+
/** Copper edge clearance, mm or unit string; defaults to 0.2 mm. */
|
|
72
|
+
testPointClearance?: Distance
|
|
73
|
+
/** Minimum probe center spacing, mm or unit string; defaults to 2.54 mm. */
|
|
74
|
+
testPointMinProbeSpacing?: Distance
|
|
75
|
+
/** Maximum local trace detour, mm or unit string; defaults to 1 mm. */
|
|
76
|
+
testPointMaxDetour?: Distance
|
|
59
77
|
}
|
|
60
78
|
|
|
61
79
|
export const autoroutingPhaseProps = z
|
|
@@ -80,9 +98,51 @@ export const autoroutingPhaseProps = z
|
|
|
80
98
|
connection: z.string().optional(),
|
|
81
99
|
connections: z.array(z.string()).optional(),
|
|
82
100
|
reroute: z.boolean().optional(),
|
|
101
|
+
addTestPoints: z.boolean().optional(),
|
|
102
|
+
testPointLayer: z.enum(["top", "bottom"]).optional(),
|
|
103
|
+
testPointDiameter: distance.pipe(z.number().finite().positive()).optional(),
|
|
104
|
+
testPointClearance: distance
|
|
105
|
+
.pipe(z.number().finite().nonnegative())
|
|
106
|
+
.optional(),
|
|
107
|
+
testPointMinProbeSpacing: distance
|
|
108
|
+
.pipe(z.number().finite().nonnegative())
|
|
109
|
+
.optional(),
|
|
110
|
+
testPointMaxDetour: distance
|
|
111
|
+
.pipe(z.number().finite().nonnegative())
|
|
112
|
+
.optional(),
|
|
83
113
|
...fanoutProps.shape,
|
|
84
114
|
})
|
|
85
115
|
.superRefine((value, ctx) => {
|
|
116
|
+
if (
|
|
117
|
+
value.addTestPoints &&
|
|
118
|
+
(value.reroute !== true ||
|
|
119
|
+
value.region ||
|
|
120
|
+
value.pcbTracePaths ||
|
|
121
|
+
value.autorouter ||
|
|
122
|
+
value.algorithmFn)
|
|
123
|
+
) {
|
|
124
|
+
ctx.addIssue({
|
|
125
|
+
code: z.ZodIssueCode.custom,
|
|
126
|
+
path: ["addTestPoints"],
|
|
127
|
+
message:
|
|
128
|
+
"addTestPoints requires reroute=true and cannot combine with region, pcbTracePaths, autorouter, or algorithmFn",
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
for (const option of [
|
|
132
|
+
"testPointLayer",
|
|
133
|
+
"testPointDiameter",
|
|
134
|
+
"testPointClearance",
|
|
135
|
+
"testPointMinProbeSpacing",
|
|
136
|
+
"testPointMaxDetour",
|
|
137
|
+
] as const) {
|
|
138
|
+
if (value[option] !== undefined && !value.addTestPoints) {
|
|
139
|
+
ctx.addIssue({
|
|
140
|
+
code: z.ZodIssueCode.custom,
|
|
141
|
+
path: [option],
|
|
142
|
+
message: `${option} requires addTestPoints=true`,
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
}
|
|
86
146
|
const isSimplifyAutorouter =
|
|
87
147
|
value.autorouter === "simplify" ||
|
|
88
148
|
(typeof value.autorouter === "object" &&
|
|
@@ -96,7 +156,10 @@ export const autoroutingPhaseProps = z
|
|
|
96
156
|
|
|
97
157
|
if (
|
|
98
158
|
value.reroute !== undefined &&
|
|
99
|
-
!(
|
|
159
|
+
!(
|
|
160
|
+
(isSimplifyAutorouter || value.addTestPoints) &&
|
|
161
|
+
value.reroute === true
|
|
162
|
+
) &&
|
|
100
163
|
value.region === undefined &&
|
|
101
164
|
value.connection === undefined &&
|
|
102
165
|
value.connections === undefined
|