@tscircuit/core 0.0.1436 → 0.0.1437
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 +70 -42
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19318,6 +19318,49 @@ function getReservedChipSize({
|
|
|
19318
19318
|
const growsPastGap = rotatedSize.x - unrotatedSize.x >= chipGap || rotatedSize.y - unrotatedSize.y >= chipGap;
|
|
19319
19319
|
return growsPastGap ? rotatedSize : unrotatedSize;
|
|
19320
19320
|
}
|
|
19321
|
+
function getNestedGroupMatchpackProxy({
|
|
19322
|
+
db,
|
|
19323
|
+
schematicGroup,
|
|
19324
|
+
groupComponents,
|
|
19325
|
+
groupInstance
|
|
19326
|
+
}) {
|
|
19327
|
+
let minX = Infinity;
|
|
19328
|
+
let maxX = -Infinity;
|
|
19329
|
+
let minY = Infinity;
|
|
19330
|
+
let maxY = -Infinity;
|
|
19331
|
+
let hasValidBounds = false;
|
|
19332
|
+
for (const component of groupComponents) {
|
|
19333
|
+
if (!component.center || !component.size) continue;
|
|
19334
|
+
hasValidBounds = true;
|
|
19335
|
+
const componentBounds = getSchematicComponentWithTextBounds({
|
|
19336
|
+
db,
|
|
19337
|
+
schematicComponent: component
|
|
19338
|
+
}) ?? getBoundFromCenteredRect2({
|
|
19339
|
+
center: component.center,
|
|
19340
|
+
width: component.size.width,
|
|
19341
|
+
height: component.size.height
|
|
19342
|
+
});
|
|
19343
|
+
minX = Math.min(minX, componentBounds.minX);
|
|
19344
|
+
maxX = Math.max(maxX, componentBounds.maxX);
|
|
19345
|
+
minY = Math.min(minY, componentBounds.minY);
|
|
19346
|
+
maxY = Math.max(maxY, componentBounds.maxY);
|
|
19347
|
+
}
|
|
19348
|
+
const marginLeft = groupInstance?._parsedProps?.schMarginLeft ?? groupInstance?._parsedProps?.schMarginX ?? 0;
|
|
19349
|
+
const marginRight = groupInstance?._parsedProps?.schMarginRight ?? groupInstance?._parsedProps?.schMarginX ?? 0;
|
|
19350
|
+
const marginTop = groupInstance?._parsedProps?.schMarginTop ?? groupInstance?._parsedProps?.schMarginY ?? 0;
|
|
19351
|
+
const marginBottom = groupInstance?._parsedProps?.schMarginBottom ?? groupInstance?._parsedProps?.schMarginY ?? 0;
|
|
19352
|
+
const contentCenter = hasValidBounds ? { x: (minX + maxX) / 2, y: (minY + maxY) / 2 } : schematicGroup.center ?? { x: 0, y: 0 };
|
|
19353
|
+
return {
|
|
19354
|
+
center: {
|
|
19355
|
+
x: contentCenter.x + (marginRight - marginLeft) / 2,
|
|
19356
|
+
y: contentCenter.y + (marginTop - marginBottom) / 2
|
|
19357
|
+
},
|
|
19358
|
+
size: {
|
|
19359
|
+
x: (hasValidBounds ? maxX - minX : 2) + marginLeft + marginRight,
|
|
19360
|
+
y: (hasValidBounds ? maxY - minY : 2) + marginTop + marginBottom
|
|
19361
|
+
}
|
|
19362
|
+
};
|
|
19363
|
+
}
|
|
19321
19364
|
function isTreeChildExplicitlyPositioned(treeChild, group) {
|
|
19322
19365
|
if (treeChild.nodeType === "component" && treeChild.sourceComponent) {
|
|
19323
19366
|
const component = group.children.find(
|
|
@@ -19353,6 +19396,7 @@ function convertTreeToMatchPackInputProblem(tree, db, group) {
|
|
|
19353
19396
|
decouplingCapsGap: 0.4,
|
|
19354
19397
|
partitionGap: 1.2
|
|
19355
19398
|
};
|
|
19399
|
+
const nestedGroupMatchpackProxyMap = {};
|
|
19356
19400
|
const groupOffset = group._getGlobalSchematicPositionBeforeLayout();
|
|
19357
19401
|
debug6(
|
|
19358
19402
|
`[${group.name}] Processing ${tree.childNodes.length} child nodes for input problem`
|
|
@@ -19464,38 +19508,15 @@ function convertTreeToMatchPackInputProblem(tree, db, group) {
|
|
|
19464
19508
|
`[${group.name}] Group ${groupId} has ${groupComponents.length} components:`,
|
|
19465
19509
|
groupComponents.map((c) => c.source_component_id)
|
|
19466
19510
|
);
|
|
19467
|
-
|
|
19468
|
-
|
|
19469
|
-
|
|
19470
|
-
|
|
19471
|
-
|
|
19472
|
-
|
|
19473
|
-
|
|
19474
|
-
hasValidBounds = true;
|
|
19475
|
-
const compBounds = getSchematicComponentWithTextBounds({
|
|
19476
|
-
db,
|
|
19477
|
-
schematicComponent: comp
|
|
19478
|
-
}) ?? getBoundFromCenteredRect2({
|
|
19479
|
-
center: comp.center,
|
|
19480
|
-
width: comp.size.width,
|
|
19481
|
-
height: comp.size.height
|
|
19482
|
-
});
|
|
19483
|
-
minX = Math.min(minX, compBounds.minX);
|
|
19484
|
-
maxX = Math.max(maxX, compBounds.maxX);
|
|
19485
|
-
minY = Math.min(minY, compBounds.minY);
|
|
19486
|
-
maxY = Math.max(maxY, compBounds.maxY);
|
|
19487
|
-
}
|
|
19488
|
-
}
|
|
19489
|
-
const marginLeft = groupInstance?._parsedProps?.schMarginLeft ?? groupInstance?._parsedProps?.schMarginX ?? 0;
|
|
19490
|
-
const marginRight = groupInstance?._parsedProps?.schMarginRight ?? groupInstance?._parsedProps?.schMarginX ?? 0;
|
|
19491
|
-
const marginTop = groupInstance?._parsedProps?.schMarginTop ?? groupInstance?._parsedProps?.schMarginY ?? 0;
|
|
19492
|
-
const marginBottom = groupInstance?._parsedProps?.schMarginBottom ?? groupInstance?._parsedProps?.schMarginY ?? 0;
|
|
19493
|
-
const marginXShift = (marginRight - marginLeft) / 2;
|
|
19494
|
-
const marginYShift = (marginTop - marginBottom) / 2;
|
|
19495
|
-
const groupWidth = (hasValidBounds ? maxX - minX : 2) + marginLeft + marginRight;
|
|
19496
|
-
const groupHeight = (hasValidBounds ? maxY - minY : 2) + marginTop + marginBottom;
|
|
19511
|
+
const matchpackProxy = getNestedGroupMatchpackProxy({
|
|
19512
|
+
db,
|
|
19513
|
+
schematicGroup,
|
|
19514
|
+
groupComponents,
|
|
19515
|
+
groupInstance
|
|
19516
|
+
});
|
|
19517
|
+
nestedGroupMatchpackProxyMap[groupId] = matchpackProxy;
|
|
19497
19518
|
debug6(
|
|
19498
|
-
`[${group.name}] Group ${groupId} computed
|
|
19519
|
+
`[${group.name}] Group ${groupId} computed proxy: ${matchpackProxy.size.x} x ${matchpackProxy.size.y} centered at (${matchpackProxy.center.x}, ${matchpackProxy.center.y})`
|
|
19499
19520
|
);
|
|
19500
19521
|
const groupPins = [];
|
|
19501
19522
|
for (const comp of groupComponents) {
|
|
@@ -19507,13 +19528,12 @@ function convertTreeToMatchPackInputProblem(tree, db, group) {
|
|
|
19507
19528
|
if (!sourcePort) continue;
|
|
19508
19529
|
const pinId = `${groupId}.${sourcePort.pin_number || sourcePort.name || port.schematic_port_id}`;
|
|
19509
19530
|
groupPins.push(pinId);
|
|
19510
|
-
const groupCenter = schematicGroup.center || { x: 0, y: 0 };
|
|
19511
19531
|
const side = facingDirectionToSide(port.facing_direction);
|
|
19512
19532
|
problem.chipPinMap[pinId] = {
|
|
19513
19533
|
pinId,
|
|
19514
19534
|
offset: {
|
|
19515
|
-
x: (port.center?.x || 0) -
|
|
19516
|
-
y: (port.center?.y || 0) -
|
|
19535
|
+
x: (port.center?.x || 0) - matchpackProxy.center.x,
|
|
19536
|
+
y: (port.center?.y || 0) - matchpackProxy.center.y
|
|
19517
19537
|
},
|
|
19518
19538
|
side
|
|
19519
19539
|
};
|
|
@@ -19526,10 +19546,7 @@ function convertTreeToMatchPackInputProblem(tree, db, group) {
|
|
|
19526
19546
|
problem.chipMap[groupId] = {
|
|
19527
19547
|
chipId: groupId,
|
|
19528
19548
|
pins: groupPins,
|
|
19529
|
-
size:
|
|
19530
|
-
x: groupWidth,
|
|
19531
|
-
y: groupHeight
|
|
19532
|
-
}
|
|
19549
|
+
size: matchpackProxy.size
|
|
19533
19550
|
};
|
|
19534
19551
|
debug6(`[${group.name}] Added group ${groupId} to chipMap`);
|
|
19535
19552
|
} else {
|
|
@@ -19681,7 +19698,7 @@ function convertTreeToMatchPackInputProblem(tree, db, group) {
|
|
|
19681
19698
|
);
|
|
19682
19699
|
}
|
|
19683
19700
|
}
|
|
19684
|
-
return problem;
|
|
19701
|
+
return { inputProblem: problem, nestedGroupMatchpackProxyMap };
|
|
19685
19702
|
}
|
|
19686
19703
|
function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
19687
19704
|
const { db } = group.root;
|
|
@@ -19696,7 +19713,7 @@ function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
|
19696
19713
|
return;
|
|
19697
19714
|
}
|
|
19698
19715
|
debug6("Converting circuit tree to InputProblem...");
|
|
19699
|
-
const inputProblem = convertTreeToMatchPackInputProblem(tree, db, group);
|
|
19716
|
+
const { inputProblem, nestedGroupMatchpackProxyMap } = convertTreeToMatchPackInputProblem(tree, db, group);
|
|
19700
19717
|
if (debug6.enabled) {
|
|
19701
19718
|
group.root?.emit("debug:logOutput", {
|
|
19702
19719
|
type: "debug:logOutput",
|
|
@@ -19870,7 +19887,8 @@ function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
|
19870
19887
|
debug6(
|
|
19871
19888
|
`Group ${chipId} has ${groupComponents.length} components to move`
|
|
19872
19889
|
);
|
|
19873
|
-
const
|
|
19890
|
+
const matchpackProxy = nestedGroupMatchpackProxyMap[chipId];
|
|
19891
|
+
const oldCenter = matchpackProxy?.center ?? schematicGroup.center ?? { x: 0, y: 0 };
|
|
19874
19892
|
const positionDelta = {
|
|
19875
19893
|
x: newCenter.x - oldCenter.x,
|
|
19876
19894
|
y: newCenter.y - oldCenter.y
|
|
@@ -19904,9 +19922,19 @@ function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
|
19904
19922
|
text.position.y += positionDelta.y;
|
|
19905
19923
|
}
|
|
19906
19924
|
}
|
|
19925
|
+
updateSchematicPrimitivesForLayoutShift({
|
|
19926
|
+
db,
|
|
19927
|
+
schematicComponentId: component.schematic_component_id,
|
|
19928
|
+
deltaX: positionDelta.x,
|
|
19929
|
+
deltaY: positionDelta.y
|
|
19930
|
+
});
|
|
19907
19931
|
}
|
|
19908
19932
|
}
|
|
19909
19933
|
schematicGroup.center = newCenter;
|
|
19934
|
+
if (matchpackProxy) {
|
|
19935
|
+
schematicGroup.width = matchpackProxy.size.x;
|
|
19936
|
+
schematicGroup.height = matchpackProxy.size.y;
|
|
19937
|
+
}
|
|
19910
19938
|
debug6(
|
|
19911
19939
|
`Updated group ${chipId} center to (${newCenter.x}, ${newCenter.y})`
|
|
19912
19940
|
);
|
|
@@ -22487,7 +22515,7 @@ function Group_getRoutingPhasePlans(group) {
|
|
|
22487
22515
|
var package_default = {
|
|
22488
22516
|
name: "@tscircuit/core",
|
|
22489
22517
|
type: "module",
|
|
22490
|
-
version: "0.0.
|
|
22518
|
+
version: "0.0.1436",
|
|
22491
22519
|
types: "dist/index.d.ts",
|
|
22492
22520
|
main: "dist/index.js",
|
|
22493
22521
|
module: "dist/index.js",
|