From b918c0f28505437f9931dcf2482f70f7725ead87 Mon Sep 17 00:00:00 2001 From: Severin Ibarluzea Date: Thu, 27 Nov 2025 09:19:22 -0800 Subject: [PATCH] Add support for 6 and 8 layer boards --- README.md | 2 +- generated/COMPONENT_TYPES.md | 13 +++++++++++-- generated/PROPS_OVERVIEW.md | 6 +++++- lib/components/board.ts | 12 ++++++++++-- tests/board.test.ts | 8 ++++++++ 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b620326..5fa5f41 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ export interface BoardProps title?: string; material?: "fr4" | "fr1"; /** Number of layers for the PCB */ - layers?: 1 | 2 | 4; + layers?: 1 | 2 | 4 | 6 | 8; borderRadius?: Distance; thickness?: Distance; boardAnchorPosition?: Point; diff --git a/generated/COMPONENT_TYPES.md b/generated/COMPONENT_TYPES.md index c07590c..76d472e 100644 --- a/generated/COMPONENT_TYPES.md +++ b/generated/COMPONENT_TYPES.md @@ -292,6 +292,7 @@ export interface CommonComponentProps symbolName?: string doNotPlace?: boolean obstructsWithinBounds?: boolean + showAsTranslucentModel?: boolean } .extend({ key: z.any().optional(), @@ -306,6 +307,12 @@ export interface CommonComponentProps .describe( "Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath", ), + showAsTranslucentModel: z + .boolean() + .optional() + .describe( + "Whether to show this component's CAD model as translucent in the 3D viewer.", + ), pinAttributes: z.record(z.string(), pinAttributeMap).optional(), }) export const lrPolarPins = [ @@ -514,7 +521,7 @@ export interface BoardProps extends Omit { title?: string material?: "fr4" | "fr1" - layers?: 1 | 2 | 4 + layers?: 1 | 2 | 4 | 6 | 8 borderRadius?: Distance thickness?: Distance boardAnchorPosition?: Point @@ -533,7 +540,9 @@ export const boardProps = subcircuitGroupProps .omit({ connections: true }) .extend({ material: z.enum(["fr4", "fr1"]).default("fr4"), - layers: z.union([z.literal(1), z.literal(2), z.literal(4)]).default(2), + layers: z + .union([z.literal(1), z.literal(2), z.literal(4), z.literal(6), z.literal(8)]) + .default(2), borderRadius: distance.optional(), thickness: distance.optional(), boardAnchorPosition: point.optional(), diff --git a/generated/PROPS_OVERVIEW.md b/generated/PROPS_OVERVIEW.md index 6d26d22..74b4605 100644 --- a/generated/PROPS_OVERVIEW.md +++ b/generated/PROPS_OVERVIEW.md @@ -214,7 +214,7 @@ export interface BoardProps title?: string material?: "fr4" | "fr1" /** Number of layers for the PCB */ - layers?: 1 | 2 | 4 + layers?: 1 | 2 | 4 | 6 | 8 borderRadius?: Distance thickness?: Distance boardAnchorPosition?: Point @@ -468,6 +468,10 @@ export interface CommonComponentProps * chips can be placed between the pin headers) or for tall modules where chips fit underneath. */ obstructsWithinBounds?: boolean + /** + * Whether to show this component's CAD model as translucent in the 3D viewer. + */ + showAsTranslucentModel?: boolean } diff --git a/lib/components/board.ts b/lib/components/board.ts index da35fb3..706bc31 100644 --- a/lib/components/board.ts +++ b/lib/components/board.ts @@ -28,7 +28,7 @@ export interface BoardProps title?: string material?: "fr4" | "fr1" /** Number of layers for the PCB */ - layers?: 1 | 2 | 4 + layers?: 1 | 2 | 4 | 6 | 8 borderRadius?: Distance thickness?: Distance boardAnchorPosition?: Point @@ -55,7 +55,15 @@ export const boardProps = subcircuitGroupProps .omit({ connections: true }) .extend({ material: z.enum(["fr4", "fr1"]).default("fr4"), - layers: z.union([z.literal(1), z.literal(2), z.literal(4)]).default(2), + layers: z + .union([ + z.literal(1), + z.literal(2), + z.literal(4), + z.literal(6), + z.literal(8), + ]) + .default(2), borderRadius: distance.optional(), thickness: distance.optional(), boardAnchorPosition: point.optional(), diff --git a/tests/board.test.ts b/tests/board.test.ts index 5ed77f2..aa9edc6 100644 --- a/tests/board.test.ts +++ b/tests/board.test.ts @@ -28,6 +28,14 @@ test("should allow single-layer boards", () => { expect(parsed.layers).toBe(1) }) +test("should allow 6 and 8 layer boards", () => { + const sixLayer: BoardProps = { name: "board", layers: 6 } + const eightLayer: BoardProps = { name: "board", layers: 8 } + + expect(boardProps.parse(sixLayer).layers).toBe(6) + expect(boardProps.parse(eightLayer).layers).toBe(8) +}) + test("should parse borderRadius prop", () => { const raw: BoardProps = { name: "board", borderRadius: 2 } const parsed = boardProps.parse(raw)