@tscircuit/circuit-json-util 0.0.124 → 0.0.125

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as circuit_json from 'circuit-json';
2
- import { AnyCircuitElementInput, AnyCircuitElement, InsertionDirection, PcbSolderPasteRect, PcbSolderPasteRotatedRect, PcbBoard, SchematicComponent, SchematicNetLabel, SchematicTrace, SourceGroup, SourceComponentBase, PcbRenderLayer, PcbPin1Location, Point as Point$2, PcbPlatedHole, PcbCopperPour, PcbSmtPad } from 'circuit-json';
2
+ import { AnyCircuitElementInput, AnyCircuitElement, InsertionDirection, PcbSolderPasteRect, PcbSolderPasteRotatedRect, PcbBoard, SchematicComponent, SchematicNetLabel, SchematicTrace, SourceGroup, SourceComponentBase, PcbRenderLayer, PcbVia, PcbPin1Location, Point as Point$2, PcbPlatedHole, PcbCopperPour, PcbSmtPad } from 'circuit-json';
3
3
  import * as zod from 'zod';
4
4
  import { Matrix } from 'transformation-matrix';
5
5
  import * as parsel from 'parsel-js';
@@ -20088,6 +20088,20 @@ declare function getMinimumFlexContainer(children: Array<{
20088
20088
 
20089
20089
  declare function getElementRenderLayers(element: AnyCircuitElement): PcbRenderLayer[];
20090
20090
 
20091
+ type ViaGeometry = Pick<PcbVia, "x" | "y"> & Partial<Pick<PcbVia, "outer_diameter" | "hole_diameter">>;
20092
+ /**
20093
+ * Checks whether a physical via covers a route transition at the same position
20094
+ * with compatible dimensions. Callers must check electrical connectivity
20095
+ * separately. Missing route dimensions use the physical via's dimensions;
20096
+ * missing or unknown layers cannot establish coverage.
20097
+ */
20098
+ declare function isRouteViaCoveredByPhysicalVia(physicalVia: ViaGeometry & {
20099
+ layers?: readonly string[];
20100
+ }, routeVia: ViaGeometry & {
20101
+ from_layer?: string;
20102
+ to_layer?: string;
20103
+ }): boolean;
20104
+
20091
20105
  declare const computeGapBetweenCopper: (elm1: AnyCircuitElement, elm2: AnyCircuitElement) => number;
20092
20106
 
20093
20107
  declare const computeClearanceBetweenElements: (elm1: AnyCircuitElement, elm2: AnyCircuitElement) => number;
@@ -20173,4 +20187,4 @@ declare const getTraceSegmentPolygon: (start: Point$2, end: Point$2, startWidth:
20173
20187
  */
20174
20188
  declare const copperPolygonsTouch: (a: Polygon$1, b: Polygon$1, tolerance?: number) => boolean;
20175
20189
 
20176
- export { type AnyCircuitJsonId, type BoardBounds, type CircuitJsonInputUtilObjects, type CircuitJsonOps, type CircuitJsonTreeNode, type CircuitJsonUtilObjects, type CircuitJsonUtilOptions, type DrcCategory, type GetCircuitJsonUtilFn, type GetIndexedCircuitJsonUtilFn, type IndexedCircuitJsonUtilOptions, type PcbBounds, type PcbPin1LocationElement, type SchematicElementBounds, type SchematicElementWithBounds, type Size, type SubtreeOptions, analyzePcbPin1Location, applySelector, applySelectorAST, buildSubtree, categorizeErrorOrWarning, circlePolygon, cju, cjuIndexed, computeClearanceBetweenElements, computeGapBetweenCopper, copperPolygonsTouch, createBoardOwnerMap, directionToVec, distanceBetweenCircleAndCircle, distanceBetweenCircleAndPolygon, distanceBetweenPolygonAndPolygon, distanceBetweenShapes, findBoundsAndCenter, getBoardBounds, getBoundsOfPcbElements, getCircuitJsonTree, getElementById, getElementId, getElementRenderLayers, getMinimumFlexContainer, getPcbElementBounds, getPcbElementsWithinBounds, getPlatedHolePolygon, getPourPolygon, getPrimaryId, getReadableNameForElement, getReadableNameForPcbPort, getReadableNameForPcbSmtpad, getReadableNameForPcbTrace, getSchematicElementBounds, getSmtPadPolygon, getStringFromCircuitJsonTree, getTraceSegmentPolygon, getViaPolygon, oppositeDirection, oppositeSide, placePolygon, repositionPcbComponentTo, repositionPcbGroupTo, repositionSchematicComponentTo, repositionSchematicGroupTo, rotateClockwise, rotateCounterClockwise, rotateDirection, roundedRectangle, su, transformInsertionDirection, transformPCBElement, transformPCBElements, transformPCBElement as transformPcbElement, transformPCBElements as transformPcbElements, transformSchematicElement, transformSchematicElements, vecToDirection };
20190
+ export { type AnyCircuitJsonId, type BoardBounds, type CircuitJsonInputUtilObjects, type CircuitJsonOps, type CircuitJsonTreeNode, type CircuitJsonUtilObjects, type CircuitJsonUtilOptions, type DrcCategory, type GetCircuitJsonUtilFn, type GetIndexedCircuitJsonUtilFn, type IndexedCircuitJsonUtilOptions, type PcbBounds, type PcbPin1LocationElement, type SchematicElementBounds, type SchematicElementWithBounds, type Size, type SubtreeOptions, analyzePcbPin1Location, applySelector, applySelectorAST, buildSubtree, categorizeErrorOrWarning, circlePolygon, cju, cjuIndexed, computeClearanceBetweenElements, computeGapBetweenCopper, copperPolygonsTouch, createBoardOwnerMap, directionToVec, distanceBetweenCircleAndCircle, distanceBetweenCircleAndPolygon, distanceBetweenPolygonAndPolygon, distanceBetweenShapes, findBoundsAndCenter, getBoardBounds, getBoundsOfPcbElements, getCircuitJsonTree, getElementById, getElementId, getElementRenderLayers, getMinimumFlexContainer, getPcbElementBounds, getPcbElementsWithinBounds, getPlatedHolePolygon, getPourPolygon, getPrimaryId, getReadableNameForElement, getReadableNameForPcbPort, getReadableNameForPcbSmtpad, getReadableNameForPcbTrace, getSchematicElementBounds, getSmtPadPolygon, getStringFromCircuitJsonTree, getTraceSegmentPolygon, getViaPolygon, isRouteViaCoveredByPhysicalVia, oppositeDirection, oppositeSide, placePolygon, repositionPcbComponentTo, repositionPcbGroupTo, repositionSchematicComponentTo, repositionSchematicGroupTo, rotateClockwise, rotateCounterClockwise, rotateDirection, roundedRectangle, su, transformInsertionDirection, transformPCBElement, transformPCBElements, transformPCBElement as transformPcbElement, transformPCBElements as transformPcbElements, transformSchematicElement, transformSchematicElements, vecToDirection };
package/dist/index.js CHANGED
@@ -2431,6 +2431,27 @@ function getElementRenderLayers(element) {
2431
2431
  return [];
2432
2432
  }
2433
2433
 
2434
+ // lib/is-route-via-covered-by-physical-via.ts
2435
+ var getLayerDepth = (layer) => {
2436
+ if (layer === "top") return 0;
2437
+ if (layer === "bottom") return Number.POSITIVE_INFINITY;
2438
+ const match = layer?.match(/^inner([1-9]\d*)$/);
2439
+ return match ? Number(match[1]) : Number.NaN;
2440
+ };
2441
+ function isRouteViaCoveredByPhysicalVia(physicalVia, routeVia) {
2442
+ if (physicalVia.x !== routeVia.x || physicalVia.y !== routeVia.y) return false;
2443
+ if (routeVia.outer_diameter !== void 0 && routeVia.outer_diameter !== physicalVia.outer_diameter || routeVia.hole_diameter !== void 0 && routeVia.hole_diameter !== physicalVia.hole_diameter) {
2444
+ return false;
2445
+ }
2446
+ const physicalLayers = physicalVia.layers?.map(getLayerDepth);
2447
+ if (!physicalLayers?.length || physicalLayers.some(Number.isNaN)) return false;
2448
+ const physicalTop = Math.min(...physicalLayers);
2449
+ const physicalBottom = Math.max(...physicalLayers);
2450
+ const from = getLayerDepth(routeVia.from_layer);
2451
+ const to = getLayerDepth(routeVia.to_layer);
2452
+ return physicalTop < physicalBottom && from !== to && physicalTop <= Math.min(from, to) && physicalBottom >= Math.max(from, to);
2453
+ }
2454
+
2434
2455
  // lib/shape-distances/geometry.ts
2435
2456
  var EPSILON = 1e-9;
2436
2457
  var toRadians = (degrees) => degrees * Math.PI / 180;
@@ -3209,6 +3230,7 @@ export {
3209
3230
  getStringFromCircuitJsonTree,
3210
3231
  getTraceSegmentPolygon,
3211
3232
  getViaPolygon,
3233
+ isRouteViaCoveredByPhysicalVia,
3212
3234
  oppositeDirection,
3213
3235
  oppositeSide,
3214
3236
  placePolygon,