@tscircuit/circuit-json-util 0.0.124 → 0.0.126
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 +16 -2
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
@@ -1081,19 +1081,26 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
1081
1081
|
});
|
|
1082
1082
|
elm.x = x;
|
|
1083
1083
|
elm.y = y;
|
|
1084
|
+
if (elm.type === "pcb_smtpad" && (elm.shape === "rotated_rect" || elm.shape === "rotated_pill")) {
|
|
1085
|
+
elm.ccw_rotation = getTransformedRectRotation(elm.ccw_rotation, matrix);
|
|
1086
|
+
}
|
|
1084
1087
|
} else if (elm.type === "pcb_keepout" && elm.shape === "outline") {
|
|
1085
1088
|
elm.outline = elm.outline.map((point) => applyToPoint(matrix, point));
|
|
1086
1089
|
} else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
|
|
1087
1090
|
elm.center = applyToPoint(matrix, elm.center);
|
|
1088
1091
|
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text" || elm.type === "pcb_note_text") {
|
|
1089
1092
|
elm.anchor_position = applyToPoint(matrix, elm.anchor_position);
|
|
1093
|
+
if (elm.type === "pcb_silkscreen_text") {
|
|
1094
|
+
const textTransform = compose(matrix, rotateDEG(elm.ccw_rotation ?? 0));
|
|
1095
|
+
elm.ccw_rotation = Math.atan2(textTransform.b, textTransform.a) * 180 / Math.PI;
|
|
1096
|
+
}
|
|
1090
1097
|
} else if (elm.type === "pcb_copper_text") {
|
|
1091
1098
|
if (elm.anchor_position) {
|
|
1092
1099
|
elm.anchor_position = applyToPoint(matrix, elm.anchor_position);
|
|
1093
1100
|
}
|
|
1094
1101
|
} else if (elm.type === "pcb_courtyard_rect") {
|
|
1095
1102
|
elm.center = applyToPoint(matrix, elm.center);
|
|
1096
|
-
elm.ccw_rotation = (
|
|
1103
|
+
elm.ccw_rotation = getTransformedRectRotation(elm.ccw_rotation ?? 0, matrix);
|
|
1097
1104
|
} else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_silkscreen_pill" || elm.type === "pcb_silkscreen_oval" || elm.type === "pcb_note_rect" || elm.type === "pcb_courtyard_circle") {
|
|
1098
1105
|
elm.center = applyToPoint(matrix, elm.center);
|
|
1099
1106
|
} else if (elm.type === "pcb_component") {
|
|
@@ -2431,6 +2438,27 @@ function getElementRenderLayers(element) {
|
|
|
2431
2438
|
return [];
|
|
2432
2439
|
}
|
|
2433
2440
|
|
|
2441
|
+
// lib/is-route-via-covered-by-physical-via.ts
|
|
2442
|
+
var getLayerDepth = (layer) => {
|
|
2443
|
+
if (layer === "top") return 0;
|
|
2444
|
+
if (layer === "bottom") return Number.POSITIVE_INFINITY;
|
|
2445
|
+
const match = layer?.match(/^inner([1-9]\d*)$/);
|
|
2446
|
+
return match ? Number(match[1]) : Number.NaN;
|
|
2447
|
+
};
|
|
2448
|
+
function isRouteViaCoveredByPhysicalVia(physicalVia, routeVia) {
|
|
2449
|
+
if (physicalVia.x !== routeVia.x || physicalVia.y !== routeVia.y) return false;
|
|
2450
|
+
if (routeVia.outer_diameter !== void 0 && routeVia.outer_diameter !== physicalVia.outer_diameter || routeVia.hole_diameter !== void 0 && routeVia.hole_diameter !== physicalVia.hole_diameter) {
|
|
2451
|
+
return false;
|
|
2452
|
+
}
|
|
2453
|
+
const physicalLayers = physicalVia.layers?.map(getLayerDepth);
|
|
2454
|
+
if (!physicalLayers?.length || physicalLayers.some(Number.isNaN)) return false;
|
|
2455
|
+
const physicalTop = Math.min(...physicalLayers);
|
|
2456
|
+
const physicalBottom = Math.max(...physicalLayers);
|
|
2457
|
+
const from = getLayerDepth(routeVia.from_layer);
|
|
2458
|
+
const to = getLayerDepth(routeVia.to_layer);
|
|
2459
|
+
return physicalTop < physicalBottom && from !== to && physicalTop <= Math.min(from, to) && physicalBottom >= Math.max(from, to);
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2434
2462
|
// lib/shape-distances/geometry.ts
|
|
2435
2463
|
var EPSILON = 1e-9;
|
|
2436
2464
|
var toRadians = (degrees) => degrees * Math.PI / 180;
|
|
@@ -3209,6 +3237,7 @@ export {
|
|
|
3209
3237
|
getStringFromCircuitJsonTree,
|
|
3210
3238
|
getTraceSegmentPolygon,
|
|
3211
3239
|
getViaPolygon,
|
|
3240
|
+
isRouteViaCoveredByPhysicalVia,
|
|
3212
3241
|
oppositeDirection,
|
|
3213
3242
|
oppositeSide,
|
|
3214
3243
|
placePolygon,
|