@tscircuit/circuit-json-util 0.0.115 → 0.0.116
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 +4 -1
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -19309,6 +19309,9 @@ interface BoardBounds {
|
|
|
19309
19309
|
}
|
|
19310
19310
|
declare const getBoardBounds: (board: PcbBoard) => BoardBounds;
|
|
19311
19311
|
|
|
19312
|
+
type AnyCircuitJsonId = string;
|
|
19313
|
+
declare function createBoardOwnerMap(circuitJson: AnyCircuitElement[]): Map<AnyCircuitJsonId, PcbBoard | undefined>;
|
|
19314
|
+
|
|
19312
19315
|
type SchematicElementWithBounds = SchematicComponent | SchematicNetLabel | SchematicTrace;
|
|
19313
19316
|
interface SchematicElementBounds {
|
|
19314
19317
|
minX: number;
|
|
@@ -19496,4 +19499,4 @@ declare const getTraceSegmentPolygon: (start: Point$2, end: Point$2, startWidth:
|
|
|
19496
19499
|
*/
|
|
19497
19500
|
declare const copperPolygonsTouch: (a: Polygon$1, b: Polygon$1, tolerance?: number) => boolean;
|
|
19498
19501
|
|
|
19499
|
-
export { 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, 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 };
|
|
19502
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -1596,6 +1596,88 @@ var getBoardBounds = (board) => {
|
|
|
1596
1596
|
};
|
|
1597
1597
|
};
|
|
1598
1598
|
|
|
1599
|
+
// lib/create-board-owner-map.ts
|
|
1600
|
+
function createBoardOwnerMap(circuitJson) {
|
|
1601
|
+
const boardOwnerMap = /* @__PURE__ */ new Map();
|
|
1602
|
+
const parentById = /* @__PURE__ */ new Map();
|
|
1603
|
+
const boardsById = /* @__PURE__ */ new Map();
|
|
1604
|
+
for (const element of circuitJson) {
|
|
1605
|
+
switch (element.type) {
|
|
1606
|
+
case "pcb_board":
|
|
1607
|
+
boardsById.set(element.pcb_board_id, element);
|
|
1608
|
+
break;
|
|
1609
|
+
case "source_group": {
|
|
1610
|
+
const parentGroupId = element.parent_subcircuit_id ?? element.parent_source_group_id;
|
|
1611
|
+
parentById.set(
|
|
1612
|
+
element.source_group_id,
|
|
1613
|
+
element.subcircuit_id ?? parentGroupId
|
|
1614
|
+
);
|
|
1615
|
+
if (element.is_subcircuit && element.subcircuit_id) {
|
|
1616
|
+
parentById.set(element.subcircuit_id, parentGroupId);
|
|
1617
|
+
}
|
|
1618
|
+
break;
|
|
1619
|
+
}
|
|
1620
|
+
case "pcb_group":
|
|
1621
|
+
parentById.set(
|
|
1622
|
+
element.pcb_group_id,
|
|
1623
|
+
element.subcircuit_id ?? element.source_group_id
|
|
1624
|
+
);
|
|
1625
|
+
break;
|
|
1626
|
+
case "pcb_component":
|
|
1627
|
+
parentById.set(
|
|
1628
|
+
element.pcb_component_id,
|
|
1629
|
+
element.subcircuit_id ?? element.pcb_group_id
|
|
1630
|
+
);
|
|
1631
|
+
break;
|
|
1632
|
+
case "pcb_trace":
|
|
1633
|
+
parentById.set(
|
|
1634
|
+
element.pcb_trace_id,
|
|
1635
|
+
element.subcircuit_id ?? element.pcb_group_id ?? element.pcb_component_id
|
|
1636
|
+
);
|
|
1637
|
+
break;
|
|
1638
|
+
case "pcb_via":
|
|
1639
|
+
parentById.set(
|
|
1640
|
+
element.pcb_via_id,
|
|
1641
|
+
element.subcircuit_id ?? element.pcb_group_id ?? element.pcb_trace_id
|
|
1642
|
+
);
|
|
1643
|
+
break;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
const boards = [...boardsById.values()];
|
|
1647
|
+
for (const board of boards) {
|
|
1648
|
+
boardOwnerMap.set(board.pcb_board_id, board);
|
|
1649
|
+
if (board.subcircuit_id) {
|
|
1650
|
+
boardOwnerMap.set(board.subcircuit_id, board);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
const singleBoard = boards.length === 1 ? boards[0] : void 0;
|
|
1654
|
+
const resolvingIds = /* @__PURE__ */ new Set();
|
|
1655
|
+
function resolveBoard(id) {
|
|
1656
|
+
if (boardOwnerMap.has(id)) {
|
|
1657
|
+
return boardOwnerMap.get(id);
|
|
1658
|
+
}
|
|
1659
|
+
if (!parentById.has(id)) {
|
|
1660
|
+
return void 0;
|
|
1661
|
+
}
|
|
1662
|
+
if (resolvingIds.has(id)) {
|
|
1663
|
+
return void 0;
|
|
1664
|
+
}
|
|
1665
|
+
resolvingIds.add(id);
|
|
1666
|
+
const parentId = parentById.get(id);
|
|
1667
|
+
let board = singleBoard;
|
|
1668
|
+
if (parentId) {
|
|
1669
|
+
board = resolveBoard(parentId);
|
|
1670
|
+
}
|
|
1671
|
+
resolvingIds.delete(id);
|
|
1672
|
+
boardOwnerMap.set(id, board);
|
|
1673
|
+
return board;
|
|
1674
|
+
}
|
|
1675
|
+
for (const id of parentById.keys()) {
|
|
1676
|
+
resolveBoard(id);
|
|
1677
|
+
}
|
|
1678
|
+
return boardOwnerMap;
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1599
1681
|
// lib/get-schematic-element-bounds.ts
|
|
1600
1682
|
var SCHEMATIC_TRACE_WIDTH = 0.1;
|
|
1601
1683
|
var SCHEMATIC_NET_LABEL_FONT_SIZE = 0.18;
|
|
@@ -2996,6 +3078,7 @@ export {
|
|
|
2996
3078
|
computeClearanceBetweenElements,
|
|
2997
3079
|
computeGapBetweenCopper,
|
|
2998
3080
|
copperPolygonsTouch,
|
|
3081
|
+
createBoardOwnerMap,
|
|
2999
3082
|
directionToVec,
|
|
3000
3083
|
distanceBetweenCircleAndCircle,
|
|
3001
3084
|
distanceBetweenCircleAndPolygon,
|