@tscircuit/core 0.0.2148 → 0.0.2149

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.
Files changed (2) hide show
  1. package/dist/index.js +68 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6553,6 +6553,66 @@ var getRouteForPcbPath = ({
6553
6553
  return route;
6554
6554
  };
6555
6555
 
6556
+ // lib/components/primitive-components/Trace/insert-pcb-path-via-policy-errors.ts
6557
+ var insertPcbPathViaPolicyErrors = ({
6558
+ trace,
6559
+ pcbTrace,
6560
+ path,
6561
+ ports,
6562
+ pathIndex
6563
+ }) => {
6564
+ const allowBlindAndBuriedVias = trace._getBoard()?.getInheritedProperty("allowBlindAndBuriedVias");
6565
+ if (allowBlindAndBuriedVias) {
6566
+ return;
6567
+ }
6568
+ const { db: db2 } = trace.root;
6569
+ const connection = db2.source_trace.get(trace.source_trace_id)?.display_name;
6570
+ const traceDescription = [trace._parsedProps.name ? trace.getDisplayName() : void 0, connection].filter(Boolean).join(", ") || "unnamed trace";
6571
+ const pathName = pathIndex === void 0 ? "pcbPath" : `pcbPaths[${pathIndex}]`;
6572
+ const viaPathEntryIndices = [];
6573
+ for (const [pathEntryIndex, point6] of path.entries()) {
6574
+ if (typeof point6 !== "string" && point6.via) {
6575
+ viaPathEntryIndices.push(pathEntryIndex);
6576
+ }
6577
+ }
6578
+ const pcbVias = db2.pcb_via.list({ pcb_trace_id: pcbTrace.pcb_trace_id });
6579
+ const viaDescriptions = [];
6580
+ const viaKinds = /* @__PURE__ */ new Set();
6581
+ let firstDisallowedVia;
6582
+ for (const [viaIndex, via] of pcbVias.entries()) {
6583
+ const reachesTop = via.layers.includes("top");
6584
+ const reachesBottom = via.layers.includes("bottom");
6585
+ if (reachesTop && reachesBottom) {
6586
+ continue;
6587
+ }
6588
+ const viaKind = reachesTop || reachesBottom ? "blind" : "buried";
6589
+ viaKinds.add(viaKind);
6590
+ const pathEntryIndex = viaPathEntryIndices[viaIndex];
6591
+ const pathEntry = `${pathName}[${pathEntryIndex}]`;
6592
+ const boardX = Number(via.x.toFixed(4));
6593
+ const boardY = Number(via.y.toFixed(4));
6594
+ firstDisallowedVia ??= via;
6595
+ viaDescriptions.push(
6596
+ `${pathEntry}: ${viaKind} via (fromLayer: "${via.from_layer}", toLayer: "${via.to_layer}") spanning [${via.layers.join(", ")}] at board (${boardX}, ${boardY}) mm`
6597
+ );
6598
+ }
6599
+ if (!firstDisallowedVia) {
6600
+ return;
6601
+ }
6602
+ const viaKindDescription = [...viaKinds].sort().join(" and ");
6603
+ db2.pcb_trace_error.insert({
6604
+ error_type: "pcb_trace_error",
6605
+ source_trace_id: trace.source_trace_id,
6606
+ pcb_trace_id: pcbTrace.pcb_trace_id,
6607
+ pcb_component_ids: [],
6608
+ pcb_port_ids: ports.map((port) => port.pcb_port_id).filter(Boolean),
6609
+ subcircuit_id: pcbTrace.subcircuit_id,
6610
+ center: { x: firstDisallowedVia.x, y: firstDisallowedVia.y },
6611
+ is_fatal: false,
6612
+ message: `${viaKindDescription} vias aren't allowed by allowBlindAndBuriedVias settings in ${pathName} (${traceDescription}): ${viaDescriptions.length} disallowed via${viaDescriptions.length === 1 ? "" : "s"}. Use top-to-bottom through vias (fromLayer: "top", toLayer: "bottom", or the reverse) and adjust the adjoining wire layers to match, or set allowBlindAndBuriedVias={true} on <board> if fabrication supports blind/buried vias. Saved copper has been preserved. Affected indices (zero-based): ${viaDescriptions.join("; ")}.`
6613
+ });
6614
+ };
6615
+
6556
6616
  // lib/components/primitive-components/Trace/render-pcb-paths.ts
6557
6617
  var renderPcbPaths = ({
6558
6618
  trace,
@@ -6617,6 +6677,7 @@ var renderPcbPaths = ({
6617
6677
  }
6618
6678
  insertPcbPathViaContactErrors({ trace, pcbTrace, ports, pathIndex });
6619
6679
  trace._insertErrorIfTraceIsOutsideBoard(route, ports);
6680
+ insertPcbPathViaPolicyErrors({ trace, pcbTrace, path, ports, pathIndex });
6620
6681
  }
6621
6682
  trace._portsRoutedOnPcb = ports;
6622
6683
  };
@@ -7007,6 +7068,12 @@ function Trace_doInitialPcbManualTraceRender(trace) {
7007
7068
  });
7008
7069
  }
7009
7070
  }
7071
+ insertPcbPathViaPolicyErrors({
7072
+ trace,
7073
+ pcbTrace: pcb_trace,
7074
+ path: props.pcbPath,
7075
+ ports
7076
+ });
7010
7077
  trace._portsRoutedOnPcb = ports;
7011
7078
  trace.pcb_trace_id = pcb_trace.pcb_trace_id;
7012
7079
  insertPcbPathViaContactErrors({ trace, pcbTrace: pcb_trace, ports });
@@ -118721,7 +118788,7 @@ var RoutingPhasePreparationError = class extends Error {
118721
118788
  var package_default = {
118722
118789
  name: "@tscircuit/core",
118723
118790
  type: "module",
118724
- version: "0.0.2147",
118791
+ version: "0.0.2148",
118725
118792
  types: "dist/index.d.ts",
118726
118793
  main: "dist/index.js",
118727
118794
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.2148",
4
+ "version": "0.0.2149",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",