@tscircuit/core 0.0.633 → 0.0.634
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 +55 -38
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -8894,6 +8894,7 @@ import {
|
|
|
8894
8894
|
getPrimaryId
|
|
8895
8895
|
} from "@tscircuit/circuit-json-util";
|
|
8896
8896
|
import { length as length3 } from "circuit-json";
|
|
8897
|
+
import { CssGrid } from "minicssgrid";
|
|
8897
8898
|
function Group_doInitialPcbLayoutGrid(group) {
|
|
8898
8899
|
const { db } = group.root;
|
|
8899
8900
|
const props = group._parsedProps;
|
|
@@ -8901,8 +8902,8 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
8901
8902
|
(child) => child.pcb_component_id
|
|
8902
8903
|
);
|
|
8903
8904
|
if (pcbChildren.length === 0) return;
|
|
8904
|
-
let
|
|
8905
|
-
let
|
|
8905
|
+
let childWidth = 0;
|
|
8906
|
+
let childHeight = 0;
|
|
8906
8907
|
for (const child of pcbChildren) {
|
|
8907
8908
|
const pcbComp = db.pcb_component.get(child.pcb_component_id);
|
|
8908
8909
|
let width = pcbComp?.width ?? 0;
|
|
@@ -8912,11 +8913,11 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
8912
8913
|
width = Math.max(width, bounds.width);
|
|
8913
8914
|
height = Math.max(height, bounds.height);
|
|
8914
8915
|
}
|
|
8915
|
-
|
|
8916
|
-
|
|
8916
|
+
childWidth = Math.max(childWidth, width);
|
|
8917
|
+
childHeight = Math.max(childHeight, height);
|
|
8917
8918
|
}
|
|
8918
|
-
if (
|
|
8919
|
-
if (
|
|
8919
|
+
if (childWidth === 0 && pcbChildren.length > 0) childWidth = 1;
|
|
8920
|
+
if (childHeight === 0 && pcbChildren.length > 0) childHeight = 1;
|
|
8920
8921
|
let gridColsOption = props.pcbGridCols ?? props.gridCols;
|
|
8921
8922
|
let gridRowsOption = props.pcbGridRows;
|
|
8922
8923
|
let gridGapOption = props.pcbGridGap ?? props.gridGap;
|
|
@@ -8929,29 +8930,12 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
8929
8930
|
gridRowGapOption = props.pcbLayout.gridRowGap ?? gridRowGapOption;
|
|
8930
8931
|
gridColumnGapOption = props.pcbLayout.gridColumnGap ?? gridColumnGapOption;
|
|
8931
8932
|
}
|
|
8932
|
-
let numCols;
|
|
8933
|
-
let numRows;
|
|
8934
|
-
if (gridColsOption !== void 0 && gridRowsOption !== void 0) {
|
|
8935
|
-
numCols = gridColsOption;
|
|
8936
|
-
numRows = gridRowsOption;
|
|
8937
|
-
} else if (gridColsOption !== void 0) {
|
|
8938
|
-
numCols = gridColsOption;
|
|
8939
|
-
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8940
|
-
} else if (gridRowsOption !== void 0) {
|
|
8941
|
-
numRows = gridRowsOption;
|
|
8942
|
-
numCols = Math.ceil(pcbChildren.length / numRows);
|
|
8943
|
-
} else {
|
|
8944
|
-
numCols = Math.ceil(Math.sqrt(pcbChildren.length));
|
|
8945
|
-
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8946
|
-
}
|
|
8947
|
-
if (numCols === 0 && pcbChildren.length > 0) numCols = 1;
|
|
8948
|
-
if (numRows === 0 && pcbChildren.length > 0) numRows = pcbChildren.length;
|
|
8949
|
-
let gridGapX;
|
|
8950
|
-
let gridGapY;
|
|
8951
8933
|
const parseGap = (val) => {
|
|
8952
8934
|
if (val === void 0) return void 0;
|
|
8953
8935
|
return typeof val === "number" ? val : length3.parse(val);
|
|
8954
8936
|
};
|
|
8937
|
+
let gridGapX = props.pcbGridColumnGap ?? props.gridColumnGap;
|
|
8938
|
+
let gridGapY = props.pcbGridRowGap ?? props.gridRowGap;
|
|
8955
8939
|
if (gridRowGapOption !== void 0 || gridColumnGapOption !== void 0) {
|
|
8956
8940
|
const fallbackX = typeof gridGapOption === "object" && gridGapOption !== null ? gridGapOption.x : gridGapOption;
|
|
8957
8941
|
const fallbackY = typeof gridGapOption === "object" && gridGapOption !== null ? gridGapOption.y : gridGapOption;
|
|
@@ -8973,24 +8957,56 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
8973
8957
|
gridGapX = 1;
|
|
8974
8958
|
gridGapY = 1;
|
|
8975
8959
|
}
|
|
8976
|
-
|
|
8977
|
-
|
|
8960
|
+
let numCols = gridColsOption ?? 0;
|
|
8961
|
+
let numRows = gridRowsOption ?? 0;
|
|
8962
|
+
if (gridColsOption !== void 0 && gridRowsOption !== void 0) {
|
|
8963
|
+
numCols = gridColsOption;
|
|
8964
|
+
numRows = gridRowsOption;
|
|
8965
|
+
} else if (gridColsOption !== void 0) {
|
|
8966
|
+
numCols = gridColsOption;
|
|
8967
|
+
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8968
|
+
} else if (gridRowsOption !== void 0) {
|
|
8969
|
+
numRows = gridRowsOption;
|
|
8970
|
+
numCols = Math.ceil(pcbChildren.length / numRows);
|
|
8971
|
+
} else {
|
|
8972
|
+
numCols = Math.ceil(Math.sqrt(pcbChildren.length));
|
|
8973
|
+
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8974
|
+
}
|
|
8975
|
+
if (numCols === 0 && pcbChildren.length > 0) numCols = 1;
|
|
8976
|
+
if (numRows === 0 && pcbChildren.length > 0) numRows = pcbChildren.length;
|
|
8977
|
+
const totalGridWidth = numCols * childWidth + Math.max(0, numCols - 1) * gridGapX;
|
|
8978
|
+
const totalGridHeight = numRows * childHeight + Math.max(0, numRows - 1) * gridGapY;
|
|
8979
|
+
const gridTemplateColumns = props.pcbGridTemplateColumns ?? `repeat(${numCols}, ${childWidth}px)`;
|
|
8980
|
+
const gridTemplateRows = props.pcbGridTemplateRows ?? `repeat(${numRows}, ${childHeight}px)`;
|
|
8981
|
+
const gridChildren = pcbChildren.map((child, index) => ({
|
|
8982
|
+
key: child.getString() || `child-${index}`,
|
|
8983
|
+
contentWidth: childWidth,
|
|
8984
|
+
contentHeight: childHeight
|
|
8985
|
+
}));
|
|
8986
|
+
const cssGrid = new CssGrid({
|
|
8987
|
+
containerWidth: totalGridWidth,
|
|
8988
|
+
containerHeight: totalGridHeight,
|
|
8989
|
+
gridTemplateColumns,
|
|
8990
|
+
gridTemplateRows,
|
|
8991
|
+
gap: [gridGapY, gridGapX],
|
|
8992
|
+
// [rowGap, columnGap]
|
|
8993
|
+
children: gridChildren
|
|
8994
|
+
});
|
|
8995
|
+
const { itemCoordinates } = cssGrid.layout();
|
|
8978
8996
|
const groupCenter = group._getGlobalPcbPositionBeforeLayout();
|
|
8979
|
-
const firstCellCenterX = groupCenter.x - totalGridWidth / 2 + maxCellWidth / 2;
|
|
8980
|
-
const firstCellCenterY = groupCenter.y + totalGridHeight / 2 - maxCellHeight / 2;
|
|
8981
8997
|
for (let i = 0; i < pcbChildren.length; i++) {
|
|
8982
8998
|
const child = pcbChildren[i];
|
|
8983
8999
|
if (!child.pcb_component_id) continue;
|
|
8984
|
-
const
|
|
8985
|
-
const
|
|
8986
|
-
if (
|
|
9000
|
+
const childKey = child.getString() || `child-${i}`;
|
|
9001
|
+
const coordinates = itemCoordinates[childKey];
|
|
9002
|
+
if (!coordinates) {
|
|
8987
9003
|
console.warn(
|
|
8988
|
-
`PCB grid layout:
|
|
9004
|
+
`PCB grid layout: No coordinates found for child ${childKey}`
|
|
8989
9005
|
);
|
|
8990
9006
|
continue;
|
|
8991
9007
|
}
|
|
8992
|
-
const targetCellCenterX =
|
|
8993
|
-
const targetCellCenterY =
|
|
9008
|
+
const targetCellCenterX = groupCenter.x - totalGridWidth / 2 + coordinates.x + coordinates.width / 2;
|
|
9009
|
+
const targetCellCenterY = groupCenter.y + totalGridHeight / 2 - coordinates.y - coordinates.height / 2;
|
|
8994
9010
|
const pcbComp = db.pcb_component.get(child.pcb_component_id);
|
|
8995
9011
|
if (pcbComp) {
|
|
8996
9012
|
const oldCenter = pcbComp.center;
|
|
@@ -12532,7 +12548,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
12532
12548
|
var package_default = {
|
|
12533
12549
|
name: "@tscircuit/core",
|
|
12534
12550
|
type: "module",
|
|
12535
|
-
version: "0.0.
|
|
12551
|
+
version: "0.0.633",
|
|
12536
12552
|
types: "dist/index.d.ts",
|
|
12537
12553
|
main: "dist/index.js",
|
|
12538
12554
|
module: "dist/index.js",
|
|
@@ -12562,6 +12578,7 @@ var package_default = {
|
|
|
12562
12578
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
12563
12579
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
12564
12580
|
"@tscircuit/log-soup": "^1.0.2",
|
|
12581
|
+
"@tscircuit/matchpack": "^0.0.4",
|
|
12565
12582
|
"@tscircuit/math-utils": "^0.0.18",
|
|
12566
12583
|
"@tscircuit/miniflex": "^0.0.4",
|
|
12567
12584
|
"@tscircuit/props": "^0.0.286",
|
|
@@ -12589,13 +12606,13 @@ var package_default = {
|
|
|
12589
12606
|
howfat: "^0.3.8",
|
|
12590
12607
|
"live-server": "^1.2.2",
|
|
12591
12608
|
"looks-same": "^9.0.1",
|
|
12609
|
+
minicssgrid: "^0.0.5",
|
|
12592
12610
|
"pkg-pr-new": "^0.0.37",
|
|
12593
12611
|
react: "^19.1.0",
|
|
12594
12612
|
"react-dom": "^19.1.0",
|
|
12595
12613
|
"schematic-symbols": "^0.0.180",
|
|
12596
12614
|
"ts-expect": "^1.3.0",
|
|
12597
|
-
tsup: "^8.2.4"
|
|
12598
|
-
"@tscircuit/matchpack": "^0.0.4"
|
|
12615
|
+
tsup: "^8.2.4"
|
|
12599
12616
|
},
|
|
12600
12617
|
peerDependencies: {
|
|
12601
12618
|
"@tscircuit/capacity-autorouter": "*",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.634",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
32
32
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
33
33
|
"@tscircuit/log-soup": "^1.0.2",
|
|
34
|
+
"@tscircuit/matchpack": "^0.0.4",
|
|
34
35
|
"@tscircuit/math-utils": "^0.0.18",
|
|
35
36
|
"@tscircuit/miniflex": "^0.0.4",
|
|
36
37
|
"@tscircuit/props": "^0.0.286",
|
|
@@ -58,13 +59,13 @@
|
|
|
58
59
|
"howfat": "^0.3.8",
|
|
59
60
|
"live-server": "^1.2.2",
|
|
60
61
|
"looks-same": "^9.0.1",
|
|
62
|
+
"minicssgrid": "^0.0.5",
|
|
61
63
|
"pkg-pr-new": "^0.0.37",
|
|
62
64
|
"react": "^19.1.0",
|
|
63
65
|
"react-dom": "^19.1.0",
|
|
64
66
|
"schematic-symbols": "^0.0.180",
|
|
65
67
|
"ts-expect": "^1.3.0",
|
|
66
|
-
"tsup": "^8.2.4"
|
|
67
|
-
"@tscircuit/matchpack": "^0.0.4"
|
|
68
|
+
"tsup": "^8.2.4"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
71
|
"@tscircuit/capacity-autorouter": "*",
|