@tscircuit/core 0.0.924 → 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 +59 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1281,9 +1281,6 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
1281
1281
|
if (Object.keys(component).length === 0) {
|
|
1282
1282
|
return;
|
|
1283
1283
|
}
|
|
1284
|
-
if (this.lowercaseComponentName === "board" && component.lowercaseComponentName === "board") {
|
|
1285
|
-
throw new Error("Nested boards are not supported");
|
|
1286
|
-
}
|
|
1287
1284
|
if (component.lowercaseComponentName === "panel") {
|
|
1288
1285
|
throw new Error("<panel> must be a root-level element");
|
|
1289
1286
|
}
|
|
@@ -15710,6 +15707,14 @@ var Board = class extends Group6 {
|
|
|
15710
15707
|
});
|
|
15711
15708
|
}
|
|
15712
15709
|
doInitialSourceRender() {
|
|
15710
|
+
const nestedBoard = this.getDescendants().find(
|
|
15711
|
+
(d) => d.lowercaseComponentName === "board"
|
|
15712
|
+
);
|
|
15713
|
+
if (nestedBoard) {
|
|
15714
|
+
throw new Error(
|
|
15715
|
+
`Nested boards are not supported: found board "${nestedBoard.name}" inside board "${this.name}"`
|
|
15716
|
+
);
|
|
15717
|
+
}
|
|
15713
15718
|
super.doInitialSourceRender();
|
|
15714
15719
|
const { db } = this.root;
|
|
15715
15720
|
const source_board = db.source_board.insert({
|
|
@@ -15753,14 +15758,8 @@ var Board = class extends Group6 {
|
|
|
15753
15758
|
const maxX = Math.max(...xValues);
|
|
15754
15759
|
const minY = Math.min(...yValues);
|
|
15755
15760
|
const maxY = Math.max(...yValues);
|
|
15756
|
-
const outlineCenterX = (minX + maxX) / 2;
|
|
15757
|
-
const outlineCenterY = (minY + maxY) / 2;
|
|
15758
15761
|
computedWidth = maxX - minX;
|
|
15759
15762
|
computedHeight = maxY - minY;
|
|
15760
|
-
center = {
|
|
15761
|
-
x: outlineCenterX + (props.outlineOffsetX ?? 0),
|
|
15762
|
-
y: outlineCenterY + (props.outlineOffsetY ?? 0)
|
|
15763
|
-
};
|
|
15764
15763
|
}
|
|
15765
15764
|
let outline = props.outline;
|
|
15766
15765
|
if (!outline && props.borderRadius != null && computedWidth > 0 && computedHeight > 0) {
|
|
@@ -15848,20 +15847,57 @@ var Board = class extends Group6 {
|
|
|
15848
15847
|
}
|
|
15849
15848
|
}
|
|
15850
15849
|
_repositionOnPcb(position) {
|
|
15851
|
-
|
|
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
|
+
}
|
|
15852
15882
|
if (this.pcb_board_id) {
|
|
15853
|
-
|
|
15854
|
-
|
|
15855
|
-
|
|
15856
|
-
|
|
15857
|
-
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
|
|
15862
|
-
|
|
15863
|
-
outline
|
|
15864
|
-
|
|
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
|
+
}
|
|
15865
15901
|
}
|
|
15866
15902
|
}
|
|
15867
15903
|
}
|
|
@@ -19460,7 +19496,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
19460
19496
|
var package_default = {
|
|
19461
19497
|
name: "@tscircuit/core",
|
|
19462
19498
|
type: "module",
|
|
19463
|
-
version: "0.0.
|
|
19499
|
+
version: "0.0.925",
|
|
19464
19500
|
types: "dist/index.d.ts",
|
|
19465
19501
|
main: "dist/index.js",
|
|
19466
19502
|
module: "dist/index.js",
|