@tscircuit/core 0.0.1288 → 0.0.1290
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 +4 -1
- package/dist/index.js +260 -46
- 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
|
/**
|
|
@@ -2166,6 +2167,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
2166
2167
|
ignoreSymbolPorts?: boolean;
|
|
2167
2168
|
}): void;
|
|
2168
2169
|
_getImpliedFootprintString(): string | null;
|
|
2170
|
+
resolveFootprint(): any;
|
|
2169
2171
|
_addChildrenFromStringFootprint(): void;
|
|
2170
2172
|
get portMap(): PortMap<PortNames>;
|
|
2171
2173
|
getInstanceForReactElement(element: ReactElement): NormalComponent | null;
|
|
@@ -2389,6 +2391,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
|
|
|
2389
2391
|
doInitialSchematicComponentRender(): void;
|
|
2390
2392
|
_getSchematicLayoutMode(): "match-adapt" | "flex" | "grid" | "relative";
|
|
2391
2393
|
doInitialSchematicLayout(): void;
|
|
2394
|
+
_doInitialSchematicLayoutSections(): void;
|
|
2392
2395
|
_doInitialSchematicLayoutMatchAdapt(): void;
|
|
2393
2396
|
_doInitialSchematicLayoutMatchpack(): void;
|
|
2394
2397
|
_doInitialSchematicLayoutGrid(): void;
|
|
@@ -147791,7 +147794,7 @@ declare class SchematicSection extends PrimitiveComponent<typeof schematicSectio
|
|
|
147791
147794
|
sectionTitleFontSize?: string | number | undefined;
|
|
147792
147795
|
}>;
|
|
147793
147796
|
};
|
|
147794
|
-
_computeSectionBounds(board: PrimitiveComponent): Bounds | null;
|
|
147797
|
+
_computeSectionBounds(board: PrimitiveComponent, sectionName: string | null): Bounds | null;
|
|
147795
147798
|
doInitialSchematicSectionRender(): void;
|
|
147796
147799
|
}
|
|
147797
147800
|
|
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
|
}
|
|
@@ -10850,8 +10853,7 @@ var extractCadModelFromCircuitJson = (circuitJson) => {
|
|
|
10850
10853
|
|
|
10851
10854
|
// lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts
|
|
10852
10855
|
function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
|
|
10853
|
-
|
|
10854
|
-
footprint ??= component._getImpliedFootprintString?.();
|
|
10856
|
+
const footprint = component.resolveFootprint();
|
|
10855
10857
|
if (!footprint) return;
|
|
10856
10858
|
const { pcbRotation, pinLabels, pcbPinLabels } = component.props;
|
|
10857
10859
|
const fileExtension = getFileExtension(String(footprint));
|
|
@@ -11814,10 +11816,13 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
11814
11816
|
_getImpliedFootprintString() {
|
|
11815
11817
|
return null;
|
|
11816
11818
|
}
|
|
11819
|
+
// Override to choose the effective footprint without rewriting user props.
|
|
11820
|
+
resolveFootprint() {
|
|
11821
|
+
return this._parsedProps.footprint ?? this.props.footprint ?? this._getImpliedFootprintString?.();
|
|
11822
|
+
}
|
|
11817
11823
|
_addChildrenFromStringFootprint() {
|
|
11818
11824
|
const { pcbRotation, pinLabels, pcbPinLabels } = this.props;
|
|
11819
|
-
|
|
11820
|
-
footprint ??= this._getImpliedFootprintString?.();
|
|
11825
|
+
const footprint = this.resolveFootprint();
|
|
11821
11826
|
if (!footprint) return;
|
|
11822
11827
|
if (typeof footprint === "string") {
|
|
11823
11828
|
if (isHttpUrl(footprint)) return;
|
|
@@ -12112,7 +12117,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12112
12117
|
obstructs_within_bounds: props.obstructsWithinBounds ?? true,
|
|
12113
12118
|
metadata: props.kicadFootprintMetadata ? { kicad_footprint: props.kicadFootprintMetadata } : void 0
|
|
12114
12119
|
});
|
|
12115
|
-
const footprint =
|
|
12120
|
+
const footprint = this.resolveFootprint();
|
|
12116
12121
|
const hasFootprintChild = this.children.some(
|
|
12117
12122
|
(c) => c.componentName === "Footprint"
|
|
12118
12123
|
);
|
|
@@ -12651,8 +12656,9 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12651
12656
|
return dimensions;
|
|
12652
12657
|
}
|
|
12653
12658
|
getFootprinterString() {
|
|
12654
|
-
|
|
12655
|
-
|
|
12659
|
+
const footprint = this.resolveFootprint();
|
|
12660
|
+
if (typeof footprint === "string") {
|
|
12661
|
+
return footprint;
|
|
12656
12662
|
}
|
|
12657
12663
|
return null;
|
|
12658
12664
|
}
|
|
@@ -12663,11 +12669,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12663
12669
|
const { boardThickness = 0 } = this._getBoard() ?? {};
|
|
12664
12670
|
const cadModelProp2 = this._parsedProps.cadModel;
|
|
12665
12671
|
const cadModel = cadModelProp2 === void 0 ? this._asyncFootprintCadModel : cadModelProp2;
|
|
12666
|
-
const
|
|
12667
|
-
let footprintString;
|
|
12668
|
-
if (typeof footprint === "string") {
|
|
12669
|
-
footprintString = footprint;
|
|
12670
|
-
}
|
|
12672
|
+
const footprintString = this.getFootprinterString() ?? void 0;
|
|
12671
12673
|
let footprintIsFootprinterString = false;
|
|
12672
12674
|
if (footprintString) {
|
|
12673
12675
|
footprintIsFootprinterString = !parseLibraryFootprintRef(footprintString) && !isHttpUrl(footprintString) && !isStaticAssetPath(footprintString);
|
|
@@ -12834,10 +12836,8 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12834
12836
|
const source_component = db.source_component.get(this.source_component_id);
|
|
12835
12837
|
if (!source_component) return;
|
|
12836
12838
|
if (source_component.supplier_part_numbers) return;
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
footprinterString = this.props.footprint;
|
|
12840
|
-
}
|
|
12839
|
+
const footprint = this.props.footprint ?? this._getImpliedFootprintString();
|
|
12840
|
+
const footprinterString = typeof footprint === "string" ? footprint : void 0;
|
|
12841
12841
|
const supplierPartNumbersMaybePromise = this._getSupplierPartNumbers(
|
|
12842
12842
|
partsEngine,
|
|
12843
12843
|
source_component,
|
|
@@ -16685,18 +16685,16 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
16685
16685
|
const subtreeCircuitJson = buildSubtree(db.toArray(), {
|
|
16686
16686
|
source_group_id: group.source_group_id
|
|
16687
16687
|
});
|
|
16688
|
-
const
|
|
16688
|
+
const shouldSkip = subtreeCircuitJson.filter((item) => item.type === "source_component").length <= 1;
|
|
16689
|
+
if (shouldSkip) return;
|
|
16690
|
+
const floatingGraph = convertCircuitJsonToBpc(subtreeCircuitJson);
|
|
16689
16691
|
if (debug5.enabled && global?.debugGraphics) {
|
|
16690
16692
|
global.debugGraphics?.push(
|
|
16691
|
-
getGraphicsForBpcGraph(
|
|
16693
|
+
getGraphicsForBpcGraph(floatingGraph, {
|
|
16692
16694
|
title: `floatingBpcGraph-${group.name}`
|
|
16693
16695
|
})
|
|
16694
16696
|
);
|
|
16695
16697
|
}
|
|
16696
|
-
const floatingGraph = convertCircuitJsonToBpc(
|
|
16697
|
-
subtreeCircuitJson
|
|
16698
|
-
// .concat(implicitNetLabels),
|
|
16699
|
-
);
|
|
16700
16698
|
const floatingGraphNoNotConnected = {
|
|
16701
16699
|
boxes: floatingGraph.boxes,
|
|
16702
16700
|
pins: floatingGraph.pins.map((p) => ({
|
|
@@ -16801,9 +16799,10 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
16801
16799
|
}
|
|
16802
16800
|
|
|
16803
16801
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts
|
|
16804
|
-
import {
|
|
16805
|
-
|
|
16806
|
-
|
|
16802
|
+
import { getCircuitJsonTree as getCircuitJsonTree2 } from "@tscircuit/circuit-json-util";
|
|
16803
|
+
|
|
16804
|
+
// lib/components/primitive-components/Group/applySchematicMatchPackLayoutToTree.ts
|
|
16805
|
+
import "@tscircuit/circuit-json-util";
|
|
16807
16806
|
import { LayoutPipelineSolver } from "@tscircuit/matchpack";
|
|
16808
16807
|
import Debug8 from "debug";
|
|
16809
16808
|
var debug6 = Debug8("Group_doInitialSchematicLayoutMatchpack");
|
|
@@ -16858,7 +16857,7 @@ function getTreeChildChipId(child, index) {
|
|
|
16858
16857
|
}
|
|
16859
16858
|
return null;
|
|
16860
16859
|
}
|
|
16861
|
-
function
|
|
16860
|
+
function convertTreeToMatchPackInputProblem(tree, db, group) {
|
|
16862
16861
|
const problem = {
|
|
16863
16862
|
chipMap: {},
|
|
16864
16863
|
chipPinMap: {},
|
|
@@ -17184,11 +17183,8 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
17184
17183
|
}
|
|
17185
17184
|
return problem;
|
|
17186
17185
|
}
|
|
17187
|
-
function
|
|
17186
|
+
function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
17188
17187
|
const { db } = group.root;
|
|
17189
|
-
const tree = getCircuitJsonTree2(db.toArray(), {
|
|
17190
|
-
source_group_id: group.source_group_id
|
|
17191
|
-
});
|
|
17192
17188
|
debug6(
|
|
17193
17189
|
`[${group.name}] Starting matchpack layout with ${tree.childNodes.length} children`
|
|
17194
17190
|
);
|
|
@@ -17200,7 +17196,7 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
17200
17196
|
return;
|
|
17201
17197
|
}
|
|
17202
17198
|
debug6("Converting circuit tree to InputProblem...");
|
|
17203
|
-
const inputProblem =
|
|
17199
|
+
const inputProblem = convertTreeToMatchPackInputProblem(tree, db, group);
|
|
17204
17200
|
if (debug6.enabled) {
|
|
17205
17201
|
group.root?.emit("debug:logOutput", {
|
|
17206
17202
|
type: "debug:logOutput",
|
|
@@ -17355,8 +17351,8 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
17355
17351
|
}
|
|
17356
17352
|
const schematicSymbolOrientation = schematicComponent.symbol_name.match(/_(horz|vert)$/);
|
|
17357
17353
|
if (schematicSymbolOrientation) {
|
|
17358
|
-
const
|
|
17359
|
-
const shouldSwapOrientation =
|
|
17354
|
+
const normalizedRot = (placement.ccwRotationDegrees % 360 + 360) % 360;
|
|
17355
|
+
const shouldSwapOrientation = normalizedRot === 90 || normalizedRot === 270;
|
|
17360
17356
|
if (shouldSwapOrientation) {
|
|
17361
17357
|
schematicComponent.symbol_name = schematicComponent.symbol_name.replace(
|
|
17362
17358
|
schematicSymbolOrientation[0],
|
|
@@ -17427,6 +17423,188 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
17427
17423
|
debug6("Matchpack layout completed successfully");
|
|
17428
17424
|
}
|
|
17429
17425
|
|
|
17426
|
+
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts
|
|
17427
|
+
function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
17428
|
+
const { db } = group.root;
|
|
17429
|
+
const tree = getCircuitJsonTree2(db.toArray(), {
|
|
17430
|
+
source_group_id: group.source_group_id
|
|
17431
|
+
});
|
|
17432
|
+
applySchematicMatchPackLayoutToTree(group, tree);
|
|
17433
|
+
}
|
|
17434
|
+
|
|
17435
|
+
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutSections.ts
|
|
17436
|
+
import { getCircuitJsonTree as getCircuitJsonTree3 } from "@tscircuit/circuit-json-util";
|
|
17437
|
+
|
|
17438
|
+
// lib/components/primitive-components/Group/computeSchematicSectionLayoutUsingRows.ts
|
|
17439
|
+
var SECTION_GAP = 1;
|
|
17440
|
+
var MARGIN = 1.5;
|
|
17441
|
+
function computeSchematicSectionLayoutUsingRows({
|
|
17442
|
+
sectionBlocks,
|
|
17443
|
+
groupSchPositionBeforeLayout: groupOffset
|
|
17444
|
+
}) {
|
|
17445
|
+
const totalArea = sectionBlocks.reduce((sum, block) => {
|
|
17446
|
+
const paddedWidth = Math.max(block.size.x, 0.5) + MARGIN * 2;
|
|
17447
|
+
const paddedHeight = Math.max(block.size.y, 0.5) + MARGIN * 2;
|
|
17448
|
+
return sum + paddedWidth * paddedHeight;
|
|
17449
|
+
}, 0);
|
|
17450
|
+
const targetRowWidth = Math.sqrt(totalArea) * 2;
|
|
17451
|
+
const computedSectionsMatrix = [];
|
|
17452
|
+
let currentSectionRow = [];
|
|
17453
|
+
let currentRowSectionWidth = 0;
|
|
17454
|
+
for (const section of sectionBlocks) {
|
|
17455
|
+
const paddedWidth = Math.max(section.size.x, 0.5) + MARGIN * 2;
|
|
17456
|
+
const paddedHeight = Math.max(section.size.y, 0.5) + MARGIN * 2;
|
|
17457
|
+
const neededWidth = currentRowSectionWidth > 0 ? currentRowSectionWidth + SECTION_GAP + paddedWidth : paddedWidth;
|
|
17458
|
+
if (currentSectionRow.length > 0 && neededWidth > targetRowWidth) {
|
|
17459
|
+
computedSectionsMatrix.push(currentSectionRow);
|
|
17460
|
+
currentSectionRow = [];
|
|
17461
|
+
currentRowSectionWidth = 0;
|
|
17462
|
+
}
|
|
17463
|
+
const xOffsetInRow = currentRowSectionWidth > 0 ? currentRowSectionWidth + SECTION_GAP : 0;
|
|
17464
|
+
currentSectionRow.push({
|
|
17465
|
+
sectionName: section.sectionName,
|
|
17466
|
+
rowOffset: xOffsetInRow,
|
|
17467
|
+
width: paddedWidth,
|
|
17468
|
+
height: paddedHeight
|
|
17469
|
+
});
|
|
17470
|
+
currentRowSectionWidth = xOffsetInRow + paddedWidth;
|
|
17471
|
+
}
|
|
17472
|
+
if (currentSectionRow.length > 0)
|
|
17473
|
+
computedSectionsMatrix.push(currentSectionRow);
|
|
17474
|
+
const sectionPlacements = /* @__PURE__ */ new Map();
|
|
17475
|
+
let rowY = 0;
|
|
17476
|
+
for (const sectionRow of computedSectionsMatrix) {
|
|
17477
|
+
const rowHeight = Math.max(...sectionRow.map((rowEntry) => rowEntry.height));
|
|
17478
|
+
const rowWidth = sectionRow[sectionRow.length - 1].rowOffset + sectionRow[sectionRow.length - 1].width;
|
|
17479
|
+
const rowCenteringOffsetX = -rowWidth / 2;
|
|
17480
|
+
for (const section of sectionRow) {
|
|
17481
|
+
sectionPlacements.set(section.sectionName, {
|
|
17482
|
+
x: rowCenteringOffsetX + section.rowOffset + section.width / 2 + groupOffset.x,
|
|
17483
|
+
y: rowY - rowHeight / 2 + groupOffset.y
|
|
17484
|
+
});
|
|
17485
|
+
}
|
|
17486
|
+
rowY -= rowHeight + SECTION_GAP;
|
|
17487
|
+
}
|
|
17488
|
+
return sectionPlacements;
|
|
17489
|
+
}
|
|
17490
|
+
|
|
17491
|
+
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutSections.ts
|
|
17492
|
+
function Group_doInitialSchematicLayoutSections(group) {
|
|
17493
|
+
const { db } = group.root;
|
|
17494
|
+
const sectionNamesUsedByChildren = /* @__PURE__ */ new Set();
|
|
17495
|
+
let hasChildrenWithoutSection = false;
|
|
17496
|
+
for (const child of group.children) {
|
|
17497
|
+
if (!child.source_component_id) continue;
|
|
17498
|
+
const sectionName = child.getSchematicSectionName();
|
|
17499
|
+
if (sectionName !== null) {
|
|
17500
|
+
sectionNamesUsedByChildren.add(sectionName);
|
|
17501
|
+
} else {
|
|
17502
|
+
hasChildrenWithoutSection = true;
|
|
17503
|
+
}
|
|
17504
|
+
}
|
|
17505
|
+
const sectionNamesToLayout = Array.from(
|
|
17506
|
+
sectionNamesUsedByChildren
|
|
17507
|
+
);
|
|
17508
|
+
if (hasChildrenWithoutSection) sectionNamesToLayout.push(null);
|
|
17509
|
+
if (sectionNamesToLayout.length === 0) return;
|
|
17510
|
+
for (const sectionName of sectionNamesToLayout) {
|
|
17511
|
+
const sectionTree = getCircuitJsonTree3(db.toArray(), {
|
|
17512
|
+
source_group_id: group.source_group_id
|
|
17513
|
+
});
|
|
17514
|
+
sectionTree.childNodes = sectionTree.childNodes.filter((child) => {
|
|
17515
|
+
if (child.nodeType !== "component" || !child.sourceComponent) return false;
|
|
17516
|
+
const component = group.children.find(
|
|
17517
|
+
(c) => c.source_component_id === child.sourceComponent?.source_component_id
|
|
17518
|
+
);
|
|
17519
|
+
const compSection = component?.getSchematicSectionName() ?? null;
|
|
17520
|
+
return compSection === sectionName;
|
|
17521
|
+
});
|
|
17522
|
+
applySchematicMatchPackLayoutToTree(group, sectionTree);
|
|
17523
|
+
}
|
|
17524
|
+
if (sectionNamesToLayout.length <= 1) return;
|
|
17525
|
+
const sectionNameToBoundsWithChildren = /* @__PURE__ */ new Map();
|
|
17526
|
+
for (const sectionName of sectionNamesToLayout) {
|
|
17527
|
+
let minX = Infinity;
|
|
17528
|
+
let maxX = -Infinity;
|
|
17529
|
+
let minY = Infinity;
|
|
17530
|
+
let maxY = -Infinity;
|
|
17531
|
+
const sourceCompIds = /* @__PURE__ */ new Set();
|
|
17532
|
+
for (const child of group.children) {
|
|
17533
|
+
const sourceComponentId = child.source_component_id;
|
|
17534
|
+
if (!sourceComponentId) continue;
|
|
17535
|
+
const compSectionName = child.getSchematicSectionName();
|
|
17536
|
+
if (compSectionName !== sectionName) continue;
|
|
17537
|
+
const schComp = db.schematic_component.getWhere({
|
|
17538
|
+
source_component_id: sourceComponentId
|
|
17539
|
+
});
|
|
17540
|
+
if (!schComp) continue;
|
|
17541
|
+
sourceCompIds.add(sourceComponentId);
|
|
17542
|
+
const hw = schComp.size.width / 2;
|
|
17543
|
+
const hh = schComp.size.height / 2;
|
|
17544
|
+
minX = Math.min(minX, schComp.center.x - hw);
|
|
17545
|
+
maxX = Math.max(maxX, schComp.center.x + hw);
|
|
17546
|
+
minY = Math.min(minY, schComp.center.y - hh);
|
|
17547
|
+
maxY = Math.max(maxY, schComp.center.y + hh);
|
|
17548
|
+
}
|
|
17549
|
+
if (!Number.isFinite(minX) || sourceCompIds.size === 0) continue;
|
|
17550
|
+
sectionNameToBoundsWithChildren.set(sectionName, {
|
|
17551
|
+
sectionName,
|
|
17552
|
+
center: { x: (minX + maxX) / 2, y: (minY + maxY) / 2 },
|
|
17553
|
+
size: { x: maxX - minX, y: maxY - minY },
|
|
17554
|
+
sourceCompIds
|
|
17555
|
+
});
|
|
17556
|
+
}
|
|
17557
|
+
if (sectionNameToBoundsWithChildren.size <= 1) return;
|
|
17558
|
+
const groupSchPositionBeforeLayout = group._getGlobalSchematicPositionBeforeLayout();
|
|
17559
|
+
const sectionPlacements = computeSchematicSectionLayoutUsingRows({
|
|
17560
|
+
sectionBlocks: Array.from(sectionNameToBoundsWithChildren.values()).map(
|
|
17561
|
+
(bounds) => ({
|
|
17562
|
+
sectionName: bounds.sectionName,
|
|
17563
|
+
size: bounds.size
|
|
17564
|
+
})
|
|
17565
|
+
),
|
|
17566
|
+
groupSchPositionBeforeLayout
|
|
17567
|
+
});
|
|
17568
|
+
for (const [sectionName, placement] of sectionPlacements) {
|
|
17569
|
+
const boundsWithChildren = sectionNameToBoundsWithChildren.get(sectionName);
|
|
17570
|
+
if (!boundsWithChildren) continue;
|
|
17571
|
+
const delta = {
|
|
17572
|
+
x: placement.x - boundsWithChildren.center.x,
|
|
17573
|
+
y: placement.y - boundsWithChildren.center.y
|
|
17574
|
+
};
|
|
17575
|
+
for (const sourceComponentId of boundsWithChildren.sourceCompIds) {
|
|
17576
|
+
const schComp = db.schematic_component.getWhere({
|
|
17577
|
+
source_component_id: sourceComponentId
|
|
17578
|
+
});
|
|
17579
|
+
if (!schComp) continue;
|
|
17580
|
+
const ports = db.schematic_port.list({
|
|
17581
|
+
schematic_component_id: schComp.schematic_component_id
|
|
17582
|
+
});
|
|
17583
|
+
const texts = db.schematic_text.list({
|
|
17584
|
+
schematic_component_id: schComp.schematic_component_id
|
|
17585
|
+
});
|
|
17586
|
+
for (const port of ports) {
|
|
17587
|
+
port.center.x += delta.x;
|
|
17588
|
+
port.center.y += delta.y;
|
|
17589
|
+
}
|
|
17590
|
+
for (const text of texts) {
|
|
17591
|
+
text.position.x += delta.x;
|
|
17592
|
+
text.position.y += delta.y;
|
|
17593
|
+
}
|
|
17594
|
+
updateSchematicPrimitivesForLayoutShift({
|
|
17595
|
+
db,
|
|
17596
|
+
schematicComponentId: schComp.schematic_component_id,
|
|
17597
|
+
deltaX: delta.x,
|
|
17598
|
+
deltaY: delta.y
|
|
17599
|
+
});
|
|
17600
|
+
schComp.center = {
|
|
17601
|
+
x: schComp.center.x + delta.x,
|
|
17602
|
+
y: schComp.center.y + delta.y
|
|
17603
|
+
};
|
|
17604
|
+
}
|
|
17605
|
+
}
|
|
17606
|
+
}
|
|
17607
|
+
|
|
17430
17608
|
// lib/components/primitive-components/Group/Group_doInitialSchematicBoxComponentRender.ts
|
|
17431
17609
|
var parsePinNumberFromPortName = (name) => {
|
|
17432
17610
|
if (!name) return null;
|
|
@@ -20803,6 +20981,18 @@ var Group5 = class extends NormalComponent3 {
|
|
|
20803
20981
|
this._insertSchematicBorder();
|
|
20804
20982
|
return;
|
|
20805
20983
|
}
|
|
20984
|
+
const hasAnySectionName = this.children.some(
|
|
20985
|
+
(c) => c.source_component_id !== null && c._parsedProps?.schSectionName !== void 0
|
|
20986
|
+
);
|
|
20987
|
+
const hasAnyExplicitPosition = this.children.some(
|
|
20988
|
+
(c) => c.source_component_id !== null && (c._parsedProps?.schX !== void 0 || c._parsedProps?.schY !== void 0)
|
|
20989
|
+
);
|
|
20990
|
+
const hasSections = hasAnySectionName && !hasAnyExplicitPosition;
|
|
20991
|
+
if (hasSections) {
|
|
20992
|
+
this._doInitialSchematicLayoutSections();
|
|
20993
|
+
this._insertSchematicBorder();
|
|
20994
|
+
return;
|
|
20995
|
+
}
|
|
20806
20996
|
const schematicLayoutMode = this._getSchematicLayoutMode();
|
|
20807
20997
|
if (schematicLayoutMode === "match-adapt") {
|
|
20808
20998
|
this._doInitialSchematicLayoutMatchpack();
|
|
@@ -20815,6 +21005,9 @@ var Group5 = class extends NormalComponent3 {
|
|
|
20815
21005
|
}
|
|
20816
21006
|
this._insertSchematicBorder();
|
|
20817
21007
|
}
|
|
21008
|
+
_doInitialSchematicLayoutSections() {
|
|
21009
|
+
Group_doInitialSchematicLayoutSections(this);
|
|
21010
|
+
}
|
|
20818
21011
|
_doInitialSchematicLayoutMatchAdapt() {
|
|
20819
21012
|
Group_doInitialSchematicLayoutMatchAdapt(this);
|
|
20820
21013
|
}
|
|
@@ -22044,7 +22237,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
22044
22237
|
var package_default = {
|
|
22045
22238
|
name: "@tscircuit/core",
|
|
22046
22239
|
type: "module",
|
|
22047
|
-
version: "0.0.
|
|
22240
|
+
version: "0.0.1289",
|
|
22048
22241
|
types: "dist/index.d.ts",
|
|
22049
22242
|
main: "dist/index.js",
|
|
22050
22243
|
module: "dist/index.js",
|
|
@@ -22156,7 +22349,7 @@ var package_default = {
|
|
|
22156
22349
|
dependencies: {
|
|
22157
22350
|
"@flatten-js/core": "^1.6.2",
|
|
22158
22351
|
"@lume/kiwi": "^0.4.3",
|
|
22159
|
-
"calculate-cell-boundaries": "^0.0.
|
|
22352
|
+
"calculate-cell-boundaries": "^0.0.13",
|
|
22160
22353
|
"calculate-packing": "0.0.73",
|
|
22161
22354
|
"css-select": "5.1.0",
|
|
22162
22355
|
"format-si-unit": "^0.0.3",
|
|
@@ -28566,10 +28759,10 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
|
|
|
28566
28759
|
zodProps: schematicSectionProps
|
|
28567
28760
|
};
|
|
28568
28761
|
}
|
|
28569
|
-
|
|
28762
|
+
// Pass null to compute bounds for components with no schSectionName
|
|
28763
|
+
_computeSectionBounds(board, sectionName) {
|
|
28570
28764
|
const { db } = this.root;
|
|
28571
|
-
const
|
|
28572
|
-
const members = board.getDescendants().filter((c) => c.props?.schSectionName === name);
|
|
28765
|
+
const members = board.getDescendants().filter((c) => c.getSchematicSectionName() === sectionName);
|
|
28573
28766
|
if (members.length === 0) return null;
|
|
28574
28767
|
const positions = [];
|
|
28575
28768
|
for (const member of members) {
|
|
@@ -28600,11 +28793,15 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
|
|
|
28600
28793
|
const LABEL_PADDING = 0.2;
|
|
28601
28794
|
const STROKE_WIDTH = 0.02;
|
|
28602
28795
|
const TOL3 = 1e-3;
|
|
28603
|
-
const
|
|
28604
|
-
const bounds = section._computeSectionBounds(
|
|
28796
|
+
const namedSectionsWithBounds = allSections.map((section) => {
|
|
28797
|
+
const bounds = section._computeSectionBounds(
|
|
28798
|
+
board,
|
|
28799
|
+
section._parsedProps.name
|
|
28800
|
+
);
|
|
28605
28801
|
if (!bounds) return null;
|
|
28606
28802
|
return {
|
|
28607
|
-
section,
|
|
28803
|
+
displayName: section._parsedProps.displayName,
|
|
28804
|
+
sectionTitleFontSize: section._parsedProps.sectionTitleFontSize,
|
|
28608
28805
|
rawBounds: bounds,
|
|
28609
28806
|
cell: {
|
|
28610
28807
|
minX: bounds.minX - PADDING,
|
|
@@ -28614,12 +28811,26 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
|
|
|
28614
28811
|
}
|
|
28615
28812
|
};
|
|
28616
28813
|
}).filter((s) => s !== null);
|
|
28617
|
-
|
|
28618
|
-
const
|
|
28814
|
+
const unsectionedBounds = this._computeSectionBounds(board, null);
|
|
28815
|
+
const allSectionsWithBounds = [...namedSectionsWithBounds];
|
|
28816
|
+
if (unsectionedBounds)
|
|
28817
|
+
allSectionsWithBounds.push({
|
|
28818
|
+
displayName: void 0,
|
|
28819
|
+
sectionTitleFontSize: void 0,
|
|
28820
|
+
rawBounds: unsectionedBounds,
|
|
28821
|
+
cell: {
|
|
28822
|
+
minX: unsectionedBounds.minX - PADDING,
|
|
28823
|
+
maxX: unsectionedBounds.maxX + PADDING,
|
|
28824
|
+
minY: unsectionedBounds.minY - PADDING,
|
|
28825
|
+
maxY: unsectionedBounds.maxY + PADDING
|
|
28826
|
+
}
|
|
28827
|
+
});
|
|
28828
|
+
if (allSectionsWithBounds.length === 0) return;
|
|
28829
|
+
const allCells = allSectionsWithBounds.map((s) => s.cell);
|
|
28619
28830
|
const outer = computeBoundsFromCellContents(allCells);
|
|
28620
28831
|
const CELL_MARGIN = 1;
|
|
28621
28832
|
const dividers = calculateCellBoundaries(
|
|
28622
|
-
|
|
28833
|
+
allSectionsWithBounds.map((s) => ({
|
|
28623
28834
|
minX: s.rawBounds.minX - CELL_MARGIN,
|
|
28624
28835
|
maxX: s.rawBounds.maxX + CELL_MARGIN,
|
|
28625
28836
|
minY: s.rawBounds.minY - CELL_MARGIN,
|
|
@@ -28643,8 +28854,11 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
|
|
|
28643
28854
|
const vDividers = dividers.filter(
|
|
28644
28855
|
(l) => Math.abs(l.start.x - l.end.x) < TOL3
|
|
28645
28856
|
);
|
|
28646
|
-
for (const {
|
|
28647
|
-
|
|
28857
|
+
for (const {
|
|
28858
|
+
displayName,
|
|
28859
|
+
sectionTitleFontSize,
|
|
28860
|
+
rawBounds
|
|
28861
|
+
} of allSectionsWithBounds) {
|
|
28648
28862
|
if (!displayName) continue;
|
|
28649
28863
|
const dividersAbove = hDividers.map((l) => l.start.y).filter((y) => y > rawBounds.maxY);
|
|
28650
28864
|
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.1290",
|
|
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",
|