@tscircuit/core 0.0.274 → 0.0.276
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 +11 -0
- package/dist/index.js +188 -106
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -168,6 +168,12 @@ declare const Circuit: typeof RootCircuit;
|
|
|
168
168
|
interface ISubcircuit extends PrimitiveComponent {
|
|
169
169
|
_shouldUseTraceByTraceRouting(): boolean;
|
|
170
170
|
_parsedProps: z.infer<typeof subcircuitGroupProps>;
|
|
171
|
+
subcircuit_id: string | null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
interface IGroup extends PrimitiveComponent {
|
|
175
|
+
source_group_id: string | null;
|
|
176
|
+
pcb_group_id: string | null;
|
|
171
177
|
}
|
|
172
178
|
|
|
173
179
|
interface BaseComponentConfig {
|
|
@@ -327,6 +333,7 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
|
|
|
327
333
|
};
|
|
328
334
|
doesSelectorMatch(selector: string): boolean;
|
|
329
335
|
getSubcircuit(): ISubcircuit;
|
|
336
|
+
getGroup(): IGroup | null;
|
|
330
337
|
selectAll(selector: string): PrimitiveComponent[];
|
|
331
338
|
selectOne<T = PrimitiveComponent>(selector: string, options?: {
|
|
332
339
|
type?: string;
|
|
@@ -919,6 +926,8 @@ interface SimpleRouteJson {
|
|
|
919
926
|
}
|
|
920
927
|
|
|
921
928
|
declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps> extends NormalComponent<Props> implements ISubcircuit {
|
|
929
|
+
pcb_group_id: string | null;
|
|
930
|
+
subcircuit_id: string | null;
|
|
922
931
|
_asyncAutoroutingResult: {
|
|
923
932
|
output_simple_route_json?: SimpleRouteJson;
|
|
924
933
|
output_pcb_traces?: PcbTrace[];
|
|
@@ -927,6 +936,8 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
|
|
|
927
936
|
zodProps: Props;
|
|
928
937
|
componentName: string;
|
|
929
938
|
};
|
|
939
|
+
doInitialSourceRender(): void;
|
|
940
|
+
doInitialPcbComponentRender(): void;
|
|
930
941
|
doInitialCreateTraceHintsFromProps(): void;
|
|
931
942
|
_getSimpleRouteJsonFromPcbTraces(): SimpleRouteJson;
|
|
932
943
|
doInitialSourceAddConnectivityMapKey(): void;
|
package/dist/index.js
CHANGED
|
@@ -525,6 +525,9 @@ var underscorifyPortArrangement = (portArrangement) => {
|
|
|
525
525
|
return void 0;
|
|
526
526
|
};
|
|
527
527
|
|
|
528
|
+
// lib/components/base-components/PrimitiveComponent.ts
|
|
529
|
+
import Debug2 from "debug";
|
|
530
|
+
|
|
528
531
|
// lib/errors/InvalidProps.ts
|
|
529
532
|
var InvalidProps = class extends Error {
|
|
530
533
|
constructor(componentName, originalProps, formattedError) {
|
|
@@ -592,7 +595,6 @@ import {
|
|
|
592
595
|
translate
|
|
593
596
|
} from "transformation-matrix";
|
|
594
597
|
import { z as z2 } from "zod";
|
|
595
|
-
import Debug2 from "debug";
|
|
596
598
|
var debugSelectAll = Debug2("tscircuit:primitive-component:selectAll");
|
|
597
599
|
var PrimitiveComponent = class extends Renderable {
|
|
598
600
|
parent = null;
|
|
@@ -989,6 +991,10 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
989
991
|
throw new Error("Component is not inside an opaque group (no board?)");
|
|
990
992
|
return group;
|
|
991
993
|
}
|
|
994
|
+
getGroup() {
|
|
995
|
+
if (this.isGroup) return this;
|
|
996
|
+
return this.parent?.getGroup?.() ?? null;
|
|
997
|
+
}
|
|
992
998
|
selectAll(selector) {
|
|
993
999
|
debugSelectAll(`selectAll: "${selector}"`);
|
|
994
1000
|
const parts = selector.trim().split(/\s+/);
|
|
@@ -1327,9 +1333,7 @@ var createNetsFromProps = (component, props) => {
|
|
|
1327
1333
|
|
|
1328
1334
|
// lib/components/primitive-components/SmtPad.ts
|
|
1329
1335
|
import { smtPadProps } from "@tscircuit/props";
|
|
1330
|
-
import {
|
|
1331
|
-
decomposeTSR
|
|
1332
|
-
} from "transformation-matrix";
|
|
1336
|
+
import { decomposeTSR } from "transformation-matrix";
|
|
1333
1337
|
var SmtPad = class extends PrimitiveComponent {
|
|
1334
1338
|
pcb_smtpad_id = null;
|
|
1335
1339
|
matchedPort = null;
|
|
@@ -1373,6 +1377,7 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1373
1377
|
const { _parsedProps: props } = this;
|
|
1374
1378
|
if (!props.portHints) return;
|
|
1375
1379
|
const container = this.getPrimitiveContainer();
|
|
1380
|
+
const subcircuit = this.getSubcircuit();
|
|
1376
1381
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
1377
1382
|
const containerCenter = container?._getGlobalPcbPositionBeforeLayout();
|
|
1378
1383
|
const decomposedMat = decomposeTSR(
|
|
@@ -1394,7 +1399,8 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1394
1399
|
radius: props.radius,
|
|
1395
1400
|
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
1396
1401
|
x: position.x,
|
|
1397
|
-
y: position.y
|
|
1402
|
+
y: position.y,
|
|
1403
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0
|
|
1398
1404
|
});
|
|
1399
1405
|
db.pcb_solder_paste.insert({
|
|
1400
1406
|
layer: pcb_smtpad.layer,
|
|
@@ -1404,7 +1410,9 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1404
1410
|
x: pcb_smtpad.x,
|
|
1405
1411
|
y: pcb_smtpad.y,
|
|
1406
1412
|
pcb_component_id: pcb_smtpad.pcb_component_id,
|
|
1407
|
-
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id
|
|
1413
|
+
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id,
|
|
1414
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1415
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1408
1416
|
});
|
|
1409
1417
|
} else if (props.shape === "rect") {
|
|
1410
1418
|
pcb_smtpad = parentRotation === 0 || isRotated90 ? db.pcb_smtpad.insert({
|
|
@@ -1419,7 +1427,9 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1419
1427
|
},
|
|
1420
1428
|
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
1421
1429
|
x: position.x,
|
|
1422
|
-
y: position.y
|
|
1430
|
+
y: position.y,
|
|
1431
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1432
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1423
1433
|
}) : db.pcb_smtpad.insert({
|
|
1424
1434
|
pcb_component_id,
|
|
1425
1435
|
layer: props.layer ?? "top",
|
|
@@ -1428,7 +1438,9 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1428
1438
|
x: position.x,
|
|
1429
1439
|
y: position.y,
|
|
1430
1440
|
ccw_rotation: parentRotation,
|
|
1431
|
-
port_hints: props.portHints.map((ph) => ph.toString())
|
|
1441
|
+
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
1442
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1443
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1432
1444
|
});
|
|
1433
1445
|
if (pcb_smtpad.shape === "rect")
|
|
1434
1446
|
db.pcb_solder_paste.insert({
|
|
@@ -1440,7 +1452,9 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1440
1452
|
x: pcb_smtpad.x,
|
|
1441
1453
|
y: pcb_smtpad.y,
|
|
1442
1454
|
pcb_component_id: pcb_smtpad.pcb_component_id,
|
|
1443
|
-
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id
|
|
1455
|
+
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id,
|
|
1456
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1457
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1444
1458
|
});
|
|
1445
1459
|
}
|
|
1446
1460
|
if (pcb_smtpad) {
|
|
@@ -1524,7 +1538,7 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1524
1538
|
|
|
1525
1539
|
// lib/components/primitive-components/SilkscreenPath.ts
|
|
1526
1540
|
import { silkscreenPathProps } from "@tscircuit/props";
|
|
1527
|
-
import { applyToPoint as
|
|
1541
|
+
import { applyToPoint as applyToPoint2 } from "transformation-matrix";
|
|
1528
1542
|
var SilkscreenPath = class extends PrimitiveComponent {
|
|
1529
1543
|
pcb_silkscreen_path_id = null;
|
|
1530
1544
|
get config() {
|
|
@@ -1544,11 +1558,12 @@ var SilkscreenPath = class extends PrimitiveComponent {
|
|
|
1544
1558
|
);
|
|
1545
1559
|
}
|
|
1546
1560
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
1561
|
+
const subcircuit = this.getSubcircuit();
|
|
1547
1562
|
const pcb_silkscreen_path = db.pcb_silkscreen_path.insert({
|
|
1548
1563
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
1549
1564
|
layer,
|
|
1550
1565
|
route: props.route.map((p) => {
|
|
1551
|
-
const transformedPosition =
|
|
1566
|
+
const transformedPosition = applyToPoint2(transform, {
|
|
1552
1567
|
x: p.x,
|
|
1553
1568
|
y: p.y
|
|
1554
1569
|
});
|
|
@@ -1558,7 +1573,9 @@ var SilkscreenPath = class extends PrimitiveComponent {
|
|
|
1558
1573
|
y: transformedPosition.y
|
|
1559
1574
|
};
|
|
1560
1575
|
}),
|
|
1561
|
-
stroke_width: props.strokeWidth ?? 0.1
|
|
1576
|
+
stroke_width: props.strokeWidth ?? 0.1,
|
|
1577
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1578
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1562
1579
|
});
|
|
1563
1580
|
this.pcb_silkscreen_path_id = pcb_silkscreen_path.pcb_silkscreen_path_id;
|
|
1564
1581
|
}
|
|
@@ -1636,6 +1653,7 @@ var PlatedHole = class extends PrimitiveComponent {
|
|
|
1636
1653
|
const { _parsedProps: props } = this;
|
|
1637
1654
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
1638
1655
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
1656
|
+
const subcircuit = this.getSubcircuit();
|
|
1639
1657
|
if (props.shape === "circle") {
|
|
1640
1658
|
const pcb_plated_hole = db.pcb_plated_hole.insert({
|
|
1641
1659
|
pcb_component_id,
|
|
@@ -1647,7 +1665,9 @@ var PlatedHole = class extends PrimitiveComponent {
|
|
|
1647
1665
|
port_hints: this.getNameAndAliases(),
|
|
1648
1666
|
x: position.x,
|
|
1649
1667
|
y: position.y,
|
|
1650
|
-
layers: ["top", "bottom"]
|
|
1668
|
+
layers: ["top", "bottom"],
|
|
1669
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1670
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1651
1671
|
});
|
|
1652
1672
|
this.pcb_plated_hole_id = pcb_plated_hole.pcb_plated_hole_id;
|
|
1653
1673
|
} else if (props.shape === "pill" || props.shape === "oval") {
|
|
@@ -1662,7 +1682,9 @@ var PlatedHole = class extends PrimitiveComponent {
|
|
|
1662
1682
|
port_hints: this.getNameAndAliases(),
|
|
1663
1683
|
x: position.x,
|
|
1664
1684
|
y: position.y,
|
|
1665
|
-
layers: ["top", "bottom"]
|
|
1685
|
+
layers: ["top", "bottom"],
|
|
1686
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1687
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1666
1688
|
// NOTE: currently PcbPlatedHoleOval erroneously includes both the shape "pill" and "oval"
|
|
1667
1689
|
});
|
|
1668
1690
|
this.pcb_plated_hole_id = pcb_plated_hole.pcb_plated_hole_id;
|
|
@@ -1691,6 +1713,7 @@ var Keepout = class extends PrimitiveComponent {
|
|
|
1691
1713
|
}
|
|
1692
1714
|
doInitialPcbPrimitiveRender() {
|
|
1693
1715
|
if (this.root?.pcbDisabled) return;
|
|
1716
|
+
const subcircuit = this.getSubcircuit();
|
|
1694
1717
|
const { db } = this.root;
|
|
1695
1718
|
const { _parsedProps: props } = this;
|
|
1696
1719
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
@@ -1708,7 +1731,9 @@ var Keepout = class extends PrimitiveComponent {
|
|
|
1708
1731
|
center: {
|
|
1709
1732
|
x: position.x,
|
|
1710
1733
|
y: position.y
|
|
1711
|
-
}
|
|
1734
|
+
},
|
|
1735
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1736
|
+
pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
|
|
1712
1737
|
});
|
|
1713
1738
|
} else if (props.shape === "rect") {
|
|
1714
1739
|
pcb_keepout = db.pcb_keepout.insert({
|
|
@@ -1719,7 +1744,9 @@ var Keepout = class extends PrimitiveComponent {
|
|
|
1719
1744
|
center: {
|
|
1720
1745
|
x: position.x,
|
|
1721
1746
|
y: position.y
|
|
1722
|
-
}
|
|
1747
|
+
},
|
|
1748
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1749
|
+
pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
|
|
1723
1750
|
});
|
|
1724
1751
|
}
|
|
1725
1752
|
if (pcb_keepout) {
|
|
@@ -1747,13 +1774,16 @@ var Hole = class extends PrimitiveComponent {
|
|
|
1747
1774
|
if (this.root?.pcbDisabled) return;
|
|
1748
1775
|
const { db } = this.root;
|
|
1749
1776
|
const { _parsedProps: props } = this;
|
|
1777
|
+
const subcircuit = this.getSubcircuit();
|
|
1750
1778
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
1751
1779
|
const inserted_hole = db.pcb_hole.insert({
|
|
1752
1780
|
hole_shape: "circle",
|
|
1753
1781
|
// @ts-ignore
|
|
1754
1782
|
hole_diameter: props.diameter,
|
|
1755
1783
|
x: position.x,
|
|
1756
|
-
y: position.y
|
|
1784
|
+
y: position.y,
|
|
1785
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1786
|
+
pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
|
|
1757
1787
|
});
|
|
1758
1788
|
this.pcb_hole_id = inserted_hole.pcb_hole_id;
|
|
1759
1789
|
}
|
|
@@ -1910,7 +1940,7 @@ function getRelativeDirection(pointA, pointB) {
|
|
|
1910
1940
|
|
|
1911
1941
|
// lib/components/primitive-components/Port/Port.ts
|
|
1912
1942
|
import "schematic-symbols";
|
|
1913
|
-
import { applyToPoint as
|
|
1943
|
+
import { applyToPoint as applyToPoint3, compose as compose2, translate as translate2 } from "transformation-matrix";
|
|
1914
1944
|
import { z as z4 } from "zod";
|
|
1915
1945
|
|
|
1916
1946
|
// lib/components/primitive-components/Port/areAllPcbPrimitivesOverlapping.ts
|
|
@@ -2020,11 +2050,11 @@ var Port = class extends PrimitiveComponent {
|
|
|
2020
2050
|
_getGlobalSchematicPositionBeforeLayout() {
|
|
2021
2051
|
const symbol = this.parent?.getSchematicSymbol();
|
|
2022
2052
|
if (symbol && this.schematicSymbolPortDef) {
|
|
2023
|
-
const transform =
|
|
2053
|
+
const transform = compose2(
|
|
2024
2054
|
this.parent.computeSchematicGlobalTransform(),
|
|
2025
|
-
|
|
2055
|
+
translate2(-symbol.center.x, -symbol.center.y)
|
|
2026
2056
|
);
|
|
2027
|
-
return
|
|
2057
|
+
return applyToPoint3(transform, this.schematicSymbolPortDef);
|
|
2028
2058
|
}
|
|
2029
2059
|
const parentBoxDim = this?.parent?._getSchematicBoxDimensions();
|
|
2030
2060
|
if (parentBoxDim && this.props.pinNumber !== void 0) {
|
|
@@ -2034,7 +2064,7 @@ var Port = class extends PrimitiveComponent {
|
|
|
2034
2064
|
if (!localPortPosition) {
|
|
2035
2065
|
return { x: 0, y: 0 };
|
|
2036
2066
|
}
|
|
2037
|
-
return
|
|
2067
|
+
return applyToPoint3(
|
|
2038
2068
|
this.parent.computeSchematicGlobalTransform(),
|
|
2039
2069
|
localPortPosition
|
|
2040
2070
|
);
|
|
@@ -2145,9 +2175,12 @@ var Port = class extends PrimitiveComponent {
|
|
|
2145
2175
|
matchCenter = getCenterOfPcbPrimitives(pcbMatches);
|
|
2146
2176
|
}
|
|
2147
2177
|
if (matchCenter) {
|
|
2178
|
+
const subcircuit = this.getSubcircuit();
|
|
2148
2179
|
const pcb_port = db.pcb_port.insert({
|
|
2149
2180
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
2150
2181
|
layers: this.getAvailablePcbLayers(),
|
|
2182
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
2183
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0,
|
|
2151
2184
|
...matchCenter,
|
|
2152
2185
|
source_port_id: this.source_port_id
|
|
2153
2186
|
});
|
|
@@ -3457,18 +3490,74 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
3457
3490
|
|
|
3458
3491
|
// lib/components/normal-components/Board.ts
|
|
3459
3492
|
import { boardProps } from "@tscircuit/props";
|
|
3460
|
-
import { identity as
|
|
3493
|
+
import { identity as identity3 } from "transformation-matrix";
|
|
3494
|
+
|
|
3495
|
+
// lib/components/primitive-components/Group/Group.ts
|
|
3496
|
+
import { groupProps } from "@tscircuit/props";
|
|
3497
|
+
import * as SAL from "@tscircuit/schematic-autolayout";
|
|
3498
|
+
import "circuit-json";
|
|
3499
|
+
import { ConnectivityMap } from "circuit-json-to-connectivity-map";
|
|
3500
|
+
import Debug5 from "debug";
|
|
3501
|
+
|
|
3502
|
+
// lib/utils/autorouting/getSimpleRouteJsonFromTracesAndDb.ts
|
|
3503
|
+
import { getObstaclesFromSoup } from "@tscircuit/infgrid-ijump-astar";
|
|
3504
|
+
var getSimpleRouteJsonFromTracesAndDb = ({
|
|
3505
|
+
db,
|
|
3506
|
+
traces,
|
|
3507
|
+
minTraceWidth = 0.1
|
|
3508
|
+
}) => {
|
|
3509
|
+
const obstacles = getObstaclesFromSoup([
|
|
3510
|
+
...db.pcb_component.list(),
|
|
3511
|
+
...db.pcb_smtpad.list(),
|
|
3512
|
+
...db.pcb_plated_hole.list()
|
|
3513
|
+
]);
|
|
3514
|
+
const allPoints = obstacles.flatMap((o) => [
|
|
3515
|
+
{
|
|
3516
|
+
x: o.center.x - o.width / 2,
|
|
3517
|
+
y: o.center.y - o.height / 2
|
|
3518
|
+
},
|
|
3519
|
+
{
|
|
3520
|
+
x: o.center.x + o.width / 2,
|
|
3521
|
+
y: o.center.y + o.height / 2
|
|
3522
|
+
}
|
|
3523
|
+
]);
|
|
3524
|
+
const bounds = {
|
|
3525
|
+
minX: Math.min(...allPoints.map((p) => p.x)) - 1,
|
|
3526
|
+
maxX: Math.max(...allPoints.map((p) => p.x)) + 1,
|
|
3527
|
+
minY: Math.min(...allPoints.map((p) => p.y)) - 1,
|
|
3528
|
+
maxY: Math.max(...allPoints.map((p) => p.y)) + 1
|
|
3529
|
+
};
|
|
3530
|
+
const connections = traces.map((trace) => {
|
|
3531
|
+
const connectedPorts = trace._findConnectedPorts();
|
|
3532
|
+
if (!connectedPorts.allPortsFound || connectedPorts.ports.length < 2)
|
|
3533
|
+
return null;
|
|
3534
|
+
return {
|
|
3535
|
+
name: trace.source_trace_id ?? "",
|
|
3536
|
+
pointsToConnect: connectedPorts.ports.map((port) => {
|
|
3537
|
+
const pos = port._getGlobalPcbPositionBeforeLayout();
|
|
3538
|
+
return {
|
|
3539
|
+
x: pos.x,
|
|
3540
|
+
y: pos.y,
|
|
3541
|
+
layer: port.getAvailablePcbLayers()[0] ?? "top"
|
|
3542
|
+
};
|
|
3543
|
+
})
|
|
3544
|
+
};
|
|
3545
|
+
}).filter((c) => c !== null);
|
|
3546
|
+
return {
|
|
3547
|
+
bounds,
|
|
3548
|
+
obstacles: [],
|
|
3549
|
+
connections,
|
|
3550
|
+
layerCount: 2,
|
|
3551
|
+
minTraceWidth
|
|
3552
|
+
};
|
|
3553
|
+
};
|
|
3461
3554
|
|
|
3462
3555
|
// lib/components/primitive-components/Group/Group.ts
|
|
3463
|
-
import {
|
|
3464
|
-
groupProps
|
|
3465
|
-
} from "@tscircuit/props";
|
|
3466
|
-
import "transformation-matrix";
|
|
3467
3556
|
import "zod";
|
|
3468
3557
|
|
|
3469
3558
|
// lib/components/primitive-components/TraceHint.ts
|
|
3470
3559
|
import { traceHintProps } from "@tscircuit/props";
|
|
3471
|
-
import { applyToPoint as
|
|
3560
|
+
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
3472
3561
|
var TraceHint = class extends PrimitiveComponent {
|
|
3473
3562
|
matchedPort = null;
|
|
3474
3563
|
get config() {
|
|
@@ -3508,7 +3597,7 @@ var TraceHint = class extends PrimitiveComponent {
|
|
|
3508
3597
|
const globalTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
3509
3598
|
return offsets.map(
|
|
3510
3599
|
(offset) => ({
|
|
3511
|
-
...
|
|
3600
|
+
...applyToPoint4(globalTransform, offset),
|
|
3512
3601
|
via: offset.via,
|
|
3513
3602
|
to_layer: offset.to_layer,
|
|
3514
3603
|
trace_width: offset.trace_width
|
|
@@ -3528,66 +3617,9 @@ var TraceHint = class extends PrimitiveComponent {
|
|
|
3528
3617
|
};
|
|
3529
3618
|
|
|
3530
3619
|
// lib/components/primitive-components/Group/Group.ts
|
|
3531
|
-
import * as SAL from "@tscircuit/schematic-autolayout";
|
|
3532
|
-
import "@tscircuit/infgrid-ijump-astar";
|
|
3533
|
-
import { ConnectivityMap } from "circuit-json-to-connectivity-map";
|
|
3534
|
-
|
|
3535
|
-
// lib/utils/autorouting/getSimpleRouteJsonFromTracesAndDb.ts
|
|
3536
|
-
import { getObstaclesFromSoup } from "@tscircuit/infgrid-ijump-astar";
|
|
3537
|
-
var getSimpleRouteJsonFromTracesAndDb = ({
|
|
3538
|
-
db,
|
|
3539
|
-
traces,
|
|
3540
|
-
minTraceWidth = 0.1
|
|
3541
|
-
}) => {
|
|
3542
|
-
const obstacles = getObstaclesFromSoup([
|
|
3543
|
-
...db.pcb_component.list(),
|
|
3544
|
-
...db.pcb_smtpad.list(),
|
|
3545
|
-
...db.pcb_plated_hole.list()
|
|
3546
|
-
]);
|
|
3547
|
-
const allPoints = obstacles.flatMap((o) => [
|
|
3548
|
-
{
|
|
3549
|
-
x: o.center.x - o.width / 2,
|
|
3550
|
-
y: o.center.y - o.height / 2
|
|
3551
|
-
},
|
|
3552
|
-
{
|
|
3553
|
-
x: o.center.x + o.width / 2,
|
|
3554
|
-
y: o.center.y + o.height / 2
|
|
3555
|
-
}
|
|
3556
|
-
]);
|
|
3557
|
-
const bounds = {
|
|
3558
|
-
minX: Math.min(...allPoints.map((p) => p.x)) - 1,
|
|
3559
|
-
maxX: Math.max(...allPoints.map((p) => p.x)) + 1,
|
|
3560
|
-
minY: Math.min(...allPoints.map((p) => p.y)) - 1,
|
|
3561
|
-
maxY: Math.max(...allPoints.map((p) => p.y)) + 1
|
|
3562
|
-
};
|
|
3563
|
-
const connections = traces.map((trace) => {
|
|
3564
|
-
const connectedPorts = trace._findConnectedPorts();
|
|
3565
|
-
if (!connectedPorts.allPortsFound || connectedPorts.ports.length < 2)
|
|
3566
|
-
return null;
|
|
3567
|
-
return {
|
|
3568
|
-
name: trace.source_trace_id ?? "",
|
|
3569
|
-
pointsToConnect: connectedPorts.ports.map((port) => {
|
|
3570
|
-
const pos = port._getGlobalPcbPositionBeforeLayout();
|
|
3571
|
-
return {
|
|
3572
|
-
x: pos.x,
|
|
3573
|
-
y: pos.y,
|
|
3574
|
-
layer: port.getAvailablePcbLayers()[0] ?? "top"
|
|
3575
|
-
};
|
|
3576
|
-
})
|
|
3577
|
-
};
|
|
3578
|
-
}).filter((c) => c !== null);
|
|
3579
|
-
return {
|
|
3580
|
-
bounds,
|
|
3581
|
-
obstacles: [],
|
|
3582
|
-
connections,
|
|
3583
|
-
layerCount: 2,
|
|
3584
|
-
minTraceWidth
|
|
3585
|
-
};
|
|
3586
|
-
};
|
|
3587
|
-
|
|
3588
|
-
// lib/components/primitive-components/Group/Group.ts
|
|
3589
|
-
import Debug5 from "debug";
|
|
3590
3620
|
var Group = class extends NormalComponent {
|
|
3621
|
+
pcb_group_id = null;
|
|
3622
|
+
subcircuit_id = null;
|
|
3591
3623
|
_asyncAutoroutingResult = null;
|
|
3592
3624
|
get config() {
|
|
3593
3625
|
return {
|
|
@@ -3595,6 +3627,34 @@ var Group = class extends NormalComponent {
|
|
|
3595
3627
|
componentName: "Group"
|
|
3596
3628
|
};
|
|
3597
3629
|
}
|
|
3630
|
+
doInitialSourceRender() {
|
|
3631
|
+
const { db } = this.root;
|
|
3632
|
+
const source_group = db.source_group.insert({
|
|
3633
|
+
name: this._parsedProps.name,
|
|
3634
|
+
is_subcircuit: this.isSubcircuit
|
|
3635
|
+
});
|
|
3636
|
+
this.subcircuit_id = `subcircuit_${source_group.source_group_id}`;
|
|
3637
|
+
this.source_group_id = source_group.source_group_id;
|
|
3638
|
+
db.source_group.update(source_group.source_group_id, {
|
|
3639
|
+
subcircuit_id: this.subcircuit_id
|
|
3640
|
+
});
|
|
3641
|
+
}
|
|
3642
|
+
doInitialPcbComponentRender() {
|
|
3643
|
+
if (this.root?.pcbDisabled) return;
|
|
3644
|
+
const { db } = this.root;
|
|
3645
|
+
const { _parsedProps: props } = this;
|
|
3646
|
+
const pcb_group = db.pcb_group.insert({
|
|
3647
|
+
is_subcircuit: this.isSubcircuit,
|
|
3648
|
+
subcircuit_id: this.subcircuit_id,
|
|
3649
|
+
name: this._parsedProps.name,
|
|
3650
|
+
center: this._getGlobalPcbPositionBeforeLayout(),
|
|
3651
|
+
width: 0,
|
|
3652
|
+
height: 0,
|
|
3653
|
+
pcb_component_ids: [],
|
|
3654
|
+
source_group_id: this.source_group_id
|
|
3655
|
+
});
|
|
3656
|
+
this.pcb_group_id = pcb_group.pcb_group_id;
|
|
3657
|
+
}
|
|
3598
3658
|
doInitialCreateTraceHintsFromProps() {
|
|
3599
3659
|
const { _parsedProps: props } = this;
|
|
3600
3660
|
const { db } = this.root;
|
|
@@ -3868,7 +3928,7 @@ var Board = class extends Group {
|
|
|
3868
3928
|
this.pcb_board_id = null;
|
|
3869
3929
|
}
|
|
3870
3930
|
_computePcbGlobalTransformBeforeLayout() {
|
|
3871
|
-
return
|
|
3931
|
+
return identity3();
|
|
3872
3932
|
}
|
|
3873
3933
|
};
|
|
3874
3934
|
|
|
@@ -3887,7 +3947,7 @@ var FTYPE = stringProxy;
|
|
|
3887
3947
|
// lib/components/primitive-components/Trace/Trace.ts
|
|
3888
3948
|
import {
|
|
3889
3949
|
MultilayerIjump,
|
|
3890
|
-
getObstaclesFromSoup as
|
|
3950
|
+
getObstaclesFromSoup as getObstaclesFromSoup2
|
|
3891
3951
|
} from "@tscircuit/infgrid-ijump-astar";
|
|
3892
3952
|
import { traceProps } from "@tscircuit/props";
|
|
3893
3953
|
import "circuit-json";
|
|
@@ -4785,7 +4845,9 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4785
4845
|
if (cachedRoute) {
|
|
4786
4846
|
const pcb_trace2 = db.pcb_trace.insert({
|
|
4787
4847
|
route: cachedRoute.flatMap((trace) => trace.route),
|
|
4788
|
-
source_trace_id: this.source_trace_id
|
|
4848
|
+
source_trace_id: this.source_trace_id,
|
|
4849
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
4850
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
4789
4851
|
});
|
|
4790
4852
|
this.pcb_trace_id = pcb_trace2.pcb_trace_id;
|
|
4791
4853
|
return;
|
|
@@ -4889,7 +4951,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4889
4951
|
this.root.db.toArray()
|
|
4890
4952
|
);
|
|
4891
4953
|
const [obstacles, errGettingObstacles] = tryNow(
|
|
4892
|
-
() =>
|
|
4954
|
+
() => getObstaclesFromSoup2(this.root.db.toArray())
|
|
4893
4955
|
// Remove as any when autorouting-dataset gets updated
|
|
4894
4956
|
);
|
|
4895
4957
|
if (errGettingObstacles) {
|
|
@@ -5669,7 +5731,7 @@ var Constraint2 = class extends PrimitiveComponent {
|
|
|
5669
5731
|
|
|
5670
5732
|
// lib/components/primitive-components/FabricationNotePath.ts
|
|
5671
5733
|
import { fabricationNotePathProps } from "@tscircuit/props";
|
|
5672
|
-
import { applyToPoint as
|
|
5734
|
+
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
5673
5735
|
var FabricationNotePath = class extends PrimitiveComponent {
|
|
5674
5736
|
fabrication_note_path_id = null;
|
|
5675
5737
|
get config() {
|
|
@@ -5681,6 +5743,7 @@ var FabricationNotePath = class extends PrimitiveComponent {
|
|
|
5681
5743
|
doInitialPcbPrimitiveRender() {
|
|
5682
5744
|
if (this.root?.pcbDisabled) return;
|
|
5683
5745
|
const { db } = this.root;
|
|
5746
|
+
const subcircuit = this.getSubcircuit();
|
|
5684
5747
|
const { _parsedProps: props } = this;
|
|
5685
5748
|
const layer = props.layer ?? "top";
|
|
5686
5749
|
if (layer !== "top" && layer !== "bottom") {
|
|
@@ -5694,7 +5757,7 @@ var FabricationNotePath = class extends PrimitiveComponent {
|
|
|
5694
5757
|
layer,
|
|
5695
5758
|
color: props.color,
|
|
5696
5759
|
route: props.route.map((p) => {
|
|
5697
|
-
const transformedPosition =
|
|
5760
|
+
const transformedPosition = applyToPoint5(transform, {
|
|
5698
5761
|
x: p.x,
|
|
5699
5762
|
y: p.y
|
|
5700
5763
|
});
|
|
@@ -5704,7 +5767,8 @@ var FabricationNotePath = class extends PrimitiveComponent {
|
|
|
5704
5767
|
y: transformedPosition.y
|
|
5705
5768
|
};
|
|
5706
5769
|
}),
|
|
5707
|
-
stroke_width: props.strokeWidth ?? 0.1
|
|
5770
|
+
stroke_width: props.strokeWidth ?? 0.1,
|
|
5771
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0
|
|
5708
5772
|
});
|
|
5709
5773
|
this.fabrication_note_path_id = fabrication_note_path.pcb_fabrication_note_path_id;
|
|
5710
5774
|
}
|
|
@@ -5724,6 +5788,7 @@ var FabricationNoteText = class extends PrimitiveComponent {
|
|
|
5724
5788
|
const { db } = this.root;
|
|
5725
5789
|
const { _parsedProps: props } = this;
|
|
5726
5790
|
const container = this.getPrimitiveContainer();
|
|
5791
|
+
const subcircuit = this.getSubcircuit();
|
|
5727
5792
|
db.pcb_fabrication_note_text.insert({
|
|
5728
5793
|
anchor_alignment: props.anchorAlignment,
|
|
5729
5794
|
anchor_position: {
|
|
@@ -5735,7 +5800,9 @@ var FabricationNoteText = class extends PrimitiveComponent {
|
|
|
5735
5800
|
layer: "top",
|
|
5736
5801
|
color: props.color,
|
|
5737
5802
|
text: props.text ?? "",
|
|
5738
|
-
pcb_component_id: container.pcb_component_id
|
|
5803
|
+
pcb_component_id: container.pcb_component_id,
|
|
5804
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5805
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5739
5806
|
});
|
|
5740
5807
|
}
|
|
5741
5808
|
};
|
|
@@ -5799,6 +5866,7 @@ var SilkscreenCircle = class extends PrimitiveComponent {
|
|
|
5799
5866
|
);
|
|
5800
5867
|
}
|
|
5801
5868
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
5869
|
+
const subcircuit = this.getSubcircuit();
|
|
5802
5870
|
const pcb_silkscreen_circle = db.pcb_silkscreen_circle.insert({
|
|
5803
5871
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
5804
5872
|
layer,
|
|
@@ -5806,7 +5874,9 @@ var SilkscreenCircle = class extends PrimitiveComponent {
|
|
|
5806
5874
|
x: props.pcbX ?? 0,
|
|
5807
5875
|
y: props.pcbY ?? 0
|
|
5808
5876
|
},
|
|
5809
|
-
radius: props.radius
|
|
5877
|
+
radius: props.radius,
|
|
5878
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5879
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5810
5880
|
});
|
|
5811
5881
|
this.pcb_silkscreen_circle_id = pcb_silkscreen_circle.pcb_silkscreen_circle_id;
|
|
5812
5882
|
}
|
|
@@ -5832,6 +5902,7 @@ var SilkscreenRect = class extends PrimitiveComponent {
|
|
|
5832
5902
|
`Invalid layer "${layer}" for SilkscreenRect. Must be "top" or "bottom".`
|
|
5833
5903
|
);
|
|
5834
5904
|
}
|
|
5905
|
+
const subcircuit = this.getSubcircuit();
|
|
5835
5906
|
const pcb_silkscreen_rect = db.pcb_silkscreen_rect.insert({
|
|
5836
5907
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
5837
5908
|
layer,
|
|
@@ -5840,7 +5911,9 @@ var SilkscreenRect = class extends PrimitiveComponent {
|
|
|
5840
5911
|
y: props.pcbY ?? 0
|
|
5841
5912
|
},
|
|
5842
5913
|
width: props.width,
|
|
5843
|
-
height: props.height
|
|
5914
|
+
height: props.height,
|
|
5915
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5916
|
+
pcb_group_id: this?.getGroup()?.pcb_group_id ?? void 0
|
|
5844
5917
|
});
|
|
5845
5918
|
this.pcb_silkscreen_rect_id = pcb_silkscreen_rect.pcb_silkscreen_rect_id;
|
|
5846
5919
|
}
|
|
@@ -5863,6 +5936,7 @@ var SilkscreenText = class extends PrimitiveComponent {
|
|
|
5863
5936
|
const container = this.getPrimitiveContainer();
|
|
5864
5937
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
5865
5938
|
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
5939
|
+
const subcircuit = this.getSubcircuit();
|
|
5866
5940
|
db.pcb_silkscreen_text.insert({
|
|
5867
5941
|
anchor_alignment: props.anchorAlignment,
|
|
5868
5942
|
anchor_position: {
|
|
@@ -5874,7 +5948,9 @@ var SilkscreenText = class extends PrimitiveComponent {
|
|
|
5874
5948
|
layer: maybeFlipLayer(props.layer ?? "top"),
|
|
5875
5949
|
text: props.text ?? "",
|
|
5876
5950
|
ccw_rotation: props.pcbRotation,
|
|
5877
|
-
pcb_component_id: container.pcb_component_id
|
|
5951
|
+
pcb_component_id: container.pcb_component_id,
|
|
5952
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5953
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5878
5954
|
});
|
|
5879
5955
|
}
|
|
5880
5956
|
getPcbSize() {
|
|
@@ -5907,6 +5983,7 @@ var SilkscreenLine = class extends PrimitiveComponent {
|
|
|
5907
5983
|
`Invalid layer "${layer}" for SilkscreenLine. Must be "top" or "bottom".`
|
|
5908
5984
|
);
|
|
5909
5985
|
}
|
|
5986
|
+
const subcircuit = this.getSubcircuit();
|
|
5910
5987
|
const pcb_silkscreen_line = db.pcb_silkscreen_line.insert({
|
|
5911
5988
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
5912
5989
|
layer,
|
|
@@ -5914,7 +5991,9 @@ var SilkscreenLine = class extends PrimitiveComponent {
|
|
|
5914
5991
|
y1: props.y1,
|
|
5915
5992
|
x2: props.x2,
|
|
5916
5993
|
y2: props.y2,
|
|
5917
|
-
stroke_width: props.strokeWidth ?? 0.1
|
|
5994
|
+
stroke_width: props.strokeWidth ?? 0.1,
|
|
5995
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5996
|
+
pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
|
|
5918
5997
|
});
|
|
5919
5998
|
this.pcb_silkscreen_line_id = pcb_silkscreen_line.pcb_silkscreen_line_id;
|
|
5920
5999
|
}
|
|
@@ -5967,6 +6046,7 @@ var Via = class extends PrimitiveComponent {
|
|
|
5967
6046
|
const { db } = this.root;
|
|
5968
6047
|
const { _parsedProps: props } = this;
|
|
5969
6048
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
6049
|
+
const subcircuit = this.getSubcircuit();
|
|
5970
6050
|
const pcb_via = db.pcb_via.insert({
|
|
5971
6051
|
x: position.x,
|
|
5972
6052
|
y: position.y,
|
|
@@ -5974,7 +6054,9 @@ var Via = class extends PrimitiveComponent {
|
|
|
5974
6054
|
outer_diameter: props.outerDiameter,
|
|
5975
6055
|
layers: ["bottom", "top"],
|
|
5976
6056
|
from_layer: props.fromLayer || "bottom",
|
|
5977
|
-
to_layer: props.toLayer || "top"
|
|
6057
|
+
to_layer: props.toLayer || "top",
|
|
6058
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
6059
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5978
6060
|
});
|
|
5979
6061
|
this.pcb_via_id = pcb_via.pcb_via_id;
|
|
5980
6062
|
}
|
|
@@ -6297,7 +6379,7 @@ var Mosfet = class extends NormalComponent {
|
|
|
6297
6379
|
// lib/RootCircuit.ts
|
|
6298
6380
|
import { su } from "@tscircuit/soup-util";
|
|
6299
6381
|
import { isValidElement as isValidElement2 } from "react";
|
|
6300
|
-
import { identity as
|
|
6382
|
+
import { identity as identity4 } from "transformation-matrix";
|
|
6301
6383
|
var RootCircuit = class {
|
|
6302
6384
|
firstChild = null;
|
|
6303
6385
|
children;
|
|
@@ -6408,10 +6490,10 @@ var RootCircuit = class {
|
|
|
6408
6490
|
throw new Error("project.preview is not yet implemented");
|
|
6409
6491
|
}
|
|
6410
6492
|
computeSchematicGlobalTransform() {
|
|
6411
|
-
return
|
|
6493
|
+
return identity4();
|
|
6412
6494
|
}
|
|
6413
6495
|
_computePcbGlobalTransformBeforeLayout() {
|
|
6414
|
-
return
|
|
6496
|
+
return identity4();
|
|
6415
6497
|
}
|
|
6416
6498
|
selectAll(selector) {
|
|
6417
6499
|
this._guessRootComponent();
|
|
@@ -6602,7 +6684,7 @@ var applyEditEventsToManualEditsFile = ({
|
|
|
6602
6684
|
};
|
|
6603
6685
|
|
|
6604
6686
|
// lib/utils/autorouting/getSimpleRouteJsonFromCircuitJson.ts
|
|
6605
|
-
import { getObstaclesFromSoup as
|
|
6687
|
+
import { getObstaclesFromSoup as getObstaclesFromSoup3 } from "@tscircuit/infgrid-ijump-astar";
|
|
6606
6688
|
import { su as su3 } from "@tscircuit/soup-util";
|
|
6607
6689
|
import { getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson2 } from "circuit-json-to-connectivity-map";
|
|
6608
6690
|
var getSimpleRouteJsonFromCircuitJson = ({
|
|
@@ -6611,7 +6693,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
6611
6693
|
}) => {
|
|
6612
6694
|
const db = su3(circuitJson);
|
|
6613
6695
|
const connMap = getFullConnectivityMapFromCircuitJson2(circuitJson);
|
|
6614
|
-
const obstacles =
|
|
6696
|
+
const obstacles = getObstaclesFromSoup3(
|
|
6615
6697
|
[
|
|
6616
6698
|
...db.pcb_component.list(),
|
|
6617
6699
|
...db.pcb_smtpad.list(),
|
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.276",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@tscircuit/props": "^0.0.130",
|
|
58
58
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
59
59
|
"@tscircuit/soup-util": "^0.0.41",
|
|
60
|
-
"circuit-json": "^0.0.
|
|
60
|
+
"circuit-json": "^0.0.133",
|
|
61
61
|
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
62
62
|
"format-si-unit": "^0.0.2",
|
|
63
63
|
"nanoid": "^5.0.7",
|