@tscircuit/core 0.0.275 → 0.0.277
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 +16 -2
- package/dist/index.js +276 -168
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -45,8 +45,9 @@ declare abstract class Renderable implements IRenderable {
|
|
|
45
45
|
_renderId: string;
|
|
46
46
|
_currentRenderPhase: RenderPhase | null;
|
|
47
47
|
private _asyncEffects;
|
|
48
|
+
parent: Renderable | null;
|
|
48
49
|
constructor(props: any);
|
|
49
|
-
|
|
50
|
+
_markDirty(phase: RenderPhase): void;
|
|
50
51
|
protected _queueAsyncEffect(effectName: string, effect: () => Promise<void>): void;
|
|
51
52
|
protected _emitRenderLifecycleEvent(phase: RenderPhase, startOrEnd: "start" | "end"): void;
|
|
52
53
|
getString(): string;
|
|
@@ -168,6 +169,12 @@ declare const Circuit: typeof RootCircuit;
|
|
|
168
169
|
interface ISubcircuit extends PrimitiveComponent {
|
|
169
170
|
_shouldUseTraceByTraceRouting(): boolean;
|
|
170
171
|
_parsedProps: z.infer<typeof subcircuitGroupProps>;
|
|
172
|
+
subcircuit_id: string | null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface IGroup extends PrimitiveComponent {
|
|
176
|
+
source_group_id: string | null;
|
|
177
|
+
pcb_group_id: string | null;
|
|
171
178
|
}
|
|
172
179
|
|
|
173
180
|
interface BaseComponentConfig {
|
|
@@ -327,6 +334,7 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
|
|
|
327
334
|
};
|
|
328
335
|
doesSelectorMatch(selector: string): boolean;
|
|
329
336
|
getSubcircuit(): ISubcircuit;
|
|
337
|
+
getGroup(): IGroup | null;
|
|
330
338
|
selectAll(selector: string): PrimitiveComponent[];
|
|
331
339
|
selectOne<T = PrimitiveComponent>(selector: string, options?: {
|
|
332
340
|
type?: string;
|
|
@@ -919,7 +927,9 @@ interface SimpleRouteJson {
|
|
|
919
927
|
}
|
|
920
928
|
|
|
921
929
|
declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps> extends NormalComponent<Props> implements ISubcircuit {
|
|
922
|
-
|
|
930
|
+
pcb_group_id: string | null;
|
|
931
|
+
subcircuit_id: string | null;
|
|
932
|
+
_hasStartedAsyncAutorouting: boolean;
|
|
923
933
|
_asyncAutoroutingResult: {
|
|
924
934
|
output_simple_route_json?: SimpleRouteJson;
|
|
925
935
|
output_pcb_traces?: PcbTrace[];
|
|
@@ -933,6 +943,10 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
|
|
|
933
943
|
doInitialCreateTraceHintsFromProps(): void;
|
|
934
944
|
_getSimpleRouteJsonFromPcbTraces(): SimpleRouteJson;
|
|
935
945
|
doInitialSourceAddConnectivityMapKey(): void;
|
|
946
|
+
_areChildSubcircuitsRouted(): boolean;
|
|
947
|
+
_shouldRouteAsync(): boolean;
|
|
948
|
+
_runEffectMakeHttpAutoroutingRequest(): Promise<void>;
|
|
949
|
+
_startAsyncAutorouting(): void;
|
|
936
950
|
doInitialPcbTraceRender(): void;
|
|
937
951
|
updatePcbTraceRender(): void;
|
|
938
952
|
_updatePcbTraceRenderFromSimpleRouteJson(): void;
|
package/dist/index.js
CHANGED
|
@@ -105,6 +105,7 @@ var Renderable = class {
|
|
|
105
105
|
_renderId;
|
|
106
106
|
_currentRenderPhase = null;
|
|
107
107
|
_asyncEffects = [];
|
|
108
|
+
parent = null;
|
|
108
109
|
constructor(props) {
|
|
109
110
|
this._renderId = `${globalRenderCounter++}`;
|
|
110
111
|
this.children = [];
|
|
@@ -122,6 +123,9 @@ var Renderable = class {
|
|
|
122
123
|
for (let i = phaseIndex + 1; i < orderedRenderPhases.length; i++) {
|
|
123
124
|
this.renderPhaseStates[orderedRenderPhases[i]].dirty = true;
|
|
124
125
|
}
|
|
126
|
+
if (this.parent?._markDirty) {
|
|
127
|
+
this.parent._markDirty(phase);
|
|
128
|
+
}
|
|
125
129
|
}
|
|
126
130
|
_queueAsyncEffect(effectName, effect) {
|
|
127
131
|
const asyncEffect = {
|
|
@@ -525,6 +529,9 @@ var underscorifyPortArrangement = (portArrangement) => {
|
|
|
525
529
|
return void 0;
|
|
526
530
|
};
|
|
527
531
|
|
|
532
|
+
// lib/components/base-components/PrimitiveComponent.ts
|
|
533
|
+
import Debug2 from "debug";
|
|
534
|
+
|
|
528
535
|
// lib/errors/InvalidProps.ts
|
|
529
536
|
var InvalidProps = class extends Error {
|
|
530
537
|
constructor(componentName, originalProps, formattedError) {
|
|
@@ -592,7 +599,6 @@ import {
|
|
|
592
599
|
translate
|
|
593
600
|
} from "transformation-matrix";
|
|
594
601
|
import { z as z2 } from "zod";
|
|
595
|
-
import Debug2 from "debug";
|
|
596
602
|
var debugSelectAll = Debug2("tscircuit:primitive-component:selectAll");
|
|
597
603
|
var PrimitiveComponent = class extends Renderable {
|
|
598
604
|
parent = null;
|
|
@@ -989,6 +995,10 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
989
995
|
throw new Error("Component is not inside an opaque group (no board?)");
|
|
990
996
|
return group;
|
|
991
997
|
}
|
|
998
|
+
getGroup() {
|
|
999
|
+
if (this.isGroup) return this;
|
|
1000
|
+
return this.parent?.getGroup?.() ?? null;
|
|
1001
|
+
}
|
|
992
1002
|
selectAll(selector) {
|
|
993
1003
|
debugSelectAll(`selectAll: "${selector}"`);
|
|
994
1004
|
const parts = selector.trim().split(/\s+/);
|
|
@@ -1327,9 +1337,7 @@ var createNetsFromProps = (component, props) => {
|
|
|
1327
1337
|
|
|
1328
1338
|
// lib/components/primitive-components/SmtPad.ts
|
|
1329
1339
|
import { smtPadProps } from "@tscircuit/props";
|
|
1330
|
-
import {
|
|
1331
|
-
decomposeTSR
|
|
1332
|
-
} from "transformation-matrix";
|
|
1340
|
+
import { decomposeTSR } from "transformation-matrix";
|
|
1333
1341
|
var SmtPad = class extends PrimitiveComponent {
|
|
1334
1342
|
pcb_smtpad_id = null;
|
|
1335
1343
|
matchedPort = null;
|
|
@@ -1373,6 +1381,7 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1373
1381
|
const { _parsedProps: props } = this;
|
|
1374
1382
|
if (!props.portHints) return;
|
|
1375
1383
|
const container = this.getPrimitiveContainer();
|
|
1384
|
+
const subcircuit = this.getSubcircuit();
|
|
1376
1385
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
1377
1386
|
const containerCenter = container?._getGlobalPcbPositionBeforeLayout();
|
|
1378
1387
|
const decomposedMat = decomposeTSR(
|
|
@@ -1394,7 +1403,8 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1394
1403
|
radius: props.radius,
|
|
1395
1404
|
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
1396
1405
|
x: position.x,
|
|
1397
|
-
y: position.y
|
|
1406
|
+
y: position.y,
|
|
1407
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0
|
|
1398
1408
|
});
|
|
1399
1409
|
db.pcb_solder_paste.insert({
|
|
1400
1410
|
layer: pcb_smtpad.layer,
|
|
@@ -1404,7 +1414,9 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1404
1414
|
x: pcb_smtpad.x,
|
|
1405
1415
|
y: pcb_smtpad.y,
|
|
1406
1416
|
pcb_component_id: pcb_smtpad.pcb_component_id,
|
|
1407
|
-
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id
|
|
1417
|
+
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id,
|
|
1418
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1419
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1408
1420
|
});
|
|
1409
1421
|
} else if (props.shape === "rect") {
|
|
1410
1422
|
pcb_smtpad = parentRotation === 0 || isRotated90 ? db.pcb_smtpad.insert({
|
|
@@ -1419,7 +1431,9 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1419
1431
|
},
|
|
1420
1432
|
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
1421
1433
|
x: position.x,
|
|
1422
|
-
y: position.y
|
|
1434
|
+
y: position.y,
|
|
1435
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1436
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1423
1437
|
}) : db.pcb_smtpad.insert({
|
|
1424
1438
|
pcb_component_id,
|
|
1425
1439
|
layer: props.layer ?? "top",
|
|
@@ -1428,7 +1442,9 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1428
1442
|
x: position.x,
|
|
1429
1443
|
y: position.y,
|
|
1430
1444
|
ccw_rotation: parentRotation,
|
|
1431
|
-
port_hints: props.portHints.map((ph) => ph.toString())
|
|
1445
|
+
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
1446
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1447
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1432
1448
|
});
|
|
1433
1449
|
if (pcb_smtpad.shape === "rect")
|
|
1434
1450
|
db.pcb_solder_paste.insert({
|
|
@@ -1440,7 +1456,9 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1440
1456
|
x: pcb_smtpad.x,
|
|
1441
1457
|
y: pcb_smtpad.y,
|
|
1442
1458
|
pcb_component_id: pcb_smtpad.pcb_component_id,
|
|
1443
|
-
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id
|
|
1459
|
+
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id,
|
|
1460
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1461
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1444
1462
|
});
|
|
1445
1463
|
}
|
|
1446
1464
|
if (pcb_smtpad) {
|
|
@@ -1524,7 +1542,7 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
1524
1542
|
|
|
1525
1543
|
// lib/components/primitive-components/SilkscreenPath.ts
|
|
1526
1544
|
import { silkscreenPathProps } from "@tscircuit/props";
|
|
1527
|
-
import { applyToPoint as
|
|
1545
|
+
import { applyToPoint as applyToPoint2 } from "transformation-matrix";
|
|
1528
1546
|
var SilkscreenPath = class extends PrimitiveComponent {
|
|
1529
1547
|
pcb_silkscreen_path_id = null;
|
|
1530
1548
|
get config() {
|
|
@@ -1544,11 +1562,12 @@ var SilkscreenPath = class extends PrimitiveComponent {
|
|
|
1544
1562
|
);
|
|
1545
1563
|
}
|
|
1546
1564
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
1565
|
+
const subcircuit = this.getSubcircuit();
|
|
1547
1566
|
const pcb_silkscreen_path = db.pcb_silkscreen_path.insert({
|
|
1548
1567
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
1549
1568
|
layer,
|
|
1550
1569
|
route: props.route.map((p) => {
|
|
1551
|
-
const transformedPosition =
|
|
1570
|
+
const transformedPosition = applyToPoint2(transform, {
|
|
1552
1571
|
x: p.x,
|
|
1553
1572
|
y: p.y
|
|
1554
1573
|
});
|
|
@@ -1558,7 +1577,9 @@ var SilkscreenPath = class extends PrimitiveComponent {
|
|
|
1558
1577
|
y: transformedPosition.y
|
|
1559
1578
|
};
|
|
1560
1579
|
}),
|
|
1561
|
-
stroke_width: props.strokeWidth ?? 0.1
|
|
1580
|
+
stroke_width: props.strokeWidth ?? 0.1,
|
|
1581
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1582
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1562
1583
|
});
|
|
1563
1584
|
this.pcb_silkscreen_path_id = pcb_silkscreen_path.pcb_silkscreen_path_id;
|
|
1564
1585
|
}
|
|
@@ -1636,6 +1657,7 @@ var PlatedHole = class extends PrimitiveComponent {
|
|
|
1636
1657
|
const { _parsedProps: props } = this;
|
|
1637
1658
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
1638
1659
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
1660
|
+
const subcircuit = this.getSubcircuit();
|
|
1639
1661
|
if (props.shape === "circle") {
|
|
1640
1662
|
const pcb_plated_hole = db.pcb_plated_hole.insert({
|
|
1641
1663
|
pcb_component_id,
|
|
@@ -1647,7 +1669,9 @@ var PlatedHole = class extends PrimitiveComponent {
|
|
|
1647
1669
|
port_hints: this.getNameAndAliases(),
|
|
1648
1670
|
x: position.x,
|
|
1649
1671
|
y: position.y,
|
|
1650
|
-
layers: ["top", "bottom"]
|
|
1672
|
+
layers: ["top", "bottom"],
|
|
1673
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1674
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1651
1675
|
});
|
|
1652
1676
|
this.pcb_plated_hole_id = pcb_plated_hole.pcb_plated_hole_id;
|
|
1653
1677
|
} else if (props.shape === "pill" || props.shape === "oval") {
|
|
@@ -1662,7 +1686,9 @@ var PlatedHole = class extends PrimitiveComponent {
|
|
|
1662
1686
|
port_hints: this.getNameAndAliases(),
|
|
1663
1687
|
x: position.x,
|
|
1664
1688
|
y: position.y,
|
|
1665
|
-
layers: ["top", "bottom"]
|
|
1689
|
+
layers: ["top", "bottom"],
|
|
1690
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1691
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1666
1692
|
// NOTE: currently PcbPlatedHoleOval erroneously includes both the shape "pill" and "oval"
|
|
1667
1693
|
});
|
|
1668
1694
|
this.pcb_plated_hole_id = pcb_plated_hole.pcb_plated_hole_id;
|
|
@@ -1691,6 +1717,7 @@ var Keepout = class extends PrimitiveComponent {
|
|
|
1691
1717
|
}
|
|
1692
1718
|
doInitialPcbPrimitiveRender() {
|
|
1693
1719
|
if (this.root?.pcbDisabled) return;
|
|
1720
|
+
const subcircuit = this.getSubcircuit();
|
|
1694
1721
|
const { db } = this.root;
|
|
1695
1722
|
const { _parsedProps: props } = this;
|
|
1696
1723
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
@@ -1708,7 +1735,9 @@ var Keepout = class extends PrimitiveComponent {
|
|
|
1708
1735
|
center: {
|
|
1709
1736
|
x: position.x,
|
|
1710
1737
|
y: position.y
|
|
1711
|
-
}
|
|
1738
|
+
},
|
|
1739
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1740
|
+
pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
|
|
1712
1741
|
});
|
|
1713
1742
|
} else if (props.shape === "rect") {
|
|
1714
1743
|
pcb_keepout = db.pcb_keepout.insert({
|
|
@@ -1719,7 +1748,9 @@ var Keepout = class extends PrimitiveComponent {
|
|
|
1719
1748
|
center: {
|
|
1720
1749
|
x: position.x,
|
|
1721
1750
|
y: position.y
|
|
1722
|
-
}
|
|
1751
|
+
},
|
|
1752
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1753
|
+
pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
|
|
1723
1754
|
});
|
|
1724
1755
|
}
|
|
1725
1756
|
if (pcb_keepout) {
|
|
@@ -1747,13 +1778,16 @@ var Hole = class extends PrimitiveComponent {
|
|
|
1747
1778
|
if (this.root?.pcbDisabled) return;
|
|
1748
1779
|
const { db } = this.root;
|
|
1749
1780
|
const { _parsedProps: props } = this;
|
|
1781
|
+
const subcircuit = this.getSubcircuit();
|
|
1750
1782
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
1751
1783
|
const inserted_hole = db.pcb_hole.insert({
|
|
1752
1784
|
hole_shape: "circle",
|
|
1753
1785
|
// @ts-ignore
|
|
1754
1786
|
hole_diameter: props.diameter,
|
|
1755
1787
|
x: position.x,
|
|
1756
|
-
y: position.y
|
|
1788
|
+
y: position.y,
|
|
1789
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1790
|
+
pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
|
|
1757
1791
|
});
|
|
1758
1792
|
this.pcb_hole_id = inserted_hole.pcb_hole_id;
|
|
1759
1793
|
}
|
|
@@ -1910,7 +1944,7 @@ function getRelativeDirection(pointA, pointB) {
|
|
|
1910
1944
|
|
|
1911
1945
|
// lib/components/primitive-components/Port/Port.ts
|
|
1912
1946
|
import "schematic-symbols";
|
|
1913
|
-
import { applyToPoint as
|
|
1947
|
+
import { applyToPoint as applyToPoint3, compose as compose2, translate as translate2 } from "transformation-matrix";
|
|
1914
1948
|
import { z as z4 } from "zod";
|
|
1915
1949
|
|
|
1916
1950
|
// lib/components/primitive-components/Port/areAllPcbPrimitivesOverlapping.ts
|
|
@@ -2020,11 +2054,11 @@ var Port = class extends PrimitiveComponent {
|
|
|
2020
2054
|
_getGlobalSchematicPositionBeforeLayout() {
|
|
2021
2055
|
const symbol = this.parent?.getSchematicSymbol();
|
|
2022
2056
|
if (symbol && this.schematicSymbolPortDef) {
|
|
2023
|
-
const transform =
|
|
2057
|
+
const transform = compose2(
|
|
2024
2058
|
this.parent.computeSchematicGlobalTransform(),
|
|
2025
|
-
|
|
2059
|
+
translate2(-symbol.center.x, -symbol.center.y)
|
|
2026
2060
|
);
|
|
2027
|
-
return
|
|
2061
|
+
return applyToPoint3(transform, this.schematicSymbolPortDef);
|
|
2028
2062
|
}
|
|
2029
2063
|
const parentBoxDim = this?.parent?._getSchematicBoxDimensions();
|
|
2030
2064
|
if (parentBoxDim && this.props.pinNumber !== void 0) {
|
|
@@ -2034,7 +2068,7 @@ var Port = class extends PrimitiveComponent {
|
|
|
2034
2068
|
if (!localPortPosition) {
|
|
2035
2069
|
return { x: 0, y: 0 };
|
|
2036
2070
|
}
|
|
2037
|
-
return
|
|
2071
|
+
return applyToPoint3(
|
|
2038
2072
|
this.parent.computeSchematicGlobalTransform(),
|
|
2039
2073
|
localPortPosition
|
|
2040
2074
|
);
|
|
@@ -2145,9 +2179,12 @@ var Port = class extends PrimitiveComponent {
|
|
|
2145
2179
|
matchCenter = getCenterOfPcbPrimitives(pcbMatches);
|
|
2146
2180
|
}
|
|
2147
2181
|
if (matchCenter) {
|
|
2182
|
+
const subcircuit = this.getSubcircuit();
|
|
2148
2183
|
const pcb_port = db.pcb_port.insert({
|
|
2149
2184
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
2150
2185
|
layers: this.getAvailablePcbLayers(),
|
|
2186
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
2187
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0,
|
|
2151
2188
|
...matchCenter,
|
|
2152
2189
|
source_port_id: this.source_port_id
|
|
2153
2190
|
});
|
|
@@ -3457,18 +3494,74 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
3457
3494
|
|
|
3458
3495
|
// lib/components/normal-components/Board.ts
|
|
3459
3496
|
import { boardProps } from "@tscircuit/props";
|
|
3460
|
-
import { identity as
|
|
3497
|
+
import { identity as identity3 } from "transformation-matrix";
|
|
3498
|
+
|
|
3499
|
+
// lib/components/primitive-components/Group/Group.ts
|
|
3500
|
+
import { groupProps } from "@tscircuit/props";
|
|
3501
|
+
import * as SAL from "@tscircuit/schematic-autolayout";
|
|
3502
|
+
import "circuit-json";
|
|
3503
|
+
import { ConnectivityMap } from "circuit-json-to-connectivity-map";
|
|
3504
|
+
import Debug5 from "debug";
|
|
3505
|
+
|
|
3506
|
+
// lib/utils/autorouting/getSimpleRouteJsonFromTracesAndDb.ts
|
|
3507
|
+
import { getObstaclesFromSoup } from "@tscircuit/infgrid-ijump-astar";
|
|
3508
|
+
var getSimpleRouteJsonFromTracesAndDb = ({
|
|
3509
|
+
db,
|
|
3510
|
+
traces,
|
|
3511
|
+
minTraceWidth = 0.1
|
|
3512
|
+
}) => {
|
|
3513
|
+
const obstacles = getObstaclesFromSoup([
|
|
3514
|
+
...db.pcb_component.list(),
|
|
3515
|
+
...db.pcb_smtpad.list(),
|
|
3516
|
+
...db.pcb_plated_hole.list()
|
|
3517
|
+
]);
|
|
3518
|
+
const allPoints = obstacles.flatMap((o) => [
|
|
3519
|
+
{
|
|
3520
|
+
x: o.center.x - o.width / 2,
|
|
3521
|
+
y: o.center.y - o.height / 2
|
|
3522
|
+
},
|
|
3523
|
+
{
|
|
3524
|
+
x: o.center.x + o.width / 2,
|
|
3525
|
+
y: o.center.y + o.height / 2
|
|
3526
|
+
}
|
|
3527
|
+
]);
|
|
3528
|
+
const bounds = {
|
|
3529
|
+
minX: Math.min(...allPoints.map((p) => p.x)) - 1,
|
|
3530
|
+
maxX: Math.max(...allPoints.map((p) => p.x)) + 1,
|
|
3531
|
+
minY: Math.min(...allPoints.map((p) => p.y)) - 1,
|
|
3532
|
+
maxY: Math.max(...allPoints.map((p) => p.y)) + 1
|
|
3533
|
+
};
|
|
3534
|
+
const connections = traces.map((trace) => {
|
|
3535
|
+
const connectedPorts = trace._findConnectedPorts();
|
|
3536
|
+
if (!connectedPorts.allPortsFound || connectedPorts.ports.length < 2)
|
|
3537
|
+
return null;
|
|
3538
|
+
return {
|
|
3539
|
+
name: trace.source_trace_id ?? "",
|
|
3540
|
+
pointsToConnect: connectedPorts.ports.map((port) => {
|
|
3541
|
+
const pos = port._getGlobalPcbPositionBeforeLayout();
|
|
3542
|
+
return {
|
|
3543
|
+
x: pos.x,
|
|
3544
|
+
y: pos.y,
|
|
3545
|
+
layer: port.getAvailablePcbLayers()[0] ?? "top"
|
|
3546
|
+
};
|
|
3547
|
+
})
|
|
3548
|
+
};
|
|
3549
|
+
}).filter((c) => c !== null);
|
|
3550
|
+
return {
|
|
3551
|
+
bounds,
|
|
3552
|
+
obstacles: [],
|
|
3553
|
+
connections,
|
|
3554
|
+
layerCount: 2,
|
|
3555
|
+
minTraceWidth
|
|
3556
|
+
};
|
|
3557
|
+
};
|
|
3461
3558
|
|
|
3462
3559
|
// lib/components/primitive-components/Group/Group.ts
|
|
3463
|
-
import {
|
|
3464
|
-
groupProps
|
|
3465
|
-
} from "@tscircuit/props";
|
|
3466
|
-
import "transformation-matrix";
|
|
3467
3560
|
import "zod";
|
|
3468
3561
|
|
|
3469
3562
|
// lib/components/primitive-components/TraceHint.ts
|
|
3470
3563
|
import { traceHintProps } from "@tscircuit/props";
|
|
3471
|
-
import { applyToPoint as
|
|
3564
|
+
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
3472
3565
|
var TraceHint = class extends PrimitiveComponent {
|
|
3473
3566
|
matchedPort = null;
|
|
3474
3567
|
get config() {
|
|
@@ -3508,7 +3601,7 @@ var TraceHint = class extends PrimitiveComponent {
|
|
|
3508
3601
|
const globalTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
3509
3602
|
return offsets.map(
|
|
3510
3603
|
(offset) => ({
|
|
3511
|
-
...
|
|
3604
|
+
...applyToPoint4(globalTransform, offset),
|
|
3512
3605
|
via: offset.via,
|
|
3513
3606
|
to_layer: offset.to_layer,
|
|
3514
3607
|
trace_width: offset.trace_width
|
|
@@ -3528,67 +3621,10 @@ var TraceHint = class extends PrimitiveComponent {
|
|
|
3528
3621
|
};
|
|
3529
3622
|
|
|
3530
3623
|
// 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
3624
|
var Group = class extends NormalComponent {
|
|
3591
|
-
|
|
3625
|
+
pcb_group_id = null;
|
|
3626
|
+
subcircuit_id = null;
|
|
3627
|
+
_hasStartedAsyncAutorouting = false;
|
|
3592
3628
|
_asyncAutoroutingResult = null;
|
|
3593
3629
|
get config() {
|
|
3594
3630
|
return {
|
|
@@ -3599,11 +3635,14 @@ var Group = class extends NormalComponent {
|
|
|
3599
3635
|
doInitialSourceRender() {
|
|
3600
3636
|
const { db } = this.root;
|
|
3601
3637
|
const source_group = db.source_group.insert({
|
|
3602
|
-
name: this._parsedProps.name
|
|
3603
|
-
|
|
3638
|
+
name: this._parsedProps.name,
|
|
3639
|
+
is_subcircuit: this.isSubcircuit
|
|
3604
3640
|
});
|
|
3605
3641
|
this.subcircuit_id = `subcircuit_${source_group.source_group_id}`;
|
|
3606
3642
|
this.source_group_id = source_group.source_group_id;
|
|
3643
|
+
db.source_group.update(source_group.source_group_id, {
|
|
3644
|
+
subcircuit_id: this.subcircuit_id
|
|
3645
|
+
});
|
|
3607
3646
|
}
|
|
3608
3647
|
doInitialPcbComponentRender() {
|
|
3609
3648
|
if (this.root?.pcbDisabled) return;
|
|
@@ -3619,6 +3658,7 @@ var Group = class extends NormalComponent {
|
|
|
3619
3658
|
pcb_component_ids: [],
|
|
3620
3659
|
source_group_id: this.source_group_id
|
|
3621
3660
|
});
|
|
3661
|
+
this.pcb_group_id = pcb_group.pcb_group_id;
|
|
3622
3662
|
}
|
|
3623
3663
|
doInitialCreateTraceHintsFromProps() {
|
|
3624
3664
|
const { _parsedProps: props } = this;
|
|
@@ -3674,63 +3714,91 @@ var Group = class extends NormalComponent {
|
|
|
3674
3714
|
});
|
|
3675
3715
|
}
|
|
3676
3716
|
}
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
const
|
|
3682
|
-
|
|
3717
|
+
_areChildSubcircuitsRouted() {
|
|
3718
|
+
const subcircuitChildren = this.selectAll("group").filter(
|
|
3719
|
+
(g) => g.isSubcircuit
|
|
3720
|
+
);
|
|
3721
|
+
for (const subcircuitChild of subcircuitChildren) {
|
|
3722
|
+
if (subcircuitChild._shouldRouteAsync() && !subcircuitChild._asyncAutoroutingResult) {
|
|
3723
|
+
return false;
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
return true;
|
|
3727
|
+
}
|
|
3728
|
+
_shouldRouteAsync() {
|
|
3729
|
+
const props = this._parsedProps;
|
|
3730
|
+
if (props.autorouter === "auto-local") return true;
|
|
3731
|
+
if (props.autorouter === "auto-cloud") return true;
|
|
3732
|
+
if (props.autorouter === "sequential-trace") return false;
|
|
3733
|
+
if (typeof props.autorouter === "object") return true;
|
|
3734
|
+
return false;
|
|
3735
|
+
}
|
|
3736
|
+
async _runEffectMakeHttpAutoroutingRequest() {
|
|
3737
|
+
const debug4 = Debug5("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
|
|
3738
|
+
const props = this._parsedProps;
|
|
3739
|
+
const serverUrl = props.autorouter?.serverUrl ?? "https://registry-api.tscircuit.com";
|
|
3740
|
+
const serverMode = props.autorouter?.serverMode ?? "job";
|
|
3683
3741
|
const fetchWithDebug = (url, options) => {
|
|
3684
3742
|
debug4("fetching", url);
|
|
3685
3743
|
return fetch(url, options);
|
|
3686
3744
|
};
|
|
3687
|
-
|
|
3688
|
-
if (
|
|
3689
|
-
|
|
3690
|
-
const { autorouting_result: autorouting_result2 } = await fetchWithDebug(
|
|
3691
|
-
`${serverUrl}/autorouting/solve`,
|
|
3692
|
-
{
|
|
3693
|
-
method: "POST",
|
|
3694
|
-
body: JSON.stringify({
|
|
3695
|
-
input_simple_route_json: this._getSimpleRouteJsonFromPcbTraces()
|
|
3696
|
-
}),
|
|
3697
|
-
headers: { "Content-Type": "application/json" }
|
|
3698
|
-
}
|
|
3699
|
-
).then((r) => r.json());
|
|
3700
|
-
this._asyncAutoroutingResult = autorouting_result2;
|
|
3701
|
-
this._markDirty("PcbTraceRender");
|
|
3702
|
-
return;
|
|
3703
|
-
}
|
|
3704
|
-
const { autorouting_result } = await fetchWithDebug(
|
|
3745
|
+
if (serverMode === "solve-endpoint") {
|
|
3746
|
+
if (this.props.autorouter?.inputFormat === "simplified") {
|
|
3747
|
+
const { autorouting_result: autorouting_result2 } = await fetchWithDebug(
|
|
3705
3748
|
`${serverUrl}/autorouting/solve`,
|
|
3706
3749
|
{
|
|
3707
3750
|
method: "POST",
|
|
3708
3751
|
body: JSON.stringify({
|
|
3709
|
-
|
|
3752
|
+
input_simple_route_json: this._getSimpleRouteJsonFromPcbTraces()
|
|
3710
3753
|
}),
|
|
3711
3754
|
headers: { "Content-Type": "application/json" }
|
|
3712
3755
|
}
|
|
3713
3756
|
).then((r) => r.json());
|
|
3714
|
-
this._asyncAutoroutingResult =
|
|
3757
|
+
this._asyncAutoroutingResult = autorouting_result2;
|
|
3715
3758
|
this._markDirty("PcbTraceRender");
|
|
3716
3759
|
return;
|
|
3717
3760
|
}
|
|
3718
|
-
const {
|
|
3719
|
-
`${serverUrl}/autorouting/
|
|
3761
|
+
const { autorouting_result } = await fetchWithDebug(
|
|
3762
|
+
`${serverUrl}/autorouting/solve`,
|
|
3720
3763
|
{
|
|
3721
3764
|
method: "POST",
|
|
3722
3765
|
body: JSON.stringify({
|
|
3723
|
-
input_circuit_json: this.root.db.toArray()
|
|
3724
|
-
provider: "freerouting",
|
|
3725
|
-
autostart: true,
|
|
3726
|
-
display_name: this.root?.name
|
|
3766
|
+
input_circuit_json: this.root.db.toArray()
|
|
3727
3767
|
}),
|
|
3728
3768
|
headers: { "Content-Type": "application/json" }
|
|
3729
3769
|
}
|
|
3730
3770
|
).then((r) => r.json());
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3771
|
+
this._asyncAutoroutingResult = autorouting_result;
|
|
3772
|
+
this._markDirty("PcbTraceRender");
|
|
3773
|
+
return;
|
|
3774
|
+
}
|
|
3775
|
+
const { autorouting_job } = await fetchWithDebug(
|
|
3776
|
+
`${serverUrl}/autorouting/jobs/create`,
|
|
3777
|
+
{
|
|
3778
|
+
method: "POST",
|
|
3779
|
+
body: JSON.stringify({
|
|
3780
|
+
input_circuit_json: this.root.db.toArray(),
|
|
3781
|
+
provider: "freerouting",
|
|
3782
|
+
autostart: true,
|
|
3783
|
+
display_name: this.root?.name
|
|
3784
|
+
}),
|
|
3785
|
+
headers: { "Content-Type": "application/json" }
|
|
3786
|
+
}
|
|
3787
|
+
).then((r) => r.json());
|
|
3788
|
+
while (true) {
|
|
3789
|
+
const { autorouting_job: job } = await fetchWithDebug(
|
|
3790
|
+
`${serverUrl}/autorouting/jobs/get`,
|
|
3791
|
+
{
|
|
3792
|
+
method: "POST",
|
|
3793
|
+
body: JSON.stringify({
|
|
3794
|
+
autorouting_job_id: autorouting_job.autorouting_job_id
|
|
3795
|
+
}),
|
|
3796
|
+
headers: { "Content-Type": "application/json" }
|
|
3797
|
+
}
|
|
3798
|
+
).then((r) => r.json());
|
|
3799
|
+
if (job.is_finished) {
|
|
3800
|
+
const { autorouting_job_output } = await fetchWithDebug(
|
|
3801
|
+
`${serverUrl}/autorouting/jobs/get_output`,
|
|
3734
3802
|
{
|
|
3735
3803
|
method: "POST",
|
|
3736
3804
|
body: JSON.stringify({
|
|
@@ -3739,33 +3807,51 @@ var Group = class extends NormalComponent {
|
|
|
3739
3807
|
headers: { "Content-Type": "application/json" }
|
|
3740
3808
|
}
|
|
3741
3809
|
).then((r) => r.json());
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
body: JSON.stringify({
|
|
3748
|
-
autorouting_job_id: autorouting_job.autorouting_job_id
|
|
3749
|
-
}),
|
|
3750
|
-
headers: { "Content-Type": "application/json" }
|
|
3751
|
-
}
|
|
3752
|
-
).then((r) => r.json());
|
|
3753
|
-
this._asyncAutoroutingResult = {
|
|
3754
|
-
output_pcb_traces: autorouting_job_output.output_pcb_traces
|
|
3755
|
-
};
|
|
3756
|
-
this._markDirty("PcbTraceRender");
|
|
3757
|
-
break;
|
|
3758
|
-
}
|
|
3759
|
-
if (job.has_error) {
|
|
3760
|
-
throw new Error(
|
|
3761
|
-
`Autorouting job failed: ${JSON.stringify(job.error)}`
|
|
3762
|
-
);
|
|
3763
|
-
}
|
|
3764
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
3810
|
+
this._asyncAutoroutingResult = {
|
|
3811
|
+
output_pcb_traces: autorouting_job_output.output_pcb_traces
|
|
3812
|
+
};
|
|
3813
|
+
this._markDirty("PcbTraceRender");
|
|
3814
|
+
break;
|
|
3765
3815
|
}
|
|
3766
|
-
|
|
3816
|
+
if (job.has_error) {
|
|
3817
|
+
throw new Error(`Autorouting job failed: ${JSON.stringify(job.error)}`);
|
|
3818
|
+
}
|
|
3819
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
_startAsyncAutorouting() {
|
|
3823
|
+
this._hasStartedAsyncAutorouting = true;
|
|
3824
|
+
this._queueAsyncEffect(
|
|
3825
|
+
"make-http-autorouting-request",
|
|
3826
|
+
async () => this._runEffectMakeHttpAutoroutingRequest()
|
|
3827
|
+
);
|
|
3828
|
+
}
|
|
3829
|
+
doInitialPcbTraceRender() {
|
|
3830
|
+
const debug4 = Debug5("tscircuit:core:doInitialPcbTraceRender");
|
|
3831
|
+
if (this.root?.pcbDisabled) return;
|
|
3832
|
+
if (this._shouldUseTraceByTraceRouting()) return;
|
|
3833
|
+
if (!this._areChildSubcircuitsRouted()) {
|
|
3834
|
+
debug4(
|
|
3835
|
+
`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`
|
|
3836
|
+
);
|
|
3837
|
+
return;
|
|
3838
|
+
}
|
|
3839
|
+
debug4(
|
|
3840
|
+
`[${this.getString()}] no child subcircuits to wait for, initiating async routing`
|
|
3841
|
+
);
|
|
3842
|
+
this._startAsyncAutorouting();
|
|
3767
3843
|
}
|
|
3768
3844
|
updatePcbTraceRender() {
|
|
3845
|
+
const debug4 = Debug5("tscircuit:core:updatePcbTraceRender");
|
|
3846
|
+
if (this._shouldRouteAsync() && !this._hasStartedAsyncAutorouting) {
|
|
3847
|
+
if (this._areChildSubcircuitsRouted()) {
|
|
3848
|
+
debug4(
|
|
3849
|
+
`[${this.getString()}] child subcircuits are now routed, starting async autorouting`
|
|
3850
|
+
);
|
|
3851
|
+
this._startAsyncAutorouting();
|
|
3852
|
+
}
|
|
3853
|
+
return;
|
|
3854
|
+
}
|
|
3769
3855
|
if (!this._asyncAutoroutingResult) return;
|
|
3770
3856
|
if (this._shouldUseTraceByTraceRouting()) return;
|
|
3771
3857
|
const { db } = this.root;
|
|
@@ -3893,7 +3979,7 @@ var Board = class extends Group {
|
|
|
3893
3979
|
this.pcb_board_id = null;
|
|
3894
3980
|
}
|
|
3895
3981
|
_computePcbGlobalTransformBeforeLayout() {
|
|
3896
|
-
return
|
|
3982
|
+
return identity3();
|
|
3897
3983
|
}
|
|
3898
3984
|
};
|
|
3899
3985
|
|
|
@@ -3912,7 +3998,7 @@ var FTYPE = stringProxy;
|
|
|
3912
3998
|
// lib/components/primitive-components/Trace/Trace.ts
|
|
3913
3999
|
import {
|
|
3914
4000
|
MultilayerIjump,
|
|
3915
|
-
getObstaclesFromSoup as
|
|
4001
|
+
getObstaclesFromSoup as getObstaclesFromSoup2
|
|
3916
4002
|
} from "@tscircuit/infgrid-ijump-astar";
|
|
3917
4003
|
import { traceProps } from "@tscircuit/props";
|
|
3918
4004
|
import "circuit-json";
|
|
@@ -4810,7 +4896,9 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4810
4896
|
if (cachedRoute) {
|
|
4811
4897
|
const pcb_trace2 = db.pcb_trace.insert({
|
|
4812
4898
|
route: cachedRoute.flatMap((trace) => trace.route),
|
|
4813
|
-
source_trace_id: this.source_trace_id
|
|
4899
|
+
source_trace_id: this.source_trace_id,
|
|
4900
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
4901
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
4814
4902
|
});
|
|
4815
4903
|
this.pcb_trace_id = pcb_trace2.pcb_trace_id;
|
|
4816
4904
|
return;
|
|
@@ -4914,7 +5002,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4914
5002
|
this.root.db.toArray()
|
|
4915
5003
|
);
|
|
4916
5004
|
const [obstacles, errGettingObstacles] = tryNow(
|
|
4917
|
-
() =>
|
|
5005
|
+
() => getObstaclesFromSoup2(this.root.db.toArray())
|
|
4918
5006
|
// Remove as any when autorouting-dataset gets updated
|
|
4919
5007
|
);
|
|
4920
5008
|
if (errGettingObstacles) {
|
|
@@ -5694,7 +5782,7 @@ var Constraint2 = class extends PrimitiveComponent {
|
|
|
5694
5782
|
|
|
5695
5783
|
// lib/components/primitive-components/FabricationNotePath.ts
|
|
5696
5784
|
import { fabricationNotePathProps } from "@tscircuit/props";
|
|
5697
|
-
import { applyToPoint as
|
|
5785
|
+
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
5698
5786
|
var FabricationNotePath = class extends PrimitiveComponent {
|
|
5699
5787
|
fabrication_note_path_id = null;
|
|
5700
5788
|
get config() {
|
|
@@ -5706,6 +5794,7 @@ var FabricationNotePath = class extends PrimitiveComponent {
|
|
|
5706
5794
|
doInitialPcbPrimitiveRender() {
|
|
5707
5795
|
if (this.root?.pcbDisabled) return;
|
|
5708
5796
|
const { db } = this.root;
|
|
5797
|
+
const subcircuit = this.getSubcircuit();
|
|
5709
5798
|
const { _parsedProps: props } = this;
|
|
5710
5799
|
const layer = props.layer ?? "top";
|
|
5711
5800
|
if (layer !== "top" && layer !== "bottom") {
|
|
@@ -5719,7 +5808,7 @@ var FabricationNotePath = class extends PrimitiveComponent {
|
|
|
5719
5808
|
layer,
|
|
5720
5809
|
color: props.color,
|
|
5721
5810
|
route: props.route.map((p) => {
|
|
5722
|
-
const transformedPosition =
|
|
5811
|
+
const transformedPosition = applyToPoint5(transform, {
|
|
5723
5812
|
x: p.x,
|
|
5724
5813
|
y: p.y
|
|
5725
5814
|
});
|
|
@@ -5729,7 +5818,8 @@ var FabricationNotePath = class extends PrimitiveComponent {
|
|
|
5729
5818
|
y: transformedPosition.y
|
|
5730
5819
|
};
|
|
5731
5820
|
}),
|
|
5732
|
-
stroke_width: props.strokeWidth ?? 0.1
|
|
5821
|
+
stroke_width: props.strokeWidth ?? 0.1,
|
|
5822
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0
|
|
5733
5823
|
});
|
|
5734
5824
|
this.fabrication_note_path_id = fabrication_note_path.pcb_fabrication_note_path_id;
|
|
5735
5825
|
}
|
|
@@ -5749,6 +5839,7 @@ var FabricationNoteText = class extends PrimitiveComponent {
|
|
|
5749
5839
|
const { db } = this.root;
|
|
5750
5840
|
const { _parsedProps: props } = this;
|
|
5751
5841
|
const container = this.getPrimitiveContainer();
|
|
5842
|
+
const subcircuit = this.getSubcircuit();
|
|
5752
5843
|
db.pcb_fabrication_note_text.insert({
|
|
5753
5844
|
anchor_alignment: props.anchorAlignment,
|
|
5754
5845
|
anchor_position: {
|
|
@@ -5760,7 +5851,9 @@ var FabricationNoteText = class extends PrimitiveComponent {
|
|
|
5760
5851
|
layer: "top",
|
|
5761
5852
|
color: props.color,
|
|
5762
5853
|
text: props.text ?? "",
|
|
5763
|
-
pcb_component_id: container.pcb_component_id
|
|
5854
|
+
pcb_component_id: container.pcb_component_id,
|
|
5855
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5856
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5764
5857
|
});
|
|
5765
5858
|
}
|
|
5766
5859
|
};
|
|
@@ -5824,6 +5917,7 @@ var SilkscreenCircle = class extends PrimitiveComponent {
|
|
|
5824
5917
|
);
|
|
5825
5918
|
}
|
|
5826
5919
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
5920
|
+
const subcircuit = this.getSubcircuit();
|
|
5827
5921
|
const pcb_silkscreen_circle = db.pcb_silkscreen_circle.insert({
|
|
5828
5922
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
5829
5923
|
layer,
|
|
@@ -5831,7 +5925,9 @@ var SilkscreenCircle = class extends PrimitiveComponent {
|
|
|
5831
5925
|
x: props.pcbX ?? 0,
|
|
5832
5926
|
y: props.pcbY ?? 0
|
|
5833
5927
|
},
|
|
5834
|
-
radius: props.radius
|
|
5928
|
+
radius: props.radius,
|
|
5929
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5930
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5835
5931
|
});
|
|
5836
5932
|
this.pcb_silkscreen_circle_id = pcb_silkscreen_circle.pcb_silkscreen_circle_id;
|
|
5837
5933
|
}
|
|
@@ -5857,6 +5953,7 @@ var SilkscreenRect = class extends PrimitiveComponent {
|
|
|
5857
5953
|
`Invalid layer "${layer}" for SilkscreenRect. Must be "top" or "bottom".`
|
|
5858
5954
|
);
|
|
5859
5955
|
}
|
|
5956
|
+
const subcircuit = this.getSubcircuit();
|
|
5860
5957
|
const pcb_silkscreen_rect = db.pcb_silkscreen_rect.insert({
|
|
5861
5958
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
5862
5959
|
layer,
|
|
@@ -5865,7 +5962,9 @@ var SilkscreenRect = class extends PrimitiveComponent {
|
|
|
5865
5962
|
y: props.pcbY ?? 0
|
|
5866
5963
|
},
|
|
5867
5964
|
width: props.width,
|
|
5868
|
-
height: props.height
|
|
5965
|
+
height: props.height,
|
|
5966
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5967
|
+
pcb_group_id: this?.getGroup()?.pcb_group_id ?? void 0
|
|
5869
5968
|
});
|
|
5870
5969
|
this.pcb_silkscreen_rect_id = pcb_silkscreen_rect.pcb_silkscreen_rect_id;
|
|
5871
5970
|
}
|
|
@@ -5888,6 +5987,7 @@ var SilkscreenText = class extends PrimitiveComponent {
|
|
|
5888
5987
|
const container = this.getPrimitiveContainer();
|
|
5889
5988
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
5890
5989
|
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
5990
|
+
const subcircuit = this.getSubcircuit();
|
|
5891
5991
|
db.pcb_silkscreen_text.insert({
|
|
5892
5992
|
anchor_alignment: props.anchorAlignment,
|
|
5893
5993
|
anchor_position: {
|
|
@@ -5899,7 +5999,9 @@ var SilkscreenText = class extends PrimitiveComponent {
|
|
|
5899
5999
|
layer: maybeFlipLayer(props.layer ?? "top"),
|
|
5900
6000
|
text: props.text ?? "",
|
|
5901
6001
|
ccw_rotation: props.pcbRotation,
|
|
5902
|
-
pcb_component_id: container.pcb_component_id
|
|
6002
|
+
pcb_component_id: container.pcb_component_id,
|
|
6003
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
6004
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5903
6005
|
});
|
|
5904
6006
|
}
|
|
5905
6007
|
getPcbSize() {
|
|
@@ -5932,6 +6034,7 @@ var SilkscreenLine = class extends PrimitiveComponent {
|
|
|
5932
6034
|
`Invalid layer "${layer}" for SilkscreenLine. Must be "top" or "bottom".`
|
|
5933
6035
|
);
|
|
5934
6036
|
}
|
|
6037
|
+
const subcircuit = this.getSubcircuit();
|
|
5935
6038
|
const pcb_silkscreen_line = db.pcb_silkscreen_line.insert({
|
|
5936
6039
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
5937
6040
|
layer,
|
|
@@ -5939,7 +6042,9 @@ var SilkscreenLine = class extends PrimitiveComponent {
|
|
|
5939
6042
|
y1: props.y1,
|
|
5940
6043
|
x2: props.x2,
|
|
5941
6044
|
y2: props.y2,
|
|
5942
|
-
stroke_width: props.strokeWidth ?? 0.1
|
|
6045
|
+
stroke_width: props.strokeWidth ?? 0.1,
|
|
6046
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
6047
|
+
pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
|
|
5943
6048
|
});
|
|
5944
6049
|
this.pcb_silkscreen_line_id = pcb_silkscreen_line.pcb_silkscreen_line_id;
|
|
5945
6050
|
}
|
|
@@ -5992,6 +6097,7 @@ var Via = class extends PrimitiveComponent {
|
|
|
5992
6097
|
const { db } = this.root;
|
|
5993
6098
|
const { _parsedProps: props } = this;
|
|
5994
6099
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
6100
|
+
const subcircuit = this.getSubcircuit();
|
|
5995
6101
|
const pcb_via = db.pcb_via.insert({
|
|
5996
6102
|
x: position.x,
|
|
5997
6103
|
y: position.y,
|
|
@@ -5999,7 +6105,9 @@ var Via = class extends PrimitiveComponent {
|
|
|
5999
6105
|
outer_diameter: props.outerDiameter,
|
|
6000
6106
|
layers: ["bottom", "top"],
|
|
6001
6107
|
from_layer: props.fromLayer || "bottom",
|
|
6002
|
-
to_layer: props.toLayer || "top"
|
|
6108
|
+
to_layer: props.toLayer || "top",
|
|
6109
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
6110
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
6003
6111
|
});
|
|
6004
6112
|
this.pcb_via_id = pcb_via.pcb_via_id;
|
|
6005
6113
|
}
|
|
@@ -6322,7 +6430,7 @@ var Mosfet = class extends NormalComponent {
|
|
|
6322
6430
|
// lib/RootCircuit.ts
|
|
6323
6431
|
import { su } from "@tscircuit/soup-util";
|
|
6324
6432
|
import { isValidElement as isValidElement2 } from "react";
|
|
6325
|
-
import { identity as
|
|
6433
|
+
import { identity as identity4 } from "transformation-matrix";
|
|
6326
6434
|
var RootCircuit = class {
|
|
6327
6435
|
firstChild = null;
|
|
6328
6436
|
children;
|
|
@@ -6433,10 +6541,10 @@ var RootCircuit = class {
|
|
|
6433
6541
|
throw new Error("project.preview is not yet implemented");
|
|
6434
6542
|
}
|
|
6435
6543
|
computeSchematicGlobalTransform() {
|
|
6436
|
-
return
|
|
6544
|
+
return identity4();
|
|
6437
6545
|
}
|
|
6438
6546
|
_computePcbGlobalTransformBeforeLayout() {
|
|
6439
|
-
return
|
|
6547
|
+
return identity4();
|
|
6440
6548
|
}
|
|
6441
6549
|
selectAll(selector) {
|
|
6442
6550
|
this._guessRootComponent();
|
|
@@ -6627,7 +6735,7 @@ var applyEditEventsToManualEditsFile = ({
|
|
|
6627
6735
|
};
|
|
6628
6736
|
|
|
6629
6737
|
// lib/utils/autorouting/getSimpleRouteJsonFromCircuitJson.ts
|
|
6630
|
-
import { getObstaclesFromSoup as
|
|
6738
|
+
import { getObstaclesFromSoup as getObstaclesFromSoup3 } from "@tscircuit/infgrid-ijump-astar";
|
|
6631
6739
|
import { su as su3 } from "@tscircuit/soup-util";
|
|
6632
6740
|
import { getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson2 } from "circuit-json-to-connectivity-map";
|
|
6633
6741
|
var getSimpleRouteJsonFromCircuitJson = ({
|
|
@@ -6636,7 +6744,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
6636
6744
|
}) => {
|
|
6637
6745
|
const db = su3(circuitJson);
|
|
6638
6746
|
const connMap = getFullConnectivityMapFromCircuitJson2(circuitJson);
|
|
6639
|
-
const obstacles =
|
|
6747
|
+
const obstacles = getObstaclesFromSoup3(
|
|
6640
6748
|
[
|
|
6641
6749
|
...db.pcb_component.list(),
|
|
6642
6750
|
...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.277",
|
|
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",
|