-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
121 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,33 @@ | ||
import { z } from "zod" | ||
import { distance, type Length, getZodPrefixedIdWithDefault } from "src/units" | ||
import { expectTypesMatch } from "src/utils/expect-types-match" | ||
import { distance } from "../units" | ||
|
||
export const pcb_hole = z | ||
.union([ | ||
z | ||
.object({ | ||
type: z.literal("pcb_hole"), | ||
pcb_hole_id: getZodPrefixedIdWithDefault("pcb_hole"), | ||
hole_shape: z | ||
.enum(["circle", "square", "round"]) | ||
.default("circle") | ||
.transform((shape) => { | ||
if (shape === "round") return "circle" | ||
return shape as "circle" | "square" | ||
}), | ||
hole_diameter: z.number(), | ||
x: distance, | ||
y: distance, | ||
}) | ||
.describe("Defines a circular or square hole on the PCB"), | ||
z | ||
.object({ | ||
type: z.literal("pcb_hole"), | ||
pcb_hole_id: getZodPrefixedIdWithDefault("pcb_hole"), | ||
hole_shape: z.literal("oval"), | ||
hole_width: z.number(), | ||
hole_height: z.number(), | ||
x: distance, | ||
y: distance, | ||
}) | ||
.describe("Defines an oval hole on the PCB"), | ||
]) | ||
.object({ | ||
pcb_hole_id: z.string(), | ||
type: z.literal("pcb_hole"), | ||
hole_shape: z | ||
.enum(["circle", "square", "round"]) | ||
.default("circle") | ||
.transform((shape) => { | ||
if (shape === "round") return "circle" | ||
return shape as "circle" | "square" | ||
}), | ||
hole_diameter: z.number(), | ||
x: distance, | ||
y: distance, | ||
}) | ||
.or( | ||
z.object({ | ||
pcb_hole_id: z.string(), | ||
type: z.literal("pcb_hole"), | ||
hole_shape: z.literal("oval"), | ||
hole_width: z.number(), | ||
hole_height: z.number(), | ||
x: distance, | ||
y: distance, | ||
}), | ||
) | ||
.describe("Defines a hole on the PCB") | ||
|
||
export type PcbHoleInput = z.input<typeof pcb_hole> | ||
type InferredPcbHole = z.infer<typeof pcb_hole> | ||
|
||
/** | ||
* Defines a hole on the PCB | ||
*/ | ||
export interface PcbHole { | ||
type: "pcb_hole" | ||
pcb_hole_id: string | ||
hole_shape: "circle" | "square" | "oval" | ||
x: Length | ||
y: Length | ||
} | ||
|
||
interface PcbCircularOrSquareHole extends PcbHole { | ||
hole_shape: "circle" | "square" | ||
hole_diameter: number | ||
} | ||
|
||
interface PcbOvalHole extends PcbHole { | ||
hole_shape: "oval" | ||
hole_width: number | ||
hole_height: number | ||
} | ||
|
||
export type PcbHole = PcbCircularOrSquareHole | PcbOvalHole | ||
|
||
/** | ||
* @deprecated use PcbHole | ||
*/ | ||
export type PCBHole = PcbHole | ||
|
||
expectTypesMatch<PcbHole, InferredPcbHole>(true) | ||
export type PCBHoleInput = z.input<typeof pcb_hole> | ||
export type PCBHole = z.infer<typeof pcb_hole> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,29 @@ | ||
import { z } from "zod" | ||
import { point, type Point, getZodPrefixedIdWithDefault } from "src/common" | ||
import { distance, type Distance } from "src/units" | ||
import { expectTypesMatch } from "src/utils/expect-types-match" | ||
import { point } from "../common" | ||
import { distance } from "../units" | ||
|
||
export const pcb_keepout = z.union([ | ||
z.object({ | ||
export const pcb_keepout = z | ||
.object({ | ||
type: z.literal("pcb_keepout"), | ||
shape: z.literal("rect"), | ||
pcb_keepout_id: getZodPrefixedIdWithDefault("pcb_keepout"), | ||
center: point, | ||
width: distance, | ||
height: distance, | ||
pcb_keepout_id: z.string(), | ||
layers: z.array(z.string()), // Specify layers where the keepout applies | ||
description: z.string().optional(), // Optional description of the keepout | ||
}), | ||
z.object({ | ||
type: z.literal("pcb_keepout"), | ||
shape: z.literal("circle"), | ||
pcb_keepout_id: getZodPrefixedIdWithDefault("pcb_keepout"), | ||
center: point, | ||
radius: distance, | ||
layers: z.array(z.string()), // Specify layers where the keepout applies | ||
description: z.string().optional(), // Optional description of the keepout | ||
}), | ||
]) | ||
|
||
export type PcbKeepoutInput = z.input<typeof pcb_keepout> | ||
type InferredPcbKeepout = z.infer<typeof pcb_keepout> | ||
|
||
/** | ||
* Defines a keepout area on the PCB, which can be either a rectangle or a circle. | ||
* The keepout area is specified for one or more layers, and an optional description can be provided. | ||
*/ | ||
export interface PcbKeepout { | ||
type: "pcb_keepout" | ||
pcb_keepout_id: string | ||
center: Point | ||
layers: string[] | ||
description?: string | ||
} | ||
|
||
// Rectangular Keepout | ||
export interface PcbKeepoutRect extends PcbKeepout { | ||
shape: "rect" | ||
width: Distance | ||
height: Distance | ||
} | ||
|
||
// Circular Keepout | ||
export interface PcbKeepoutCircle extends PcbKeepout { | ||
shape: "circle" | ||
radius: Distance | ||
} | ||
|
||
/** | ||
* @deprecated use PcbKeepout | ||
*/ | ||
export type PCBKeepout = PcbKeepout | ||
}) | ||
.or( | ||
z.object({ | ||
type: z.literal("pcb_keepout"), | ||
shape: z.literal("circle"), | ||
center: point, | ||
radius: distance, | ||
pcb_keepout_id: z.string(), | ||
layers: z.array(z.string()), // Specify layers where the keepout applies | ||
description: z.string().optional(), // Optional description of the keepout | ||
}), | ||
) | ||
|
||
expectTypesMatch<PcbKeepout, InferredPcbKeepout>(true) | ||
export type PCBKeepoutInput = z.input<typeof pcb_keepout> | ||
export type PCBKeepout = z.infer<typeof pcb_keepout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.