circuit-json 0.0.503 → 0.0.504
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 +6 -20
- package/dist/index.d.mts +417 -641
- package/dist/index.mjs +48 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2513,16 +2513,46 @@ expectTypesMatch(true);
|
|
|
2513
2513
|
|
|
2514
2514
|
// src/pcb/pcb_trace.ts
|
|
2515
2515
|
import { z as z116 } from "zod";
|
|
2516
|
+
var positive_width = distance.pipe(z116.number().finite().positive());
|
|
2516
2517
|
var pcb_trace_route_point_wire = z116.object({
|
|
2517
2518
|
route_type: z116.literal("wire"),
|
|
2518
2519
|
x: distance,
|
|
2519
2520
|
y: distance,
|
|
2520
2521
|
width: distance,
|
|
2522
|
+
start_width: positive_width.optional(),
|
|
2523
|
+
end_width: positive_width.optional(),
|
|
2524
|
+
width_interpolation_mode: z116.enum(["linear", "quadratic"]).optional(),
|
|
2521
2525
|
copper_pour_id: z116.string().optional(),
|
|
2522
2526
|
is_inside_copper_pour: z116.boolean().optional(),
|
|
2523
2527
|
start_pcb_port_id: z116.string().optional(),
|
|
2524
2528
|
end_pcb_port_id: z116.string().optional(),
|
|
2525
2529
|
layer: layer_ref
|
|
2530
|
+
}).superRefine((wire, ctx) => {
|
|
2531
|
+
const present = [
|
|
2532
|
+
wire.start_width,
|
|
2533
|
+
wire.end_width,
|
|
2534
|
+
wire.width_interpolation_mode
|
|
2535
|
+
].filter((v) => v !== void 0).length;
|
|
2536
|
+
if (present === 0) return;
|
|
2537
|
+
if (present !== 3) {
|
|
2538
|
+
ctx.addIssue({
|
|
2539
|
+
code: z116.ZodIssueCode.custom,
|
|
2540
|
+
message: "Wire taper requires start_width, end_width and width_interpolation_mode together"
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
if (wire.width !== wire.start_width) {
|
|
2544
|
+
ctx.addIssue({
|
|
2545
|
+
code: z116.ZodIssueCode.custom,
|
|
2546
|
+
path: ["start_width"],
|
|
2547
|
+
message: "start_width must equal width"
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
if (!Number.isFinite(wire.x) || !Number.isFinite(wire.y)) {
|
|
2551
|
+
ctx.addIssue({
|
|
2552
|
+
code: z116.ZodIssueCode.custom,
|
|
2553
|
+
message: "Tapered wire coordinates must be finite"
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2526
2556
|
});
|
|
2527
2557
|
var pcb_trace_route_point_via = z116.object({
|
|
2528
2558
|
route_type: z116.literal("via"),
|
|
@@ -2547,32 +2577,10 @@ var pcb_trace_route_point_through_pad = z116.object({
|
|
|
2547
2577
|
pcb_smtpad_id: z116.string().optional(),
|
|
2548
2578
|
pcb_plated_hole_id: z116.string().optional()
|
|
2549
2579
|
});
|
|
2550
|
-
var positive_width = distance.pipe(z116.number().finite().positive());
|
|
2551
|
-
var finite_route_point = point.extend({
|
|
2552
|
-
x: distance.pipe(z116.number().finite()),
|
|
2553
|
-
y: distance.pipe(z116.number().finite())
|
|
2554
|
-
});
|
|
2555
|
-
var pcb_trace_route_point_teardrop = z116.object({
|
|
2556
|
-
route_type: z116.literal("teardrop"),
|
|
2557
|
-
start: finite_route_point,
|
|
2558
|
-
end: finite_route_point,
|
|
2559
|
-
start_width: positive_width,
|
|
2560
|
-
end_width: positive_width,
|
|
2561
|
-
width_interpolation_mode: z116.enum(["linear", "quadratic"]),
|
|
2562
|
-
layer: layer_ref,
|
|
2563
|
-
copper_pour_id: z116.string().optional(),
|
|
2564
|
-
is_inside_copper_pour: z116.boolean().optional(),
|
|
2565
|
-
start_pcb_port_id: z116.string().optional(),
|
|
2566
|
-
end_pcb_port_id: z116.string().optional()
|
|
2567
|
-
}).refine(({ start, end }) => {
|
|
2568
|
-
const length4 = Math.hypot(end.x - start.x, end.y - start.y);
|
|
2569
|
-
return Number.isFinite(length4) && length4 > 0;
|
|
2570
|
-
}, "Teardrop endpoints must define a finite, nonzero-length segment");
|
|
2571
2580
|
var pcb_trace_route_point = z116.union([
|
|
2572
2581
|
pcb_trace_route_point_wire,
|
|
2573
2582
|
pcb_trace_route_point_via,
|
|
2574
|
-
pcb_trace_route_point_through_pad
|
|
2575
|
-
pcb_trace_route_point_teardrop
|
|
2583
|
+
pcb_trace_route_point_through_pad
|
|
2576
2584
|
]);
|
|
2577
2585
|
var pcb_trace = z116.object({
|
|
2578
2586
|
type: z116.literal("pcb_trace"),
|
|
@@ -2587,7 +2595,23 @@ var pcb_trace = z116.object({
|
|
|
2587
2595
|
trace_length: z116.number().optional(),
|
|
2588
2596
|
is_antenna_trace: z116.boolean().optional(),
|
|
2589
2597
|
highlight_color: z116.string().optional(),
|
|
2590
|
-
route: z116.array(pcb_trace_route_point)
|
|
2598
|
+
route: z116.array(pcb_trace_route_point).superRefine((route, ctx) => {
|
|
2599
|
+
for (const [i, wire] of route.entries()) {
|
|
2600
|
+
if (wire.route_type !== "wire" || wire.width_interpolation_mode === void 0)
|
|
2601
|
+
continue;
|
|
2602
|
+
const next = route[i + 1];
|
|
2603
|
+
const end = next?.route_type === "through_pad" ? next.start : next;
|
|
2604
|
+
const layer = next?.route_type === "wire" ? next.layer : next?.route_type === "via" ? next.from_layer : next?.start_layer;
|
|
2605
|
+
const length4 = end ? Math.hypot(end.x - wire.x, end.y - wire.y) : NaN;
|
|
2606
|
+
if (!Number.isFinite(length4) || length4 <= 0 || layer !== wire.layer) {
|
|
2607
|
+
ctx.addIssue({
|
|
2608
|
+
code: z116.ZodIssueCode.custom,
|
|
2609
|
+
path: [i],
|
|
2610
|
+
message: "Tapered wire must lead to a distinct finite next point on the same layer"
|
|
2611
|
+
});
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
})
|
|
2591
2615
|
}).describe("Defines a trace on the PCB");
|
|
2592
2616
|
expectTypesMatch(true);
|
|
2593
2617
|
expectTypesMatch(true);
|
|
@@ -5109,7 +5133,6 @@ export {
|
|
|
5109
5133
|
pcb_trace_hint,
|
|
5110
5134
|
pcb_trace_missing_error,
|
|
5111
5135
|
pcb_trace_route_point,
|
|
5112
|
-
pcb_trace_route_point_teardrop,
|
|
5113
5136
|
pcb_trace_route_point_through_pad,
|
|
5114
5137
|
pcb_trace_route_point_via,
|
|
5115
5138
|
pcb_trace_route_point_wire,
|