@tscircuit/props 0.0.647 → 0.0.649

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,62 @@
1
+ import { layer_ref } from "circuit-json"
2
+ import { z } from "zod"
3
+ import { distance } from "./distance"
4
+
5
+ const coordinate = distance.refine(Number.isFinite, "Coordinate must be finite")
6
+ const positiveDistance = distance.refine(
7
+ (value) => Number.isFinite(value) && value > 0,
8
+ "Distance must be positive and finite",
9
+ )
10
+ const routePoint = z.discriminatedUnion("route_type", [
11
+ z.object({
12
+ route_type: z.literal("wire"),
13
+ x: coordinate,
14
+ y: coordinate,
15
+ width: positiveDistance,
16
+ layer: layer_ref,
17
+ }),
18
+ z.object({
19
+ route_type: z.literal("via"),
20
+ x: coordinate,
21
+ y: coordinate,
22
+ from_layer: layer_ref,
23
+ to_layer: layer_ref,
24
+ via_diameter: positiveDistance.optional(),
25
+ via_hole_diameter: positiveDistance.optional(),
26
+ }),
27
+ ])
28
+
29
+ /**
30
+ * A saved route from a selected port to a fanout exit. Points are in the
31
+ * fanout's local PCB frame, in mm: +X right, +Y up, right-handed with +Z
32
+ * above the board. They are points (placement adds translation), not
33
+ * directions. Numeric distances are mm; unit strings are parsed to mm.
34
+ * Layers are physical board layers, independent of placement. Either endpoint
35
+ * may be a via: the initial layer is its from_layer and the final layer is its
36
+ * to_layer. Placement legality (including allowViaInPad) is checked by core,
37
+ * since this schema has no pad geometry or inherited routing configuration.
38
+ */
39
+ export const fanoutTracePath = z.object({
40
+ connection: z.string().min(1),
41
+ route: z
42
+ .array(routePoint)
43
+ .min(2)
44
+ .superRefine((route, ctx) => {
45
+ const first = route[0]
46
+ let layer = first?.route_type === "via" ? first.from_layer : first?.layer
47
+ for (const point of route) {
48
+ if (
49
+ (point.route_type === "wire" ? point.layer : point.from_layer) !==
50
+ layer
51
+ ) {
52
+ ctx.addIssue({
53
+ code: "custom",
54
+ message: "A fanout trace path must use vias for layer changes",
55
+ })
56
+ }
57
+ if (point.route_type === "via") layer = point.to_layer
58
+ }
59
+ }),
60
+ })
61
+
62
+ export type FanoutTracePath = z.input<typeof fanoutTracePath>
@@ -1,3 +1,7 @@
1
+ import {
2
+ fanoutTracePath,
3
+ type FanoutTracePath,
4
+ } from "lib/common/fanoutTracePath"
1
5
  import { distance, type Distance } from "lib/common/distance"
2
6
  import { type FanoutProps, fanoutProps } from "lib/common/fanoutProps"
3
7
  import { expectTypesMatch } from "lib/typecheck"
@@ -17,6 +21,19 @@ export interface BreakoutProps
17
21
  * Defaults to the multilayer fanout autorouter.
18
22
  */
19
23
  autorouter?: AutorouterProp
24
+ /**
25
+ * Saved port-to-exit wire/via routes in the fanout's local PCB frame.
26
+ * Numeric distances are mm; unit strings are normalized to mm. Each route
27
+ * must start at its selected port and end at its fanout exit. Layers name
28
+ * physical board layers. Either endpoint may be a via when permitted by
29
+ * the circuit's routing rules (e.g. allowViaInPad for a via at a pad).
30
+ * Core creates the exits and preserves saved copper.
31
+ * When supplied, replaces automatic routing (including `autorouter`) for
32
+ * this fanout and must cover all its routing connections. Do not also add
33
+ * a breakoutpoint/fanoutpoint for the same port. Omitted by default; existing
34
+ * automatic fanouts are unchanged. No aliases or migration are required.
35
+ */
36
+ pcbTracePaths?: FanoutTracePath[]
20
37
  padding?: Distance
21
38
  paddingLeft?: Distance
22
39
  paddingRight?: Distance
@@ -35,6 +52,7 @@ const nonnegativeFanoutMargin = distance.refine((value) => value >= 0, {
35
52
 
36
53
  export const breakoutProps = subcircuitGroupProps.extend({
37
54
  autorouter: autorouterProp.default("fanout"),
55
+ pcbTracePaths: z.array(fanoutTracePath).optional(),
38
56
  padding: distance.optional(),
39
57
  paddingLeft: distance.optional(),
40
58
  paddingRight: distance.optional(),
package/lib/index.ts CHANGED
@@ -145,3 +145,5 @@ export * from "./common/ninePointAnchor"
145
145
  export * from "./common/fanoutBoundaryPadding"
146
146
  export * from "./common/fanoutProps"
147
147
  export * from "./common/implicitBreakoutPointSolver"
148
+
149
+ export * from "./common/fanoutTracePath"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.647",
3
+ "version": "0.0.649",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",