@tscircuit/props 0.0.664 → 0.0.666
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 +38 -0
- package/dist/index.d.ts +426 -2
- package/dist/index.js +847 -789
- package/dist/index.js.map +1 -1
- package/lib/components/autoroutingphase.ts +10 -0
- package/lib/components/pcb-bend.ts +42 -0
- package/lib/components/pcb-stiffener.ts +48 -0
- package/lib/index.ts +2 -0
- package/package.json +1 -1
|
@@ -6,9 +6,11 @@ import {
|
|
|
6
6
|
fanoutTracePath,
|
|
7
7
|
} from "../common/fanoutTracePath"
|
|
8
8
|
import {
|
|
9
|
+
type AutorouterConfig,
|
|
9
10
|
type AutorouterProp,
|
|
10
11
|
type PreflightRoutingCheckPolicy,
|
|
11
12
|
type RoutingTolerances,
|
|
13
|
+
autorouterConfig,
|
|
12
14
|
autorouterProp,
|
|
13
15
|
preflightRoutingCheckPolicy,
|
|
14
16
|
routingTolerances,
|
|
@@ -26,6 +28,13 @@ export interface AutoroutingPhaseProps extends RoutingTolerances, FanoutProps {
|
|
|
26
28
|
key?: any
|
|
27
29
|
name?: string
|
|
28
30
|
autorouter?: AutorouterProp
|
|
31
|
+
/**
|
|
32
|
+
* Custom async routing function accepting simple route JSON and returning the
|
|
33
|
+
* routing result, using the same contract as autorouter.algorithmFn. Parsing
|
|
34
|
+
* preserves the function unchanged. Omitted by default; no aliases or prop
|
|
35
|
+
* conflicts are introduced, and existing phases require no migration.
|
|
36
|
+
*/
|
|
37
|
+
algorithmFn?: AutorouterConfig["algorithmFn"]
|
|
29
38
|
preflightRoutingCheckPolicy?: PreflightRoutingCheckPolicy
|
|
30
39
|
phaseIndex?: number
|
|
31
40
|
/**
|
|
@@ -54,6 +63,7 @@ export const autoroutingPhaseProps = z
|
|
|
54
63
|
key: z.any().optional(),
|
|
55
64
|
name: z.string().optional(),
|
|
56
65
|
autorouter: autorouterProp.optional(),
|
|
66
|
+
algorithmFn: autorouterConfig.shape.algorithmFn,
|
|
57
67
|
preflightRoutingCheckPolicy: preflightRoutingCheckPolicy.optional(),
|
|
58
68
|
phaseIndex: z.number().optional(),
|
|
59
69
|
pcbTracePaths: z.array(fanoutTracePath).optional(),
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { rotation } from "circuit-json"
|
|
2
|
+
import { distance, type Distance } from "lib/common/distance"
|
|
3
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
4
|
+
import { z } from "zod"
|
|
5
|
+
|
|
6
|
+
/** A bend on a flat flex PCB. Does not change fabrication coordinates. */
|
|
7
|
+
export interface PcbBendProps {
|
|
8
|
+
name?: string
|
|
9
|
+
/** Start/end of the bend-zone centerline in the parent PCB coordinate system. */
|
|
10
|
+
x1: Distance
|
|
11
|
+
y1: Distance
|
|
12
|
+
x2: Distance
|
|
13
|
+
y2: Distance
|
|
14
|
+
/** Signed degrees (or an angle string). Positive folds toward the local top face. */
|
|
15
|
+
bendAngle: number | string
|
|
16
|
+
/** Positive neutral-surface radius, in mm or a distance string. */
|
|
17
|
+
bendRadius: Distance
|
|
18
|
+
/** Moving side, looking from (x1, y1) toward (x2, y2) in the flat layout. */
|
|
19
|
+
bendSide: "left" | "right"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const finiteDistance = distance.pipe(z.number().finite())
|
|
23
|
+
|
|
24
|
+
export const pcbBendProps = z
|
|
25
|
+
.object({
|
|
26
|
+
name: z.string().optional(),
|
|
27
|
+
x1: finiteDistance,
|
|
28
|
+
y1: finiteDistance,
|
|
29
|
+
x2: finiteDistance,
|
|
30
|
+
y2: finiteDistance,
|
|
31
|
+
bendAngle: rotation.pipe(z.number().finite()),
|
|
32
|
+
bendRadius: distance.pipe(z.number().finite().positive()),
|
|
33
|
+
bendSide: z.enum(["left", "right"]),
|
|
34
|
+
})
|
|
35
|
+
.refine(({ x1, y1, x2, y2 }) => x1 !== x2 || y1 !== y2, {
|
|
36
|
+
message: "Bend centerline endpoints must be distinct",
|
|
37
|
+
path: ["x2"],
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
expectTypesMatch<PcbBendProps, z.input<typeof pcbBendProps>>(true)
|
|
41
|
+
|
|
42
|
+
export type PcbBendPropsInput = z.input<typeof pcbBendProps>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { distance } from "lib/common/distance"
|
|
2
|
+
import { pcbLayoutProps } from "lib/common/layout"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
|
|
5
|
+
const positiveDistance = distance.pipe(z.number().finite().positive())
|
|
6
|
+
const finiteDistance = distance.pipe(z.number().finite())
|
|
7
|
+
const stiffenerBaseProps = pcbLayoutProps.omit({ layer: true }).extend({
|
|
8
|
+
name: z.string().optional(),
|
|
9
|
+
/** Board attachment face, not a copper-layer assignment. Required. */
|
|
10
|
+
layer: z.enum(["top", "bottom"]),
|
|
11
|
+
material: z.enum(["fr4", "polyimide", "stainless_steel", "aluminum"]),
|
|
12
|
+
/** Stiffener material thickness only, excluding PCB and adhesive. */
|
|
13
|
+
thickness: positiveDistance,
|
|
14
|
+
/** Nonnegative adhesive thickness; omission means unspecified, not zero. */
|
|
15
|
+
adhesiveThickness: distance
|
|
16
|
+
.pipe(z.number().finite().nonnegative())
|
|
17
|
+
.optional(),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export const pcbStiffenerProps = z.discriminatedUnion("shape", [
|
|
21
|
+
stiffenerBaseProps.extend({
|
|
22
|
+
shape: z.literal("rect"),
|
|
23
|
+
width: positiveDistance,
|
|
24
|
+
height: positiveDistance,
|
|
25
|
+
outline: z.never().optional(),
|
|
26
|
+
}),
|
|
27
|
+
stiffenerBaseProps.extend({
|
|
28
|
+
shape: z.literal("polygon"),
|
|
29
|
+
/** Local vertices transformed by pcbX/pcbY/pcbRotation; implicitly closed. */
|
|
30
|
+
outline: z
|
|
31
|
+
.array(z.object({ x: finiteDistance, y: finiteDistance }))
|
|
32
|
+
.min(3)
|
|
33
|
+
.refine((points) => {
|
|
34
|
+
const twiceArea = points.reduce((sum, p, i) => {
|
|
35
|
+
const next = points[(i + 1) % points.length]!
|
|
36
|
+
return sum + p.x * next.y - next.x * p.y
|
|
37
|
+
}, 0)
|
|
38
|
+
return Number.isFinite(twiceArea) && twiceArea !== 0
|
|
39
|
+
}, "Stiffener outline must enclose a nonzero area"),
|
|
40
|
+
width: z.never().optional(),
|
|
41
|
+
height: z.never().optional(),
|
|
42
|
+
}),
|
|
43
|
+
])
|
|
44
|
+
|
|
45
|
+
/** Bonded mechanical reinforcement; does not add copper layers or a rigid stackup. */
|
|
46
|
+
export type PcbStiffenerProps = z.input<typeof pcbStiffenerProps>
|
|
47
|
+
|
|
48
|
+
export type PcbStiffenerPropsInput = z.input<typeof pcbStiffenerProps>
|
package/lib/index.ts
CHANGED
|
@@ -27,6 +27,8 @@ export * from "./common/kicadPinMetadata"
|
|
|
27
27
|
export * from "./customDrc"
|
|
28
28
|
|
|
29
29
|
export * from "./components/board"
|
|
30
|
+
export * from "./components/pcb-bend"
|
|
31
|
+
export * from "./components/pcb-stiffener"
|
|
30
32
|
export * from "./components/panel"
|
|
31
33
|
export * from "./components/subpanel"
|
|
32
34
|
export * from "./components/breakout"
|