@tscircuit/core 0.0.925 → 0.0.926
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.js +51 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15758,14 +15758,8 @@ var Board = class extends Group6 {
|
|
|
15758
15758
|
const maxX = Math.max(...xValues);
|
|
15759
15759
|
const minY = Math.min(...yValues);
|
|
15760
15760
|
const maxY = Math.max(...yValues);
|
|
15761
|
-
const outlineCenterX = (minX + maxX) / 2;
|
|
15762
|
-
const outlineCenterY = (minY + maxY) / 2;
|
|
15763
15761
|
computedWidth = maxX - minX;
|
|
15764
15762
|
computedHeight = maxY - minY;
|
|
15765
|
-
center = {
|
|
15766
|
-
x: outlineCenterX + (props.outlineOffsetX ?? 0),
|
|
15767
|
-
y: outlineCenterY + (props.outlineOffsetY ?? 0)
|
|
15768
|
-
};
|
|
15769
15763
|
}
|
|
15770
15764
|
let outline = props.outline;
|
|
15771
15765
|
if (!outline && props.borderRadius != null && computedWidth > 0 && computedHeight > 0) {
|
|
@@ -15853,20 +15847,57 @@ var Board = class extends Group6 {
|
|
|
15853
15847
|
}
|
|
15854
15848
|
}
|
|
15855
15849
|
_repositionOnPcb(position) {
|
|
15856
|
-
|
|
15850
|
+
const { db } = this.root;
|
|
15851
|
+
const pcbBoard = this.pcb_board_id ? db.pcb_board.get(this.pcb_board_id) : null;
|
|
15852
|
+
const oldPos = pcbBoard?.center;
|
|
15853
|
+
if (!oldPos) {
|
|
15854
|
+
if (this.pcb_board_id) {
|
|
15855
|
+
db.pcb_board.update(this.pcb_board_id, { center: position });
|
|
15856
|
+
}
|
|
15857
|
+
return;
|
|
15858
|
+
}
|
|
15859
|
+
const deltaX = position.x - oldPos.x;
|
|
15860
|
+
const deltaY = position.y - oldPos.y;
|
|
15861
|
+
if (Math.abs(deltaX) < 1e-6 && Math.abs(deltaY) < 1e-6) {
|
|
15862
|
+
return;
|
|
15863
|
+
}
|
|
15864
|
+
for (const child of this.children) {
|
|
15865
|
+
if (child instanceof NormalComponent3) {
|
|
15866
|
+
let childOldCenter;
|
|
15867
|
+
if (child.pcb_component_id) {
|
|
15868
|
+
const comp = db.pcb_component.get(child.pcb_component_id);
|
|
15869
|
+
if (comp) childOldCenter = comp.center;
|
|
15870
|
+
} else if (child instanceof Group6 && child.pcb_group_id) {
|
|
15871
|
+
const group = db.pcb_group.get(child.pcb_group_id);
|
|
15872
|
+
if (group) childOldCenter = group.center;
|
|
15873
|
+
}
|
|
15874
|
+
if (childOldCenter) {
|
|
15875
|
+
child._repositionOnPcb({
|
|
15876
|
+
x: childOldCenter.x + deltaX,
|
|
15877
|
+
y: childOldCenter.y + deltaY
|
|
15878
|
+
});
|
|
15879
|
+
}
|
|
15880
|
+
}
|
|
15881
|
+
}
|
|
15857
15882
|
if (this.pcb_board_id) {
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
|
|
15862
|
-
|
|
15863
|
-
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
outline
|
|
15869
|
-
|
|
15883
|
+
db.pcb_board.update(this.pcb_board_id, { center: position });
|
|
15884
|
+
if (pcbBoard?.outline) {
|
|
15885
|
+
const outlineBounds = getBoundsFromPoints4(pcbBoard.outline);
|
|
15886
|
+
if (outlineBounds) {
|
|
15887
|
+
const oldOutlineCenter = {
|
|
15888
|
+
x: (outlineBounds.minX + outlineBounds.maxX) / 2,
|
|
15889
|
+
y: (outlineBounds.minY + outlineBounds.maxY) / 2
|
|
15890
|
+
};
|
|
15891
|
+
const outlineDeltaX = position.x - oldOutlineCenter.x;
|
|
15892
|
+
const outlineDeltaY = position.y - oldOutlineCenter.y;
|
|
15893
|
+
const newOutline = pcbBoard.outline.map((p) => ({
|
|
15894
|
+
x: p.x + outlineDeltaX,
|
|
15895
|
+
y: p.y + outlineDeltaY
|
|
15896
|
+
}));
|
|
15897
|
+
db.pcb_board.update(this.pcb_board_id, {
|
|
15898
|
+
outline: newOutline
|
|
15899
|
+
});
|
|
15900
|
+
}
|
|
15870
15901
|
}
|
|
15871
15902
|
}
|
|
15872
15903
|
}
|
|
@@ -19465,7 +19496,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
19465
19496
|
var package_default = {
|
|
19466
19497
|
name: "@tscircuit/core",
|
|
19467
19498
|
type: "module",
|
|
19468
|
-
version: "0.0.
|
|
19499
|
+
version: "0.0.925",
|
|
19469
19500
|
types: "dist/index.d.ts",
|
|
19470
19501
|
main: "dist/index.js",
|
|
19471
19502
|
module: "dist/index.js",
|