@tscircuit/props 0.0.712 → 0.0.714

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,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
- !(isSimplifyAutorouter && value.reroute === true) &&
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
@@ -18,7 +18,8 @@ export interface SymbolProps {
18
18
  * Source sizing bounds in the local symbol coordinate space (mm, +X right, +Y up).
19
19
  * With width/height, maps the bounds center to the symbol position; all artwork
20
20
  * and ports use the same transform. Omitted uses automatic bounds including ports.
21
- * maxX must exceed minX and maxY must exceed minY. No aliases; no change to existing defaults.
21
+ * maxX must exceed minX and maxY must exceed minY. Other shapes are rejected
22
+ * with a diagnostic listing the required bounds. No aliases; existing defaults are unchanged.
22
23
  */
23
24
  viewbox?: {
24
25
  minX: number | string
@@ -29,6 +30,22 @@ export interface SymbolProps {
29
30
  name?: string
30
31
  }
31
32
 
33
+ const symbolViewboxBounds = z
34
+ .object({
35
+ minX: distance,
36
+ maxX: distance,
37
+ minY: distance,
38
+ maxY: distance,
39
+ })
40
+ .refine((bounds) => bounds.maxX > bounds.minX, {
41
+ message: "viewbox maxX must exceed minX",
42
+ path: ["maxX"],
43
+ })
44
+ .refine((bounds) => bounds.maxY > bounds.minY, {
45
+ message: "viewbox maxY must exceed minY",
46
+ path: ["maxY"],
47
+ })
48
+
32
49
  export const symbolProps = z.object({
33
50
  originalFacingDirection: z
34
51
  .enum(["up", "down", "left", "right"])
@@ -38,20 +55,20 @@ export const symbolProps = z.object({
38
55
  height: distance.optional(),
39
56
  fit: z.enum(["fill", "contain", "stretch"]).optional(),
40
57
  viewbox: z
41
- .object({
42
- minX: distance,
43
- maxX: distance,
44
- minY: distance,
45
- maxY: distance,
46
- })
47
- .refine((bounds) => bounds.maxX > bounds.minX, {
48
- message: "viewbox maxX must exceed minX",
49
- path: ["maxX"],
50
- })
51
- .refine((bounds) => bounds.maxY > bounds.minY, {
52
- message: "viewbox maxY must exceed minY",
53
- path: ["maxY"],
54
- })
58
+ .custom<z.input<typeof symbolViewboxBounds>>(
59
+ (bounds) =>
60
+ typeof bounds === "object" &&
61
+ bounds !== null &&
62
+ "minX" in bounds &&
63
+ "maxX" in bounds &&
64
+ "minY" in bounds &&
65
+ "maxY" in bounds,
66
+ {
67
+ message:
68
+ "viewbox requires { minX, maxX, minY, maxY } bounds in the local symbol coordinate space.",
69
+ },
70
+ )
71
+ .pipe(symbolViewboxBounds)
55
72
  .optional(),
56
73
  name: z.string().optional(),
57
74
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.712",
3
+ "version": "0.0.714",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",