From 9a10e3267b7f53602dd81545eb810ffd6b5cf56f Mon Sep 17 00:00:00 2001 From: seveibar Date: Tue, 28 Jul 2026 11:19:32 -0700 Subject: [PATCH 1/2] add footprinter string cad model option --- generated/COMPONENT_TYPES.md | 1 + lib/common/cadModel.ts | 11 +++++++++++ tests/cad-model-prop.test.ts | 15 +++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/cad-model-prop.test.ts diff --git a/generated/COMPONENT_TYPES.md b/generated/COMPONENT_TYPES.md index a792aa4b..ef3c618d 100644 --- a/generated/COMPONENT_TYPES.md +++ b/generated/COMPONENT_TYPES.md @@ -98,6 +98,7 @@ export const cadModelJscad = cadModelBase.extend({ }) export const cadModelProp = z.union([ z.null(), + z.literal("footprinter_string"), url, z.custom((v) => { return v && typeof v === "object" && "type" in v && "props" in v diff --git a/lib/common/cadModel.ts b/lib/common/cadModel.ts index 2a3e7207..2e1fe796 100644 --- a/lib/common/cadModel.ts +++ b/lib/common/cadModel.ts @@ -113,10 +113,20 @@ export const cadModelJscad = cadModelBase.extend({ jscad: z.record(z.any()), }) +/** + * Generate the CAD representation from the component's resolved Footprinter + * footprint instead of using a supplied or fetched CAD model. + * + * The component footprint must resolve to a Footprinter string. This explicit + * value overrides CAD models returned by footprint libraries or parts engines. + */ +export type CadModelFootprinterString = "footprinter_string" + export type CadModelProp = | null | string | ReactElement + | CadModelFootprinterString | CadModelStl | CadModelObj | CadModelGltf @@ -127,6 +137,7 @@ export type CadModelProp = export const cadModelProp = z.union([ z.null(), + z.literal("footprinter_string"), url, z.custom((v) => { return v && typeof v === "object" && "type" in v && "props" in v diff --git a/tests/cad-model-prop.test.ts b/tests/cad-model-prop.test.ts new file mode 100644 index 00000000..61e46a9a --- /dev/null +++ b/tests/cad-model-prop.test.ts @@ -0,0 +1,15 @@ +import { expect, test } from "bun:test" +import { cadModelProp } from "../lib/common/cadModel" +import { chipProps } from "../lib/components/chip" + +test("cadModel accepts the footprinter_string procedural model", () => { + expect(cadModelProp.parse("footprinter_string")).toBe("footprinter_string") + + const parsedChip = chipProps.parse({ + name: "U1", + footprint: "soic8", + cadModel: "footprinter_string", + }) + + expect(parsedChip.cadModel).toBe("footprinter_string") +}) From 1dd8102f32e8432e760a10dcfcf32602adf4452c Mon Sep 17 00:00:00 2001 From: seveibar Date: Tue, 28 Jul 2026 11:40:19 -0700 Subject: [PATCH 2/2] treat cad model strings as footprinter models --- generated/COMPONENT_TYPES.md | 3 +-- lib/common/cadModel.ts | 13 +++++-------- tests/cad-model-prop.test.ts | 10 +++++----- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/generated/COMPONENT_TYPES.md b/generated/COMPONENT_TYPES.md index ef3c618d..73473428 100644 --- a/generated/COMPONENT_TYPES.md +++ b/generated/COMPONENT_TYPES.md @@ -98,8 +98,7 @@ export const cadModelJscad = cadModelBase.extend({ }) export const cadModelProp = z.union([ z.null(), - z.literal("footprinter_string"), - url, + z.string().min(1), z.custom((v) => { return v && typeof v === "object" && "type" in v && "props" in v }), diff --git a/lib/common/cadModel.ts b/lib/common/cadModel.ts index 2e1fe796..6bedd841 100644 --- a/lib/common/cadModel.ts +++ b/lib/common/cadModel.ts @@ -114,17 +114,15 @@ export const cadModelJscad = cadModelBase.extend({ }) /** - * Generate the CAD representation from the component's resolved Footprinter - * footprint instead of using a supplied or fetched CAD model. + * A Footprinter string used to procedurally generate the component's CAD model, + * independently of the component's PCB footprint. * - * The component footprint must resolve to a Footprinter string. This explicit - * value overrides CAD models returned by footprint libraries or parts engines. + * @example "soic8" */ -export type CadModelFootprinterString = "footprinter_string" +export type CadModelFootprinterString = string export type CadModelProp = | null - | string | ReactElement | CadModelFootprinterString | CadModelStl @@ -137,8 +135,7 @@ export type CadModelProp = export const cadModelProp = z.union([ z.null(), - z.literal("footprinter_string"), - url, + z.string().min(1), z.custom((v) => { return v && typeof v === "object" && "type" in v && "props" in v }), diff --git a/tests/cad-model-prop.test.ts b/tests/cad-model-prop.test.ts index 61e46a9a..d32f3fe9 100644 --- a/tests/cad-model-prop.test.ts +++ b/tests/cad-model-prop.test.ts @@ -2,14 +2,14 @@ import { expect, test } from "bun:test" import { cadModelProp } from "../lib/common/cadModel" import { chipProps } from "../lib/components/chip" -test("cadModel accepts the footprinter_string procedural model", () => { - expect(cadModelProp.parse("footprinter_string")).toBe("footprinter_string") +test("cadModel accepts a Footprinter string as the procedural model", () => { + expect(cadModelProp.parse("soic8")).toBe("soic8") + expect(() => cadModelProp.parse("")).toThrow() const parsedChip = chipProps.parse({ name: "U1", - footprint: "soic8", - cadModel: "footprinter_string", + cadModel: "soic8", }) - expect(parsedChip.cadModel).toBe("footprinter_string") + expect(parsedChip.cadModel).toBe("soic8") })