@tscircuit/core 0.0.1288 → 0.0.1289
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 +3 -1
- package/dist/index.js +247 -30
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1498,6 +1498,7 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
|
|
|
1498
1498
|
getInheritedProperty(propertyName: string): any;
|
|
1499
1499
|
getInheritedMergedProperty(propertyName: string): any;
|
|
1500
1500
|
getResolvedPcbSx(): PcbSx;
|
|
1501
|
+
getSchematicSectionName(): string | null;
|
|
1501
1502
|
get lowercaseComponentName(): string;
|
|
1502
1503
|
externallyAddedAliases: string[];
|
|
1503
1504
|
/**
|
|
@@ -2389,6 +2390,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
|
|
|
2389
2390
|
doInitialSchematicComponentRender(): void;
|
|
2390
2391
|
_getSchematicLayoutMode(): "match-adapt" | "flex" | "grid" | "relative";
|
|
2391
2392
|
doInitialSchematicLayout(): void;
|
|
2393
|
+
_doInitialSchematicLayoutSections(): void;
|
|
2392
2394
|
_doInitialSchematicLayoutMatchAdapt(): void;
|
|
2393
2395
|
_doInitialSchematicLayoutMatchpack(): void;
|
|
2394
2396
|
_doInitialSchematicLayoutGrid(): void;
|
|
@@ -147791,7 +147793,7 @@ declare class SchematicSection extends PrimitiveComponent<typeof schematicSectio
|
|
|
147791
147793
|
sectionTitleFontSize?: string | number | undefined;
|
|
147792
147794
|
}>;
|
|
147793
147795
|
};
|
|
147794
|
-
_computeSectionBounds(board: PrimitiveComponent): Bounds | null;
|
|
147796
|
+
_computeSectionBounds(board: PrimitiveComponent, sectionName: string | null): Bounds | null;
|
|
147795
147797
|
doInitialSchematicSectionRender(): void;
|
|
147796
147798
|
}
|
|
147797
147799
|
|
package/dist/index.js
CHANGED
|
@@ -1275,6 +1275,9 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
1275
1275
|
ownPcbSx: this._parsedProps?.pcbSx
|
|
1276
1276
|
});
|
|
1277
1277
|
}
|
|
1278
|
+
getSchematicSectionName() {
|
|
1279
|
+
return this._parsedProps?.schSectionName ?? null;
|
|
1280
|
+
}
|
|
1278
1281
|
get lowercaseComponentName() {
|
|
1279
1282
|
return this.componentName.toLowerCase();
|
|
1280
1283
|
}
|
|
@@ -16685,18 +16688,16 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
16685
16688
|
const subtreeCircuitJson = buildSubtree(db.toArray(), {
|
|
16686
16689
|
source_group_id: group.source_group_id
|
|
16687
16690
|
});
|
|
16688
|
-
const
|
|
16691
|
+
const shouldSkip = subtreeCircuitJson.filter((item) => item.type === "source_component").length <= 1;
|
|
16692
|
+
if (shouldSkip) return;
|
|
16693
|
+
const floatingGraph = convertCircuitJsonToBpc(subtreeCircuitJson);
|
|
16689
16694
|
if (debug5.enabled && global?.debugGraphics) {
|
|
16690
16695
|
global.debugGraphics?.push(
|
|
16691
|
-
getGraphicsForBpcGraph(
|
|
16696
|
+
getGraphicsForBpcGraph(floatingGraph, {
|
|
16692
16697
|
title: `floatingBpcGraph-${group.name}`
|
|
16693
16698
|
})
|
|
16694
16699
|
);
|
|
16695
16700
|
}
|
|
16696
|
-
const floatingGraph = convertCircuitJsonToBpc(
|
|
16697
|
-
subtreeCircuitJson
|
|
16698
|
-
// .concat(implicitNetLabels),
|
|
16699
|
-
);
|
|
16700
16701
|
const floatingGraphNoNotConnected = {
|
|
16701
16702
|
boxes: floatingGraph.boxes,
|
|
16702
16703
|
pins: floatingGraph.pins.map((p) => ({
|
|
@@ -16801,9 +16802,10 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
16801
16802
|
}
|
|
16802
16803
|
|
|
16803
16804
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts
|
|
16804
|
-
import {
|
|
16805
|
-
|
|
16806
|
-
|
|
16805
|
+
import { getCircuitJsonTree as getCircuitJsonTree2 } from "@tscircuit/circuit-json-util";
|
|
16806
|
+
|
|
16807
|
+
// lib/components/primitive-components/Group/applySchematicMatchPackLayoutToTree.ts
|
|
16808
|
+
import "@tscircuit/circuit-json-util";
|
|
16807
16809
|
import { LayoutPipelineSolver } from "@tscircuit/matchpack";
|
|
16808
16810
|
import Debug8 from "debug";
|
|
16809
16811
|
var debug6 = Debug8("Group_doInitialSchematicLayoutMatchpack");
|
|
@@ -16858,7 +16860,7 @@ function getTreeChildChipId(child, index) {
|
|
|
16858
16860
|
}
|
|
16859
16861
|
return null;
|
|
16860
16862
|
}
|
|
16861
|
-
function
|
|
16863
|
+
function convertTreeToMatchPackInputProblem(tree, db, group) {
|
|
16862
16864
|
const problem = {
|
|
16863
16865
|
chipMap: {},
|
|
16864
16866
|
chipPinMap: {},
|
|
@@ -17184,11 +17186,8 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
17184
17186
|
}
|
|
17185
17187
|
return problem;
|
|
17186
17188
|
}
|
|
17187
|
-
function
|
|
17189
|
+
function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
17188
17190
|
const { db } = group.root;
|
|
17189
|
-
const tree = getCircuitJsonTree2(db.toArray(), {
|
|
17190
|
-
source_group_id: group.source_group_id
|
|
17191
|
-
});
|
|
17192
17191
|
debug6(
|
|
17193
17192
|
`[${group.name}] Starting matchpack layout with ${tree.childNodes.length} children`
|
|
17194
17193
|
);
|
|
@@ -17200,7 +17199,7 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
17200
17199
|
return;
|
|
17201
17200
|
}
|
|
17202
17201
|
debug6("Converting circuit tree to InputProblem...");
|
|
17203
|
-
const inputProblem =
|
|
17202
|
+
const inputProblem = convertTreeToMatchPackInputProblem(tree, db, group);
|
|
17204
17203
|
if (debug6.enabled) {
|
|
17205
17204
|
group.root?.emit("debug:logOutput", {
|
|
17206
17205
|
type: "debug:logOutput",
|
|
@@ -17355,8 +17354,8 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
17355
17354
|
}
|
|
17356
17355
|
const schematicSymbolOrientation = schematicComponent.symbol_name.match(/_(horz|vert)$/);
|
|
17357
17356
|
if (schematicSymbolOrientation) {
|
|
17358
|
-
const
|
|
17359
|
-
const shouldSwapOrientation =
|
|
17357
|
+
const normalizedRot = (placement.ccwRotationDegrees % 360 + 360) % 360;
|
|
17358
|
+
const shouldSwapOrientation = normalizedRot === 90 || normalizedRot === 270;
|
|
17360
17359
|
if (shouldSwapOrientation) {
|
|
17361
17360
|
schematicComponent.symbol_name = schematicComponent.symbol_name.replace(
|
|
17362
17361
|
schematicSymbolOrientation[0],
|
|
@@ -17427,6 +17426,188 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
17427
17426
|
debug6("Matchpack layout completed successfully");
|
|
17428
17427
|
}
|
|
17429
17428
|
|
|
17429
|
+
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts
|
|
17430
|
+
function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
17431
|
+
const { db } = group.root;
|
|
17432
|
+
const tree = getCircuitJsonTree2(db.toArray(), {
|
|
17433
|
+
source_group_id: group.source_group_id
|
|
17434
|
+
});
|
|
17435
|
+
applySchematicMatchPackLayoutToTree(group, tree);
|
|
17436
|
+
}
|
|
17437
|
+
|
|
17438
|
+
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutSections.ts
|
|
17439
|
+
import { getCircuitJsonTree as getCircuitJsonTree3 } from "@tscircuit/circuit-json-util";
|
|
17440
|
+
|
|
17441
|
+
// lib/components/primitive-components/Group/computeSchematicSectionLayoutUsingRows.ts
|
|
17442
|
+
var SECTION_GAP = 1;
|
|
17443
|
+
var MARGIN = 1.5;
|
|
17444
|
+
function computeSchematicSectionLayoutUsingRows({
|
|
17445
|
+
sectionBlocks,
|
|
17446
|
+
groupSchPositionBeforeLayout: groupOffset
|
|
17447
|
+
}) {
|
|
17448
|
+
const totalArea = sectionBlocks.reduce((sum, block) => {
|
|
17449
|
+
const paddedWidth = Math.max(block.size.x, 0.5) + MARGIN * 2;
|
|
17450
|
+
const paddedHeight = Math.max(block.size.y, 0.5) + MARGIN * 2;
|
|
17451
|
+
return sum + paddedWidth * paddedHeight;
|
|
17452
|
+
}, 0);
|
|
17453
|
+
const targetRowWidth = Math.sqrt(totalArea) * 2;
|
|
17454
|
+
const computedSectionsMatrix = [];
|
|
17455
|
+
let currentSectionRow = [];
|
|
17456
|
+
let currentRowSectionWidth = 0;
|
|
17457
|
+
for (const section of sectionBlocks) {
|
|
17458
|
+
const paddedWidth = Math.max(section.size.x, 0.5) + MARGIN * 2;
|
|
17459
|
+
const paddedHeight = Math.max(section.size.y, 0.5) + MARGIN * 2;
|
|
17460
|
+
const neededWidth = currentRowSectionWidth > 0 ? currentRowSectionWidth + SECTION_GAP + paddedWidth : paddedWidth;
|
|
17461
|
+
if (currentSectionRow.length > 0 && neededWidth > targetRowWidth) {
|
|
17462
|
+
computedSectionsMatrix.push(currentSectionRow);
|
|
17463
|
+
currentSectionRow = [];
|
|
17464
|
+
currentRowSectionWidth = 0;
|
|
17465
|
+
}
|
|
17466
|
+
const xOffsetInRow = currentRowSectionWidth > 0 ? currentRowSectionWidth + SECTION_GAP : 0;
|
|
17467
|
+
currentSectionRow.push({
|
|
17468
|
+
sectionName: section.sectionName,
|
|
17469
|
+
rowOffset: xOffsetInRow,
|
|
17470
|
+
width: paddedWidth,
|
|
17471
|
+
height: paddedHeight
|
|
17472
|
+
});
|
|
17473
|
+
currentRowSectionWidth = xOffsetInRow + paddedWidth;
|
|
17474
|
+
}
|
|
17475
|
+
if (currentSectionRow.length > 0)
|
|
17476
|
+
computedSectionsMatrix.push(currentSectionRow);
|
|
17477
|
+
const sectionPlacements = /* @__PURE__ */ new Map();
|
|
17478
|
+
let rowY = 0;
|
|
17479
|
+
for (const sectionRow of computedSectionsMatrix) {
|
|
17480
|
+
const rowHeight = Math.max(...sectionRow.map((rowEntry) => rowEntry.height));
|
|
17481
|
+
const rowWidth = sectionRow[sectionRow.length - 1].rowOffset + sectionRow[sectionRow.length - 1].width;
|
|
17482
|
+
const rowCenteringOffsetX = -rowWidth / 2;
|
|
17483
|
+
for (const section of sectionRow) {
|
|
17484
|
+
sectionPlacements.set(section.sectionName, {
|
|
17485
|
+
x: rowCenteringOffsetX + section.rowOffset + section.width / 2 + groupOffset.x,
|
|
17486
|
+
y: rowY - rowHeight / 2 + groupOffset.y
|
|
17487
|
+
});
|
|
17488
|
+
}
|
|
17489
|
+
rowY -= rowHeight + SECTION_GAP;
|
|
17490
|
+
}
|
|
17491
|
+
return sectionPlacements;
|
|
17492
|
+
}
|
|
17493
|
+
|
|
17494
|
+
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutSections.ts
|
|
17495
|
+
function Group_doInitialSchematicLayoutSections(group) {
|
|
17496
|
+
const { db } = group.root;
|
|
17497
|
+
const sectionNamesUsedByChildren = /* @__PURE__ */ new Set();
|
|
17498
|
+
let hasChildrenWithoutSection = false;
|
|
17499
|
+
for (const child of group.children) {
|
|
17500
|
+
if (!child.source_component_id) continue;
|
|
17501
|
+
const sectionName = child.getSchematicSectionName();
|
|
17502
|
+
if (sectionName !== null) {
|
|
17503
|
+
sectionNamesUsedByChildren.add(sectionName);
|
|
17504
|
+
} else {
|
|
17505
|
+
hasChildrenWithoutSection = true;
|
|
17506
|
+
}
|
|
17507
|
+
}
|
|
17508
|
+
const sectionNamesToLayout = Array.from(
|
|
17509
|
+
sectionNamesUsedByChildren
|
|
17510
|
+
);
|
|
17511
|
+
if (hasChildrenWithoutSection) sectionNamesToLayout.push(null);
|
|
17512
|
+
if (sectionNamesToLayout.length === 0) return;
|
|
17513
|
+
for (const sectionName of sectionNamesToLayout) {
|
|
17514
|
+
const sectionTree = getCircuitJsonTree3(db.toArray(), {
|
|
17515
|
+
source_group_id: group.source_group_id
|
|
17516
|
+
});
|
|
17517
|
+
sectionTree.childNodes = sectionTree.childNodes.filter((child) => {
|
|
17518
|
+
if (child.nodeType !== "component" || !child.sourceComponent) return false;
|
|
17519
|
+
const component = group.children.find(
|
|
17520
|
+
(c) => c.source_component_id === child.sourceComponent?.source_component_id
|
|
17521
|
+
);
|
|
17522
|
+
const compSection = component?.getSchematicSectionName() ?? null;
|
|
17523
|
+
return compSection === sectionName;
|
|
17524
|
+
});
|
|
17525
|
+
applySchematicMatchPackLayoutToTree(group, sectionTree);
|
|
17526
|
+
}
|
|
17527
|
+
if (sectionNamesToLayout.length <= 1) return;
|
|
17528
|
+
const sectionNameToBoundsWithChildren = /* @__PURE__ */ new Map();
|
|
17529
|
+
for (const sectionName of sectionNamesToLayout) {
|
|
17530
|
+
let minX = Infinity;
|
|
17531
|
+
let maxX = -Infinity;
|
|
17532
|
+
let minY = Infinity;
|
|
17533
|
+
let maxY = -Infinity;
|
|
17534
|
+
const sourceCompIds = /* @__PURE__ */ new Set();
|
|
17535
|
+
for (const child of group.children) {
|
|
17536
|
+
const sourceComponentId = child.source_component_id;
|
|
17537
|
+
if (!sourceComponentId) continue;
|
|
17538
|
+
const compSectionName = child.getSchematicSectionName();
|
|
17539
|
+
if (compSectionName !== sectionName) continue;
|
|
17540
|
+
const schComp = db.schematic_component.getWhere({
|
|
17541
|
+
source_component_id: sourceComponentId
|
|
17542
|
+
});
|
|
17543
|
+
if (!schComp) continue;
|
|
17544
|
+
sourceCompIds.add(sourceComponentId);
|
|
17545
|
+
const hw = schComp.size.width / 2;
|
|
17546
|
+
const hh = schComp.size.height / 2;
|
|
17547
|
+
minX = Math.min(minX, schComp.center.x - hw);
|
|
17548
|
+
maxX = Math.max(maxX, schComp.center.x + hw);
|
|
17549
|
+
minY = Math.min(minY, schComp.center.y - hh);
|
|
17550
|
+
maxY = Math.max(maxY, schComp.center.y + hh);
|
|
17551
|
+
}
|
|
17552
|
+
if (!Number.isFinite(minX) || sourceCompIds.size === 0) continue;
|
|
17553
|
+
sectionNameToBoundsWithChildren.set(sectionName, {
|
|
17554
|
+
sectionName,
|
|
17555
|
+
center: { x: (minX + maxX) / 2, y: (minY + maxY) / 2 },
|
|
17556
|
+
size: { x: maxX - minX, y: maxY - minY },
|
|
17557
|
+
sourceCompIds
|
|
17558
|
+
});
|
|
17559
|
+
}
|
|
17560
|
+
if (sectionNameToBoundsWithChildren.size <= 1) return;
|
|
17561
|
+
const groupSchPositionBeforeLayout = group._getGlobalSchematicPositionBeforeLayout();
|
|
17562
|
+
const sectionPlacements = computeSchematicSectionLayoutUsingRows({
|
|
17563
|
+
sectionBlocks: Array.from(sectionNameToBoundsWithChildren.values()).map(
|
|
17564
|
+
(bounds) => ({
|
|
17565
|
+
sectionName: bounds.sectionName,
|
|
17566
|
+
size: bounds.size
|
|
17567
|
+
})
|
|
17568
|
+
),
|
|
17569
|
+
groupSchPositionBeforeLayout
|
|
17570
|
+
});
|
|
17571
|
+
for (const [sectionName, placement] of sectionPlacements) {
|
|
17572
|
+
const boundsWithChildren = sectionNameToBoundsWithChildren.get(sectionName);
|
|
17573
|
+
if (!boundsWithChildren) continue;
|
|
17574
|
+
const delta = {
|
|
17575
|
+
x: placement.x - boundsWithChildren.center.x,
|
|
17576
|
+
y: placement.y - boundsWithChildren.center.y
|
|
17577
|
+
};
|
|
17578
|
+
for (const sourceComponentId of boundsWithChildren.sourceCompIds) {
|
|
17579
|
+
const schComp = db.schematic_component.getWhere({
|
|
17580
|
+
source_component_id: sourceComponentId
|
|
17581
|
+
});
|
|
17582
|
+
if (!schComp) continue;
|
|
17583
|
+
const ports = db.schematic_port.list({
|
|
17584
|
+
schematic_component_id: schComp.schematic_component_id
|
|
17585
|
+
});
|
|
17586
|
+
const texts = db.schematic_text.list({
|
|
17587
|
+
schematic_component_id: schComp.schematic_component_id
|
|
17588
|
+
});
|
|
17589
|
+
for (const port of ports) {
|
|
17590
|
+
port.center.x += delta.x;
|
|
17591
|
+
port.center.y += delta.y;
|
|
17592
|
+
}
|
|
17593
|
+
for (const text of texts) {
|
|
17594
|
+
text.position.x += delta.x;
|
|
17595
|
+
text.position.y += delta.y;
|
|
17596
|
+
}
|
|
17597
|
+
updateSchematicPrimitivesForLayoutShift({
|
|
17598
|
+
db,
|
|
17599
|
+
schematicComponentId: schComp.schematic_component_id,
|
|
17600
|
+
deltaX: delta.x,
|
|
17601
|
+
deltaY: delta.y
|
|
17602
|
+
});
|
|
17603
|
+
schComp.center = {
|
|
17604
|
+
x: schComp.center.x + delta.x,
|
|
17605
|
+
y: schComp.center.y + delta.y
|
|
17606
|
+
};
|
|
17607
|
+
}
|
|
17608
|
+
}
|
|
17609
|
+
}
|
|
17610
|
+
|
|
17430
17611
|
// lib/components/primitive-components/Group/Group_doInitialSchematicBoxComponentRender.ts
|
|
17431
17612
|
var parsePinNumberFromPortName = (name) => {
|
|
17432
17613
|
if (!name) return null;
|
|
@@ -20803,6 +20984,18 @@ var Group5 = class extends NormalComponent3 {
|
|
|
20803
20984
|
this._insertSchematicBorder();
|
|
20804
20985
|
return;
|
|
20805
20986
|
}
|
|
20987
|
+
const hasAnySectionName = this.children.some(
|
|
20988
|
+
(c) => c.source_component_id !== null && c._parsedProps?.schSectionName !== void 0
|
|
20989
|
+
);
|
|
20990
|
+
const hasAnyExplicitPosition = this.children.some(
|
|
20991
|
+
(c) => c.source_component_id !== null && (c._parsedProps?.schX !== void 0 || c._parsedProps?.schY !== void 0)
|
|
20992
|
+
);
|
|
20993
|
+
const hasSections = hasAnySectionName && !hasAnyExplicitPosition;
|
|
20994
|
+
if (hasSections) {
|
|
20995
|
+
this._doInitialSchematicLayoutSections();
|
|
20996
|
+
this._insertSchematicBorder();
|
|
20997
|
+
return;
|
|
20998
|
+
}
|
|
20806
20999
|
const schematicLayoutMode = this._getSchematicLayoutMode();
|
|
20807
21000
|
if (schematicLayoutMode === "match-adapt") {
|
|
20808
21001
|
this._doInitialSchematicLayoutMatchpack();
|
|
@@ -20815,6 +21008,9 @@ var Group5 = class extends NormalComponent3 {
|
|
|
20815
21008
|
}
|
|
20816
21009
|
this._insertSchematicBorder();
|
|
20817
21010
|
}
|
|
21011
|
+
_doInitialSchematicLayoutSections() {
|
|
21012
|
+
Group_doInitialSchematicLayoutSections(this);
|
|
21013
|
+
}
|
|
20818
21014
|
_doInitialSchematicLayoutMatchAdapt() {
|
|
20819
21015
|
Group_doInitialSchematicLayoutMatchAdapt(this);
|
|
20820
21016
|
}
|
|
@@ -22044,7 +22240,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
22044
22240
|
var package_default = {
|
|
22045
22241
|
name: "@tscircuit/core",
|
|
22046
22242
|
type: "module",
|
|
22047
|
-
version: "0.0.
|
|
22243
|
+
version: "0.0.1288",
|
|
22048
22244
|
types: "dist/index.d.ts",
|
|
22049
22245
|
main: "dist/index.js",
|
|
22050
22246
|
module: "dist/index.js",
|
|
@@ -22156,7 +22352,7 @@ var package_default = {
|
|
|
22156
22352
|
dependencies: {
|
|
22157
22353
|
"@flatten-js/core": "^1.6.2",
|
|
22158
22354
|
"@lume/kiwi": "^0.4.3",
|
|
22159
|
-
"calculate-cell-boundaries": "^0.0.
|
|
22355
|
+
"calculate-cell-boundaries": "^0.0.13",
|
|
22160
22356
|
"calculate-packing": "0.0.73",
|
|
22161
22357
|
"css-select": "5.1.0",
|
|
22162
22358
|
"format-si-unit": "^0.0.3",
|
|
@@ -28566,10 +28762,10 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
|
|
|
28566
28762
|
zodProps: schematicSectionProps
|
|
28567
28763
|
};
|
|
28568
28764
|
}
|
|
28569
|
-
|
|
28765
|
+
// Pass null to compute bounds for components with no schSectionName
|
|
28766
|
+
_computeSectionBounds(board, sectionName) {
|
|
28570
28767
|
const { db } = this.root;
|
|
28571
|
-
const
|
|
28572
|
-
const members = board.getDescendants().filter((c) => c.props?.schSectionName === name);
|
|
28768
|
+
const members = board.getDescendants().filter((c) => c.getSchematicSectionName() === sectionName);
|
|
28573
28769
|
if (members.length === 0) return null;
|
|
28574
28770
|
const positions = [];
|
|
28575
28771
|
for (const member of members) {
|
|
@@ -28600,11 +28796,15 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
|
|
|
28600
28796
|
const LABEL_PADDING = 0.2;
|
|
28601
28797
|
const STROKE_WIDTH = 0.02;
|
|
28602
28798
|
const TOL3 = 1e-3;
|
|
28603
|
-
const
|
|
28604
|
-
const bounds = section._computeSectionBounds(
|
|
28799
|
+
const namedSectionsWithBounds = allSections.map((section) => {
|
|
28800
|
+
const bounds = section._computeSectionBounds(
|
|
28801
|
+
board,
|
|
28802
|
+
section._parsedProps.name
|
|
28803
|
+
);
|
|
28605
28804
|
if (!bounds) return null;
|
|
28606
28805
|
return {
|
|
28607
|
-
section,
|
|
28806
|
+
displayName: section._parsedProps.displayName,
|
|
28807
|
+
sectionTitleFontSize: section._parsedProps.sectionTitleFontSize,
|
|
28608
28808
|
rawBounds: bounds,
|
|
28609
28809
|
cell: {
|
|
28610
28810
|
minX: bounds.minX - PADDING,
|
|
@@ -28614,12 +28814,26 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
|
|
|
28614
28814
|
}
|
|
28615
28815
|
};
|
|
28616
28816
|
}).filter((s) => s !== null);
|
|
28617
|
-
|
|
28618
|
-
const
|
|
28817
|
+
const unsectionedBounds = this._computeSectionBounds(board, null);
|
|
28818
|
+
const allSectionsWithBounds = [...namedSectionsWithBounds];
|
|
28819
|
+
if (unsectionedBounds)
|
|
28820
|
+
allSectionsWithBounds.push({
|
|
28821
|
+
displayName: void 0,
|
|
28822
|
+
sectionTitleFontSize: void 0,
|
|
28823
|
+
rawBounds: unsectionedBounds,
|
|
28824
|
+
cell: {
|
|
28825
|
+
minX: unsectionedBounds.minX - PADDING,
|
|
28826
|
+
maxX: unsectionedBounds.maxX + PADDING,
|
|
28827
|
+
minY: unsectionedBounds.minY - PADDING,
|
|
28828
|
+
maxY: unsectionedBounds.maxY + PADDING
|
|
28829
|
+
}
|
|
28830
|
+
});
|
|
28831
|
+
if (allSectionsWithBounds.length === 0) return;
|
|
28832
|
+
const allCells = allSectionsWithBounds.map((s) => s.cell);
|
|
28619
28833
|
const outer = computeBoundsFromCellContents(allCells);
|
|
28620
28834
|
const CELL_MARGIN = 1;
|
|
28621
28835
|
const dividers = calculateCellBoundaries(
|
|
28622
|
-
|
|
28836
|
+
allSectionsWithBounds.map((s) => ({
|
|
28623
28837
|
minX: s.rawBounds.minX - CELL_MARGIN,
|
|
28624
28838
|
maxX: s.rawBounds.maxX + CELL_MARGIN,
|
|
28625
28839
|
minY: s.rawBounds.minY - CELL_MARGIN,
|
|
@@ -28643,8 +28857,11 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
|
|
|
28643
28857
|
const vDividers = dividers.filter(
|
|
28644
28858
|
(l) => Math.abs(l.start.x - l.end.x) < TOL3
|
|
28645
28859
|
);
|
|
28646
|
-
for (const {
|
|
28647
|
-
|
|
28860
|
+
for (const {
|
|
28861
|
+
displayName,
|
|
28862
|
+
sectionTitleFontSize,
|
|
28863
|
+
rawBounds
|
|
28864
|
+
} of allSectionsWithBounds) {
|
|
28648
28865
|
if (!displayName) continue;
|
|
28649
28866
|
const dividersAbove = hDividers.map((l) => l.start.y).filter((y) => y > rawBounds.maxY);
|
|
28650
28867
|
const topBoundary = dividersAbove.length > 0 ? Math.min(...dividersAbove) : outer.maxY;
|
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.1289",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"dependencies": {
|
|
114
114
|
"@flatten-js/core": "^1.6.2",
|
|
115
115
|
"@lume/kiwi": "^0.4.3",
|
|
116
|
-
"calculate-cell-boundaries": "^0.0.
|
|
116
|
+
"calculate-cell-boundaries": "^0.0.13",
|
|
117
117
|
"calculate-packing": "0.0.73",
|
|
118
118
|
"css-select": "5.1.0",
|
|
119
119
|
"format-si-unit": "^0.0.3",
|