@tscircuit/core 0.0.632 → 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 +61 -39
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -6194,7 +6194,12 @@ var NormalComponent = class extends PrimitiveComponent2 {
|
|
|
6194
6194
|
return [];
|
|
6195
6195
|
}
|
|
6196
6196
|
get internallyConnectedPinNames() {
|
|
6197
|
-
|
|
6197
|
+
const rawPins = this._parsedProps.internallyConnectedPins ?? this.defaultInternallyConnectedPinNames;
|
|
6198
|
+
return rawPins.map(
|
|
6199
|
+
(pinGroup) => pinGroup.map(
|
|
6200
|
+
(pin) => typeof pin === "number" ? `pin${pin}` : pin
|
|
6201
|
+
)
|
|
6202
|
+
);
|
|
6198
6203
|
}
|
|
6199
6204
|
constructor(props) {
|
|
6200
6205
|
super(props);
|
|
@@ -8889,6 +8894,7 @@ import {
|
|
|
8889
8894
|
getPrimaryId
|
|
8890
8895
|
} from "@tscircuit/circuit-json-util";
|
|
8891
8896
|
import { length as length3 } from "circuit-json";
|
|
8897
|
+
import { CssGrid } from "minicssgrid";
|
|
8892
8898
|
function Group_doInitialPcbLayoutGrid(group) {
|
|
8893
8899
|
const { db } = group.root;
|
|
8894
8900
|
const props = group._parsedProps;
|
|
@@ -8896,8 +8902,8 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
8896
8902
|
(child) => child.pcb_component_id
|
|
8897
8903
|
);
|
|
8898
8904
|
if (pcbChildren.length === 0) return;
|
|
8899
|
-
let
|
|
8900
|
-
let
|
|
8905
|
+
let childWidth = 0;
|
|
8906
|
+
let childHeight = 0;
|
|
8901
8907
|
for (const child of pcbChildren) {
|
|
8902
8908
|
const pcbComp = db.pcb_component.get(child.pcb_component_id);
|
|
8903
8909
|
let width = pcbComp?.width ?? 0;
|
|
@@ -8907,11 +8913,11 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
8907
8913
|
width = Math.max(width, bounds.width);
|
|
8908
8914
|
height = Math.max(height, bounds.height);
|
|
8909
8915
|
}
|
|
8910
|
-
|
|
8911
|
-
|
|
8916
|
+
childWidth = Math.max(childWidth, width);
|
|
8917
|
+
childHeight = Math.max(childHeight, height);
|
|
8912
8918
|
}
|
|
8913
|
-
if (
|
|
8914
|
-
if (
|
|
8919
|
+
if (childWidth === 0 && pcbChildren.length > 0) childWidth = 1;
|
|
8920
|
+
if (childHeight === 0 && pcbChildren.length > 0) childHeight = 1;
|
|
8915
8921
|
let gridColsOption = props.pcbGridCols ?? props.gridCols;
|
|
8916
8922
|
let gridRowsOption = props.pcbGridRows;
|
|
8917
8923
|
let gridGapOption = props.pcbGridGap ?? props.gridGap;
|
|
@@ -8924,29 +8930,12 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
8924
8930
|
gridRowGapOption = props.pcbLayout.gridRowGap ?? gridRowGapOption;
|
|
8925
8931
|
gridColumnGapOption = props.pcbLayout.gridColumnGap ?? gridColumnGapOption;
|
|
8926
8932
|
}
|
|
8927
|
-
let numCols;
|
|
8928
|
-
let numRows;
|
|
8929
|
-
if (gridColsOption !== void 0 && gridRowsOption !== void 0) {
|
|
8930
|
-
numCols = gridColsOption;
|
|
8931
|
-
numRows = gridRowsOption;
|
|
8932
|
-
} else if (gridColsOption !== void 0) {
|
|
8933
|
-
numCols = gridColsOption;
|
|
8934
|
-
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8935
|
-
} else if (gridRowsOption !== void 0) {
|
|
8936
|
-
numRows = gridRowsOption;
|
|
8937
|
-
numCols = Math.ceil(pcbChildren.length / numRows);
|
|
8938
|
-
} else {
|
|
8939
|
-
numCols = Math.ceil(Math.sqrt(pcbChildren.length));
|
|
8940
|
-
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8941
|
-
}
|
|
8942
|
-
if (numCols === 0 && pcbChildren.length > 0) numCols = 1;
|
|
8943
|
-
if (numRows === 0 && pcbChildren.length > 0) numRows = pcbChildren.length;
|
|
8944
|
-
let gridGapX;
|
|
8945
|
-
let gridGapY;
|
|
8946
8933
|
const parseGap = (val) => {
|
|
8947
8934
|
if (val === void 0) return void 0;
|
|
8948
8935
|
return typeof val === "number" ? val : length3.parse(val);
|
|
8949
8936
|
};
|
|
8937
|
+
let gridGapX = props.pcbGridColumnGap ?? props.gridColumnGap;
|
|
8938
|
+
let gridGapY = props.pcbGridRowGap ?? props.gridRowGap;
|
|
8950
8939
|
if (gridRowGapOption !== void 0 || gridColumnGapOption !== void 0) {
|
|
8951
8940
|
const fallbackX = typeof gridGapOption === "object" && gridGapOption !== null ? gridGapOption.x : gridGapOption;
|
|
8952
8941
|
const fallbackY = typeof gridGapOption === "object" && gridGapOption !== null ? gridGapOption.y : gridGapOption;
|
|
@@ -8968,24 +8957,56 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
8968
8957
|
gridGapX = 1;
|
|
8969
8958
|
gridGapY = 1;
|
|
8970
8959
|
}
|
|
8971
|
-
|
|
8972
|
-
|
|
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();
|
|
8973
8996
|
const groupCenter = group._getGlobalPcbPositionBeforeLayout();
|
|
8974
|
-
const firstCellCenterX = groupCenter.x - totalGridWidth / 2 + maxCellWidth / 2;
|
|
8975
|
-
const firstCellCenterY = groupCenter.y + totalGridHeight / 2 - maxCellHeight / 2;
|
|
8976
8997
|
for (let i = 0; i < pcbChildren.length; i++) {
|
|
8977
8998
|
const child = pcbChildren[i];
|
|
8978
8999
|
if (!child.pcb_component_id) continue;
|
|
8979
|
-
const
|
|
8980
|
-
const
|
|
8981
|
-
if (
|
|
9000
|
+
const childKey = child.getString() || `child-${i}`;
|
|
9001
|
+
const coordinates = itemCoordinates[childKey];
|
|
9002
|
+
if (!coordinates) {
|
|
8982
9003
|
console.warn(
|
|
8983
|
-
`PCB grid layout:
|
|
9004
|
+
`PCB grid layout: No coordinates found for child ${childKey}`
|
|
8984
9005
|
);
|
|
8985
9006
|
continue;
|
|
8986
9007
|
}
|
|
8987
|
-
const targetCellCenterX =
|
|
8988
|
-
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;
|
|
8989
9010
|
const pcbComp = db.pcb_component.get(child.pcb_component_id);
|
|
8990
9011
|
if (pcbComp) {
|
|
8991
9012
|
const oldCenter = pcbComp.center;
|
|
@@ -12527,7 +12548,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
12527
12548
|
var package_default = {
|
|
12528
12549
|
name: "@tscircuit/core",
|
|
12529
12550
|
type: "module",
|
|
12530
|
-
version: "0.0.
|
|
12551
|
+
version: "0.0.633",
|
|
12531
12552
|
types: "dist/index.d.ts",
|
|
12532
12553
|
main: "dist/index.js",
|
|
12533
12554
|
module: "dist/index.js",
|
|
@@ -12557,6 +12578,7 @@ var package_default = {
|
|
|
12557
12578
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
12558
12579
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
12559
12580
|
"@tscircuit/log-soup": "^1.0.2",
|
|
12581
|
+
"@tscircuit/matchpack": "^0.0.4",
|
|
12560
12582
|
"@tscircuit/math-utils": "^0.0.18",
|
|
12561
12583
|
"@tscircuit/miniflex": "^0.0.4",
|
|
12562
12584
|
"@tscircuit/props": "^0.0.286",
|
|
@@ -12584,13 +12606,13 @@ var package_default = {
|
|
|
12584
12606
|
howfat: "^0.3.8",
|
|
12585
12607
|
"live-server": "^1.2.2",
|
|
12586
12608
|
"looks-same": "^9.0.1",
|
|
12609
|
+
minicssgrid: "^0.0.5",
|
|
12587
12610
|
"pkg-pr-new": "^0.0.37",
|
|
12588
12611
|
react: "^19.1.0",
|
|
12589
12612
|
"react-dom": "^19.1.0",
|
|
12590
12613
|
"schematic-symbols": "^0.0.180",
|
|
12591
12614
|
"ts-expect": "^1.3.0",
|
|
12592
|
-
tsup: "^8.2.4"
|
|
12593
|
-
"@tscircuit/matchpack": "^0.0.4"
|
|
12615
|
+
tsup: "^8.2.4"
|
|
12594
12616
|
},
|
|
12595
12617
|
peerDependencies: {
|
|
12596
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": "*",
|