@tscircuit/core 0.0.1435 → 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 +92 -53
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ __export(components_exports, {
|
|
|
39
39
|
Fiducial: () => Fiducial,
|
|
40
40
|
Footprint: () => Footprint,
|
|
41
41
|
Fuse: () => Fuse,
|
|
42
|
-
Group: () =>
|
|
42
|
+
Group: () => Group,
|
|
43
43
|
Hole: () => Hole,
|
|
44
44
|
Inductor: () => Inductor,
|
|
45
45
|
Interconnect: () => Interconnect,
|
|
@@ -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
|
);
|
|
@@ -20318,8 +20346,19 @@ var SCHEMATIC_RAIL_NET_LABEL_HEIGHT = 0.42;
|
|
|
20318
20346
|
function createSchematicTraceSolverInputProblem(group) {
|
|
20319
20347
|
const { db } = group.root;
|
|
20320
20348
|
const connKeyToSourceNet = /* @__PURE__ */ new Map();
|
|
20321
|
-
const
|
|
20322
|
-
const
|
|
20349
|
+
const childGroups = [];
|
|
20350
|
+
const componentsToVisit = [...group.children].reverse();
|
|
20351
|
+
while (componentsToVisit.length > 0) {
|
|
20352
|
+
const child = componentsToVisit.pop();
|
|
20353
|
+
if (child instanceof Group) {
|
|
20354
|
+
if (child.isSubcircuit) {
|
|
20355
|
+
if (child._parsedProps.showAsSchematicBox) childGroups.push(child);
|
|
20356
|
+
continue;
|
|
20357
|
+
}
|
|
20358
|
+
childGroups.push(child);
|
|
20359
|
+
}
|
|
20360
|
+
componentsToVisit.push(...[...child.children].reverse());
|
|
20361
|
+
}
|
|
20323
20362
|
const allSchematicGroupIds = [
|
|
20324
20363
|
group.schematic_group_id,
|
|
20325
20364
|
...childGroups.map((a) => a.schematic_group_id)
|
|
@@ -22476,7 +22515,7 @@ function Group_getRoutingPhasePlans(group) {
|
|
|
22476
22515
|
var package_default = {
|
|
22477
22516
|
name: "@tscircuit/core",
|
|
22478
22517
|
type: "module",
|
|
22479
|
-
version: "0.0.
|
|
22518
|
+
version: "0.0.1436",
|
|
22480
22519
|
types: "dist/index.d.ts",
|
|
22481
22520
|
main: "dist/index.js",
|
|
22482
22521
|
module: "dist/index.js",
|
|
@@ -23505,7 +23544,7 @@ var ensureRouteStartsAtSourceTraceStart = ({
|
|
|
23505
23544
|
const lastPoint = route[route.length - 1];
|
|
23506
23545
|
return getDistanceToPoint(lastPoint, firstPcbPort) < getDistanceToPoint(firstPoint, firstPcbPort) ? reversePcbTraceRoute(route) : route;
|
|
23507
23546
|
};
|
|
23508
|
-
var
|
|
23547
|
+
var Group = class extends NormalComponent3 {
|
|
23509
23548
|
pcb_group_id = null;
|
|
23510
23549
|
schematic_group_id = null;
|
|
23511
23550
|
subcircuit_id = null;
|
|
@@ -24918,7 +24957,7 @@ function inflateSourceGroup(sourceGroup, inflatorContext) {
|
|
|
24918
24957
|
if (pcbGroup?.anchor_alignment) {
|
|
24919
24958
|
groupProps2.pcbAnchorAlignment = pcbGroup.anchor_alignment;
|
|
24920
24959
|
}
|
|
24921
|
-
const group = new
|
|
24960
|
+
const group = new Group(groupProps2);
|
|
24922
24961
|
group._isInflatedFromCircuitJson = true;
|
|
24923
24962
|
group.source_group_id = sourceGroup.source_group_id;
|
|
24924
24963
|
if (groupsMap) {
|
|
@@ -26086,7 +26125,7 @@ var IsolatedCircuit = class {
|
|
|
26086
26125
|
this.firstChild = this.children[0];
|
|
26087
26126
|
return;
|
|
26088
26127
|
}
|
|
26089
|
-
const group = new
|
|
26128
|
+
const group = new Group({ subcircuit: true });
|
|
26090
26129
|
group.parent = this;
|
|
26091
26130
|
group.addAll(this.children);
|
|
26092
26131
|
this.children = [group];
|
|
@@ -26492,7 +26531,7 @@ var getRoundedRectOutline = (width, height, radius) => {
|
|
|
26492
26531
|
}
|
|
26493
26532
|
return outline;
|
|
26494
26533
|
};
|
|
26495
|
-
var Board = class extends
|
|
26534
|
+
var Board = class extends Group {
|
|
26496
26535
|
pcb_board_id = null;
|
|
26497
26536
|
source_board_id = null;
|
|
26498
26537
|
_drcChecksComplete = false;
|
|
@@ -26956,7 +26995,7 @@ import { mountedboardProps } from "@tscircuit/props";
|
|
|
26956
26995
|
|
|
26957
26996
|
// lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
|
|
26958
26997
|
import "@tscircuit/props";
|
|
26959
|
-
var Subcircuit = class extends
|
|
26998
|
+
var Subcircuit = class extends Group {
|
|
26960
26999
|
constructor(props) {
|
|
26961
27000
|
super({
|
|
26962
27001
|
...props,
|
|
@@ -27528,7 +27567,7 @@ function getItemDimensions(item, db) {
|
|
|
27528
27567
|
}
|
|
27529
27568
|
|
|
27530
27569
|
// lib/components/normal-components/Subpanel.ts
|
|
27531
|
-
var Subpanel = class _Subpanel extends
|
|
27570
|
+
var Subpanel = class _Subpanel extends Group {
|
|
27532
27571
|
pcb_panel_id = null;
|
|
27533
27572
|
_tabsAndMouseBitesGenerated = false;
|
|
27534
27573
|
get config() {
|
|
@@ -30151,7 +30190,7 @@ var createBreakoutPointSolverInput = (breakout) => {
|
|
|
30151
30190
|
};
|
|
30152
30191
|
|
|
30153
30192
|
// lib/components/primitive-components/Breakout/Breakout.ts
|
|
30154
|
-
var Breakout = class extends
|
|
30193
|
+
var Breakout = class extends Group {
|
|
30155
30194
|
constructor(props) {
|
|
30156
30195
|
super({
|
|
30157
30196
|
...props,
|
|
@@ -33410,7 +33449,7 @@ export {
|
|
|
33410
33449
|
Fiducial,
|
|
33411
33450
|
Footprint,
|
|
33412
33451
|
Fuse,
|
|
33413
|
-
|
|
33452
|
+
Group,
|
|
33414
33453
|
Hole,
|
|
33415
33454
|
Inductor,
|
|
33416
33455
|
Interconnect,
|