@tscircuit/core 0.0.1002 → 0.0.1004
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 +118 -11
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -16964,6 +16964,49 @@ var getBoardDimensionsFromProps = (board) => {
|
|
|
16964
16964
|
};
|
|
16965
16965
|
|
|
16966
16966
|
// lib/utils/panels/pack-boards-into-grid.ts
|
|
16967
|
+
function calculateOptimalGrid({
|
|
16968
|
+
boardsWithDims,
|
|
16969
|
+
availableWidth,
|
|
16970
|
+
availableHeight,
|
|
16971
|
+
boardGap,
|
|
16972
|
+
minCellWidth,
|
|
16973
|
+
minCellHeight
|
|
16974
|
+
}) {
|
|
16975
|
+
const boardCount = boardsWithDims.length;
|
|
16976
|
+
if (boardCount === 0) {
|
|
16977
|
+
return { rows: 0, cols: 0 };
|
|
16978
|
+
}
|
|
16979
|
+
const maxBoardWidth = Math.max(
|
|
16980
|
+
...boardsWithDims.map((b) => b.width),
|
|
16981
|
+
minCellWidth
|
|
16982
|
+
);
|
|
16983
|
+
const maxBoardHeight = Math.max(
|
|
16984
|
+
...boardsWithDims.map((b) => b.height),
|
|
16985
|
+
minCellHeight
|
|
16986
|
+
);
|
|
16987
|
+
const maxCols = Math.max(
|
|
16988
|
+
1,
|
|
16989
|
+
Math.floor((availableWidth + boardGap) / (maxBoardWidth + boardGap))
|
|
16990
|
+
);
|
|
16991
|
+
const maxRows = Math.max(
|
|
16992
|
+
1,
|
|
16993
|
+
Math.floor((availableHeight + boardGap) / (maxBoardHeight + boardGap))
|
|
16994
|
+
);
|
|
16995
|
+
let bestCols = maxCols;
|
|
16996
|
+
let bestRows = Math.ceil(boardCount / bestCols);
|
|
16997
|
+
if (bestRows > maxRows) {
|
|
16998
|
+
bestRows = maxRows;
|
|
16999
|
+
bestCols = Math.ceil(boardCount / bestRows);
|
|
17000
|
+
if (bestCols > maxCols) {
|
|
17001
|
+
bestCols = maxCols;
|
|
17002
|
+
bestRows = Math.ceil(boardCount / bestCols);
|
|
17003
|
+
}
|
|
17004
|
+
}
|
|
17005
|
+
return {
|
|
17006
|
+
rows: Math.max(1, bestRows),
|
|
17007
|
+
cols: Math.max(1, bestCols)
|
|
17008
|
+
};
|
|
17009
|
+
}
|
|
16967
17010
|
var packBoardsIntoGrid = ({
|
|
16968
17011
|
boards,
|
|
16969
17012
|
db,
|
|
@@ -16971,7 +17014,9 @@ var packBoardsIntoGrid = ({
|
|
|
16971
17014
|
col,
|
|
16972
17015
|
cellWidth,
|
|
16973
17016
|
cellHeight,
|
|
16974
|
-
boardGap
|
|
17017
|
+
boardGap,
|
|
17018
|
+
availablePanelWidth,
|
|
17019
|
+
availablePanelHeight
|
|
16975
17020
|
}) => {
|
|
16976
17021
|
const boardsWithDims = boards.map((board) => {
|
|
16977
17022
|
let width;
|
|
@@ -17002,8 +17047,29 @@ var packBoardsIntoGrid = ({
|
|
|
17002
17047
|
}
|
|
17003
17048
|
const explicitRow = row;
|
|
17004
17049
|
const explicitCol = col;
|
|
17005
|
-
|
|
17006
|
-
|
|
17050
|
+
let cols;
|
|
17051
|
+
let rows;
|
|
17052
|
+
if (explicitCol !== void 0) {
|
|
17053
|
+
cols = explicitCol;
|
|
17054
|
+
rows = explicitRow ?? Math.ceil(boardsWithDims.length / cols);
|
|
17055
|
+
} else if (explicitRow !== void 0) {
|
|
17056
|
+
rows = explicitRow;
|
|
17057
|
+
cols = Math.ceil(boardsWithDims.length / rows);
|
|
17058
|
+
} else if (availablePanelWidth !== void 0 && availablePanelHeight !== void 0) {
|
|
17059
|
+
const result = calculateOptimalGrid({
|
|
17060
|
+
boardsWithDims,
|
|
17061
|
+
availableWidth: availablePanelWidth,
|
|
17062
|
+
availableHeight: availablePanelHeight,
|
|
17063
|
+
boardGap,
|
|
17064
|
+
minCellWidth: cellWidth ? distance10.parse(cellWidth) : 0,
|
|
17065
|
+
minCellHeight: cellHeight ? distance10.parse(cellHeight) : 0
|
|
17066
|
+
});
|
|
17067
|
+
cols = result.cols;
|
|
17068
|
+
rows = result.rows;
|
|
17069
|
+
} else {
|
|
17070
|
+
cols = Math.ceil(Math.sqrt(boardsWithDims.length));
|
|
17071
|
+
rows = Math.ceil(boardsWithDims.length / cols);
|
|
17072
|
+
}
|
|
17007
17073
|
const colWidths = Array(cols).fill(0);
|
|
17008
17074
|
const rowHeights = Array(rows).fill(0);
|
|
17009
17075
|
boardsWithDims.forEach((b, i) => {
|
|
@@ -17158,13 +17224,42 @@ var Subpanel = class _Subpanel extends Group6 {
|
|
|
17158
17224
|
if (layoutMode !== "grid") return;
|
|
17159
17225
|
const tabWidth = this._parsedProps.tabWidth ?? DEFAULT_TAB_WIDTH;
|
|
17160
17226
|
const boardGap = this._parsedProps.boardGap ?? tabWidth;
|
|
17227
|
+
let availablePanelWidth;
|
|
17228
|
+
let availablePanelHeight;
|
|
17229
|
+
const hasExplicitRowOrCol = this._parsedProps.row !== void 0 || this._parsedProps.col !== void 0;
|
|
17230
|
+
const hasExplicitWidth = this._parsedProps.width !== void 0;
|
|
17231
|
+
const hasExplicitHeight = this._parsedProps.height !== void 0;
|
|
17232
|
+
if (!hasExplicitRowOrCol && hasExplicitWidth && hasExplicitHeight) {
|
|
17233
|
+
const {
|
|
17234
|
+
edgePadding: edgePaddingProp,
|
|
17235
|
+
edgePaddingLeft: edgePaddingLeftProp,
|
|
17236
|
+
edgePaddingRight: edgePaddingRightProp,
|
|
17237
|
+
edgePaddingTop: edgePaddingTopProp,
|
|
17238
|
+
edgePaddingBottom: edgePaddingBottomProp
|
|
17239
|
+
} = this._parsedProps;
|
|
17240
|
+
const edgePadding = distance11.parse(edgePaddingProp ?? 5);
|
|
17241
|
+
const edgePaddingLeft = distance11.parse(edgePaddingLeftProp ?? edgePadding);
|
|
17242
|
+
const edgePaddingRight = distance11.parse(
|
|
17243
|
+
edgePaddingRightProp ?? edgePadding
|
|
17244
|
+
);
|
|
17245
|
+
const edgePaddingTop = distance11.parse(edgePaddingTopProp ?? edgePadding);
|
|
17246
|
+
const edgePaddingBottom = distance11.parse(
|
|
17247
|
+
edgePaddingBottomProp ?? edgePadding
|
|
17248
|
+
);
|
|
17249
|
+
const panelWidth = distance11.parse(this._parsedProps.width);
|
|
17250
|
+
const panelHeight = distance11.parse(this._parsedProps.height);
|
|
17251
|
+
availablePanelWidth = panelWidth - edgePaddingLeft - edgePaddingRight;
|
|
17252
|
+
availablePanelHeight = panelHeight - edgePaddingTop - edgePaddingBottom;
|
|
17253
|
+
}
|
|
17161
17254
|
const { positions, gridWidth, gridHeight } = packBoardsIntoGrid({
|
|
17162
17255
|
boards: childBoardInstances,
|
|
17163
17256
|
row: this._parsedProps.row,
|
|
17164
17257
|
col: this._parsedProps.col,
|
|
17165
17258
|
cellWidth: this._parsedProps.cellWidth,
|
|
17166
17259
|
cellHeight: this._parsedProps.cellHeight,
|
|
17167
|
-
boardGap
|
|
17260
|
+
boardGap,
|
|
17261
|
+
availablePanelHeight,
|
|
17262
|
+
availablePanelWidth
|
|
17168
17263
|
});
|
|
17169
17264
|
this._cachedGridWidth = gridWidth;
|
|
17170
17265
|
this._cachedGridHeight = gridHeight;
|
|
@@ -19589,6 +19684,12 @@ var Via = class extends PrimitiveComponent2 {
|
|
|
19589
19684
|
net_is_assignable: this._parsedProps.netIsAssignable ?? void 0
|
|
19590
19685
|
});
|
|
19591
19686
|
this.pcb_via_id = pcb_via.pcb_via_id;
|
|
19687
|
+
const connected = this._getConnectedNetOrTrace();
|
|
19688
|
+
if (connected && "source_net_id" in connected && connected.source_net_id) {
|
|
19689
|
+
db.pcb_via.update(this.pcb_via_id, {
|
|
19690
|
+
pcb_trace_id: connected.source_net_id
|
|
19691
|
+
});
|
|
19692
|
+
}
|
|
19592
19693
|
}
|
|
19593
19694
|
};
|
|
19594
19695
|
|
|
@@ -19598,6 +19699,7 @@ import {
|
|
|
19598
19699
|
CopperPourPipelineSolver as CopperPourPipelineSolver2,
|
|
19599
19700
|
convertCircuitJsonToInputProblem
|
|
19600
19701
|
} from "@tscircuit/copper-pour-solver";
|
|
19702
|
+
import { getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson4 } from "circuit-json-to-connectivity-map";
|
|
19601
19703
|
var CopperPour = class extends PrimitiveComponent2 {
|
|
19602
19704
|
isPcbPrimitive = true;
|
|
19603
19705
|
get config() {
|
|
@@ -19624,17 +19726,22 @@ var CopperPour = class extends PrimitiveComponent2 {
|
|
|
19624
19726
|
return;
|
|
19625
19727
|
}
|
|
19626
19728
|
const subcircuit = this.getSubcircuit();
|
|
19627
|
-
const
|
|
19729
|
+
const circuitJson = db.toArray();
|
|
19730
|
+
const sourceNet = circuitJson.find(
|
|
19628
19731
|
(elm) => elm.type === "source_net" && elm.name === net.name
|
|
19629
|
-
)
|
|
19732
|
+
);
|
|
19733
|
+
const connectivityMap = getFullConnectivityMapFromCircuitJson4(circuitJson);
|
|
19734
|
+
const connectedNetId = sourceNet?.source_net_id ?? net.source_net_id;
|
|
19735
|
+
const pourConnectivityKey = (connectedNetId ? connectivityMap.getNetConnectedToId(connectedNetId) : void 0) || sourceNet?.subcircuit_connectivity_map_key || "";
|
|
19630
19736
|
const clearance = props.clearance ?? 0.2;
|
|
19631
|
-
const inputProblem = convertCircuitJsonToInputProblem(
|
|
19737
|
+
const inputProblem = convertCircuitJsonToInputProblem(circuitJson, {
|
|
19632
19738
|
layer: props.layer,
|
|
19633
|
-
pour_connectivity_key:
|
|
19739
|
+
pour_connectivity_key: pourConnectivityKey,
|
|
19634
19740
|
pad_margin: props.padMargin ?? clearance,
|
|
19635
19741
|
trace_margin: props.traceMargin ?? clearance,
|
|
19636
19742
|
board_edge_margin: props.boardEdgeMargin ?? clearance,
|
|
19637
|
-
cutout_margin: props.cutoutMargin ?? clearance
|
|
19743
|
+
cutout_margin: props.cutoutMargin ?? clearance,
|
|
19744
|
+
outline: props.outline
|
|
19638
19745
|
});
|
|
19639
19746
|
const solver = new CopperPourPipelineSolver2(inputProblem);
|
|
19640
19747
|
this.root.emit("solver:started", {
|
|
@@ -21593,7 +21700,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
21593
21700
|
var package_default = {
|
|
21594
21701
|
name: "@tscircuit/core",
|
|
21595
21702
|
type: "module",
|
|
21596
|
-
version: "0.0.
|
|
21703
|
+
version: "0.0.1003",
|
|
21597
21704
|
types: "dist/index.d.ts",
|
|
21598
21705
|
main: "dist/index.js",
|
|
21599
21706
|
module: "dist/index.js",
|
|
@@ -21628,7 +21735,7 @@ var package_default = {
|
|
|
21628
21735
|
"@tscircuit/checks": "^0.0.87",
|
|
21629
21736
|
"@tscircuit/circuit-json-util": "^0.0.77",
|
|
21630
21737
|
"@tscircuit/common": "^0.0.20",
|
|
21631
|
-
"@tscircuit/copper-pour-solver": "^0.0.
|
|
21738
|
+
"@tscircuit/copper-pour-solver": "^0.0.20",
|
|
21632
21739
|
"@tscircuit/footprinter": "^0.0.288",
|
|
21633
21740
|
"@tscircuit/infgrid-ijump-astar": "^0.0.35",
|
|
21634
21741
|
"@tscircuit/log-soup": "^1.0.2",
|
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.1004",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@tscircuit/checks": "^0.0.87",
|
|
37
37
|
"@tscircuit/circuit-json-util": "^0.0.77",
|
|
38
38
|
"@tscircuit/common": "^0.0.20",
|
|
39
|
-
"@tscircuit/copper-pour-solver": "^0.0.
|
|
39
|
+
"@tscircuit/copper-pour-solver": "^0.0.20",
|
|
40
40
|
"@tscircuit/footprinter": "^0.0.288",
|
|
41
41
|
"@tscircuit/infgrid-ijump-astar": "^0.0.35",
|
|
42
42
|
"@tscircuit/log-soup": "^1.0.2",
|