@tscircuit/hypergraph 0.0.3 → 0.0.4
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.d.ts +7 -1
- package/dist/index.js +30 -11
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ type JumperGraph = {
|
|
|
117
117
|
ports: JPort[];
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
-
declare const generateJumperX4Grid: ({ cols, rows, marginX, marginY, innerColChannelPointCount, innerRowChannelPointCount, regionsBetweenPads, outerPaddingX, outerPaddingY, outerChannelXPointCount, outerChannelYPointCount, orientation, center, }: {
|
|
120
|
+
declare const generateJumperX4Grid: ({ cols, rows, marginX, marginY, innerColChannelPointCount, innerRowChannelPointCount, regionsBetweenPads, outerPaddingX: outerPaddingXParam, outerPaddingY: outerPaddingYParam, outerChannelXPointCount, outerChannelYPointCount, orientation, center, bounds, }: {
|
|
121
121
|
cols: number;
|
|
122
122
|
rows: number;
|
|
123
123
|
marginX: number;
|
|
@@ -134,6 +134,12 @@ declare const generateJumperX4Grid: ({ cols, rows, marginX, marginY, innerColCha
|
|
|
134
134
|
x: number;
|
|
135
135
|
y: number;
|
|
136
136
|
};
|
|
137
|
+
bounds?: {
|
|
138
|
+
minX: number;
|
|
139
|
+
maxX: number;
|
|
140
|
+
minY: number;
|
|
141
|
+
maxY: number;
|
|
142
|
+
};
|
|
137
143
|
}) => JumperGraph;
|
|
138
144
|
|
|
139
145
|
declare const generateJumperGrid: ({ cols, rows, marginX, marginY, innerColChannelPointCount, innerRowChannelPointCount, outerPaddingX, outerPaddingY, outerChannelXPoints, outerChannelYPoints, }: {
|
package/dist/index.js
CHANGED
|
@@ -199,15 +199,14 @@ var generateJumperX4Grid = ({
|
|
|
199
199
|
innerColChannelPointCount = 1,
|
|
200
200
|
innerRowChannelPointCount = 1,
|
|
201
201
|
regionsBetweenPads = false,
|
|
202
|
-
outerPaddingX = 0.5,
|
|
203
|
-
outerPaddingY = 0.5,
|
|
202
|
+
outerPaddingX: outerPaddingXParam = 0.5,
|
|
203
|
+
outerPaddingY: outerPaddingYParam = 0.5,
|
|
204
204
|
outerChannelXPointCount,
|
|
205
205
|
outerChannelYPointCount,
|
|
206
206
|
orientation: orientation2 = "vertical",
|
|
207
|
-
center
|
|
207
|
+
center,
|
|
208
|
+
bounds
|
|
208
209
|
}) => {
|
|
209
|
-
const effectiveOuterChannelXPoints = outerChannelXPointCount ?? Math.max(1, Math.floor(outerPaddingX / 0.4));
|
|
210
|
-
const effectiveOuterChannelYPoints = outerChannelYPointCount ?? Math.max(1, Math.floor(outerPaddingY / 0.4));
|
|
211
210
|
const regions = [];
|
|
212
211
|
const ports = [];
|
|
213
212
|
const {
|
|
@@ -226,11 +225,23 @@ var generateJumperX4Grid = ({
|
|
|
226
225
|
const horizontalSpacing = cellWidth + marginX;
|
|
227
226
|
const cellHeight = row1CenterY - row4CenterY + padHeight;
|
|
228
227
|
const verticalSpacing = cellHeight + marginY;
|
|
228
|
+
let outerPaddingX = outerPaddingXParam;
|
|
229
|
+
let outerPaddingY = outerPaddingYParam;
|
|
230
|
+
if (bounds) {
|
|
231
|
+
const contentWidth = cols * cellWidth + (cols - 1) * marginX;
|
|
232
|
+
const contentHeight = rows * cellHeight + (rows - 1) * marginY;
|
|
233
|
+
const boundsWidth = bounds.maxX - bounds.minX;
|
|
234
|
+
const boundsHeight = bounds.maxY - bounds.minY;
|
|
235
|
+
outerPaddingX = (boundsWidth - contentWidth) / 2;
|
|
236
|
+
outerPaddingY = (boundsHeight - contentHeight) / 2;
|
|
237
|
+
}
|
|
238
|
+
const effectiveOuterChannelXPoints = outerChannelXPointCount ?? Math.max(1, Math.floor(outerPaddingX / 0.4));
|
|
239
|
+
const effectiveOuterChannelYPoints = outerChannelYPointCount ?? Math.max(1, Math.floor(outerPaddingY / 0.4));
|
|
229
240
|
const cells = [];
|
|
230
|
-
const createRegion = (id,
|
|
241
|
+
const createRegion = (id, bounds2, isPad, isThroughJumper) => ({
|
|
231
242
|
regionId: id,
|
|
232
243
|
ports: [],
|
|
233
|
-
d: { bounds, center: computeBoundsCenter(
|
|
244
|
+
d: { bounds: bounds2, center: computeBoundsCenter(bounds2), isPad, isThroughJumper }
|
|
234
245
|
});
|
|
235
246
|
const createPort = (id, region1, region2) => {
|
|
236
247
|
const b1 = region1.d.bounds;
|
|
@@ -837,7 +848,7 @@ var generateJumperX4Grid = ({
|
|
|
837
848
|
`cell_${row}_${col - 1}->cell_${row}_${col}:T-T`,
|
|
838
849
|
prevCell.top,
|
|
839
850
|
top,
|
|
840
|
-
|
|
851
|
+
effectiveOuterChannelYPoints
|
|
841
852
|
)
|
|
842
853
|
);
|
|
843
854
|
}
|
|
@@ -847,7 +858,7 @@ var generateJumperX4Grid = ({
|
|
|
847
858
|
`cell_${row}_${col - 1}->cell_${row}_${col}:B-B`,
|
|
848
859
|
prevCell.bottom,
|
|
849
860
|
bottom,
|
|
850
|
-
innerRowChannelPointCount
|
|
861
|
+
isLastRow ? effectiveOuterChannelYPoints : innerRowChannelPointCount
|
|
851
862
|
)
|
|
852
863
|
);
|
|
853
864
|
}
|
|
@@ -917,7 +928,8 @@ var generateJumperX4Grid = ({
|
|
|
917
928
|
let graph = { regions, ports };
|
|
918
929
|
const needsRotation = orientation2 === "horizontal";
|
|
919
930
|
const needsCentering = center !== void 0;
|
|
920
|
-
|
|
931
|
+
const needsBoundsTransform = bounds !== void 0;
|
|
932
|
+
if (needsRotation || needsCentering || needsBoundsTransform) {
|
|
921
933
|
const currentBounds = calculateGraphBounds(graph.regions);
|
|
922
934
|
const currentCenter = computeBoundsCenter(currentBounds);
|
|
923
935
|
const matrices = [];
|
|
@@ -925,7 +937,14 @@ var generateJumperX4Grid = ({
|
|
|
925
937
|
if (needsRotation) {
|
|
926
938
|
matrices.push(rotate(-Math.PI / 2));
|
|
927
939
|
}
|
|
928
|
-
|
|
940
|
+
let targetCenter;
|
|
941
|
+
if (center) {
|
|
942
|
+
targetCenter = center;
|
|
943
|
+
} else if (bounds) {
|
|
944
|
+
targetCenter = computeBoundsCenter(bounds);
|
|
945
|
+
} else {
|
|
946
|
+
targetCenter = currentCenter;
|
|
947
|
+
}
|
|
929
948
|
matrices.push(translate(targetCenter.x, targetCenter.y));
|
|
930
949
|
const matrix = compose(...matrices);
|
|
931
950
|
graph = applyTransformToGraph(graph, matrix);
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/hypergraph",
|
|
3
3
|
"main": "dist/index.js",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "cosmos",
|
|
8
|
+
"format": "biome format --write .",
|
|
8
9
|
"build:site": "cosmos-export",
|
|
9
10
|
"build": "tsup ./lib/index.ts --dts --format esm"
|
|
10
11
|
},
|