@tscircuit/core 0.0.275 → 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 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,7 +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 {
922
- subcircuit_id?: string;
929
+ pcb_group_id: string | null;
930
+ subcircuit_id: string | null;
923
931
  _asyncAutoroutingResult: {
924
932
  output_simple_route_json?: SimpleRouteJson;
925
933
  output_pcb_traces?: PcbTrace[];
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 applyToPoint3 } from "transformation-matrix";
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 = applyToPoint3(transform, {
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 applyToPoint4, compose as compose3, translate as translate3 } from "transformation-matrix";
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 = compose3(
2053
+ const transform = compose2(
2024
2054
  this.parent.computeSchematicGlobalTransform(),
2025
- translate3(-symbol.center.x, -symbol.center.y)
2055
+ translate2(-symbol.center.x, -symbol.center.y)
2026
2056
  );
2027
- return applyToPoint4(transform, this.schematicSymbolPortDef);
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 applyToPoint4(
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 identity4 } from "transformation-matrix";
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 applyToPoint5 } from "transformation-matrix";
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
- ...applyToPoint5(globalTransform, offset),
3600
+ ...applyToPoint4(globalTransform, offset),
3512
3601
  via: offset.via,
3513
3602
  to_layer: offset.to_layer,
3514
3603
  trace_width: offset.trace_width
@@ -3528,67 +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 {
3591
- subcircuit_id;
3621
+ pcb_group_id = null;
3622
+ subcircuit_id = null;
3592
3623
  _asyncAutoroutingResult = null;
3593
3624
  get config() {
3594
3625
  return {
@@ -3599,11 +3630,14 @@ var Group = class extends NormalComponent {
3599
3630
  doInitialSourceRender() {
3600
3631
  const { db } = this.root;
3601
3632
  const source_group = db.source_group.insert({
3602
- name: this._parsedProps.name
3603
- // TODO add subcircuit_id
3633
+ name: this._parsedProps.name,
3634
+ is_subcircuit: this.isSubcircuit
3604
3635
  });
3605
3636
  this.subcircuit_id = `subcircuit_${source_group.source_group_id}`;
3606
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
+ });
3607
3641
  }
3608
3642
  doInitialPcbComponentRender() {
3609
3643
  if (this.root?.pcbDisabled) return;
@@ -3619,6 +3653,7 @@ var Group = class extends NormalComponent {
3619
3653
  pcb_component_ids: [],
3620
3654
  source_group_id: this.source_group_id
3621
3655
  });
3656
+ this.pcb_group_id = pcb_group.pcb_group_id;
3622
3657
  }
3623
3658
  doInitialCreateTraceHintsFromProps() {
3624
3659
  const { _parsedProps: props } = this;
@@ -3893,7 +3928,7 @@ var Board = class extends Group {
3893
3928
  this.pcb_board_id = null;
3894
3929
  }
3895
3930
  _computePcbGlobalTransformBeforeLayout() {
3896
- return identity4();
3931
+ return identity3();
3897
3932
  }
3898
3933
  };
3899
3934
 
@@ -3912,7 +3947,7 @@ var FTYPE = stringProxy;
3912
3947
  // lib/components/primitive-components/Trace/Trace.ts
3913
3948
  import {
3914
3949
  MultilayerIjump,
3915
- getObstaclesFromSoup as getObstaclesFromSoup3
3950
+ getObstaclesFromSoup as getObstaclesFromSoup2
3916
3951
  } from "@tscircuit/infgrid-ijump-astar";
3917
3952
  import { traceProps } from "@tscircuit/props";
3918
3953
  import "circuit-json";
@@ -4810,7 +4845,9 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4810
4845
  if (cachedRoute) {
4811
4846
  const pcb_trace2 = db.pcb_trace.insert({
4812
4847
  route: cachedRoute.flatMap((trace) => trace.route),
4813
- 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
4814
4851
  });
4815
4852
  this.pcb_trace_id = pcb_trace2.pcb_trace_id;
4816
4853
  return;
@@ -4914,7 +4951,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4914
4951
  this.root.db.toArray()
4915
4952
  );
4916
4953
  const [obstacles, errGettingObstacles] = tryNow(
4917
- () => getObstaclesFromSoup3(this.root.db.toArray())
4954
+ () => getObstaclesFromSoup2(this.root.db.toArray())
4918
4955
  // Remove as any when autorouting-dataset gets updated
4919
4956
  );
4920
4957
  if (errGettingObstacles) {
@@ -5694,7 +5731,7 @@ var Constraint2 = class extends PrimitiveComponent {
5694
5731
 
5695
5732
  // lib/components/primitive-components/FabricationNotePath.ts
5696
5733
  import { fabricationNotePathProps } from "@tscircuit/props";
5697
- import { applyToPoint as applyToPoint6 } from "transformation-matrix";
5734
+ import { applyToPoint as applyToPoint5 } from "transformation-matrix";
5698
5735
  var FabricationNotePath = class extends PrimitiveComponent {
5699
5736
  fabrication_note_path_id = null;
5700
5737
  get config() {
@@ -5706,6 +5743,7 @@ var FabricationNotePath = class extends PrimitiveComponent {
5706
5743
  doInitialPcbPrimitiveRender() {
5707
5744
  if (this.root?.pcbDisabled) return;
5708
5745
  const { db } = this.root;
5746
+ const subcircuit = this.getSubcircuit();
5709
5747
  const { _parsedProps: props } = this;
5710
5748
  const layer = props.layer ?? "top";
5711
5749
  if (layer !== "top" && layer !== "bottom") {
@@ -5719,7 +5757,7 @@ var FabricationNotePath = class extends PrimitiveComponent {
5719
5757
  layer,
5720
5758
  color: props.color,
5721
5759
  route: props.route.map((p) => {
5722
- const transformedPosition = applyToPoint6(transform, {
5760
+ const transformedPosition = applyToPoint5(transform, {
5723
5761
  x: p.x,
5724
5762
  y: p.y
5725
5763
  });
@@ -5729,7 +5767,8 @@ var FabricationNotePath = class extends PrimitiveComponent {
5729
5767
  y: transformedPosition.y
5730
5768
  };
5731
5769
  }),
5732
- stroke_width: props.strokeWidth ?? 0.1
5770
+ stroke_width: props.strokeWidth ?? 0.1,
5771
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0
5733
5772
  });
5734
5773
  this.fabrication_note_path_id = fabrication_note_path.pcb_fabrication_note_path_id;
5735
5774
  }
@@ -5749,6 +5788,7 @@ var FabricationNoteText = class extends PrimitiveComponent {
5749
5788
  const { db } = this.root;
5750
5789
  const { _parsedProps: props } = this;
5751
5790
  const container = this.getPrimitiveContainer();
5791
+ const subcircuit = this.getSubcircuit();
5752
5792
  db.pcb_fabrication_note_text.insert({
5753
5793
  anchor_alignment: props.anchorAlignment,
5754
5794
  anchor_position: {
@@ -5760,7 +5800,9 @@ var FabricationNoteText = class extends PrimitiveComponent {
5760
5800
  layer: "top",
5761
5801
  color: props.color,
5762
5802
  text: props.text ?? "",
5763
- 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
5764
5806
  });
5765
5807
  }
5766
5808
  };
@@ -5824,6 +5866,7 @@ var SilkscreenCircle = class extends PrimitiveComponent {
5824
5866
  );
5825
5867
  }
5826
5868
  const transform = this._computePcbGlobalTransformBeforeLayout();
5869
+ const subcircuit = this.getSubcircuit();
5827
5870
  const pcb_silkscreen_circle = db.pcb_silkscreen_circle.insert({
5828
5871
  pcb_component_id: this.parent?.pcb_component_id,
5829
5872
  layer,
@@ -5831,7 +5874,9 @@ var SilkscreenCircle = class extends PrimitiveComponent {
5831
5874
  x: props.pcbX ?? 0,
5832
5875
  y: props.pcbY ?? 0
5833
5876
  },
5834
- 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
5835
5880
  });
5836
5881
  this.pcb_silkscreen_circle_id = pcb_silkscreen_circle.pcb_silkscreen_circle_id;
5837
5882
  }
@@ -5857,6 +5902,7 @@ var SilkscreenRect = class extends PrimitiveComponent {
5857
5902
  `Invalid layer "${layer}" for SilkscreenRect. Must be "top" or "bottom".`
5858
5903
  );
5859
5904
  }
5905
+ const subcircuit = this.getSubcircuit();
5860
5906
  const pcb_silkscreen_rect = db.pcb_silkscreen_rect.insert({
5861
5907
  pcb_component_id: this.parent?.pcb_component_id,
5862
5908
  layer,
@@ -5865,7 +5911,9 @@ var SilkscreenRect = class extends PrimitiveComponent {
5865
5911
  y: props.pcbY ?? 0
5866
5912
  },
5867
5913
  width: props.width,
5868
- 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
5869
5917
  });
5870
5918
  this.pcb_silkscreen_rect_id = pcb_silkscreen_rect.pcb_silkscreen_rect_id;
5871
5919
  }
@@ -5888,6 +5936,7 @@ var SilkscreenText = class extends PrimitiveComponent {
5888
5936
  const container = this.getPrimitiveContainer();
5889
5937
  const position = this._getGlobalPcbPositionBeforeLayout();
5890
5938
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
5939
+ const subcircuit = this.getSubcircuit();
5891
5940
  db.pcb_silkscreen_text.insert({
5892
5941
  anchor_alignment: props.anchorAlignment,
5893
5942
  anchor_position: {
@@ -5899,7 +5948,9 @@ var SilkscreenText = class extends PrimitiveComponent {
5899
5948
  layer: maybeFlipLayer(props.layer ?? "top"),
5900
5949
  text: props.text ?? "",
5901
5950
  ccw_rotation: props.pcbRotation,
5902
- 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
5903
5954
  });
5904
5955
  }
5905
5956
  getPcbSize() {
@@ -5932,6 +5983,7 @@ var SilkscreenLine = class extends PrimitiveComponent {
5932
5983
  `Invalid layer "${layer}" for SilkscreenLine. Must be "top" or "bottom".`
5933
5984
  );
5934
5985
  }
5986
+ const subcircuit = this.getSubcircuit();
5935
5987
  const pcb_silkscreen_line = db.pcb_silkscreen_line.insert({
5936
5988
  pcb_component_id: this.parent?.pcb_component_id,
5937
5989
  layer,
@@ -5939,7 +5991,9 @@ var SilkscreenLine = class extends PrimitiveComponent {
5939
5991
  y1: props.y1,
5940
5992
  x2: props.x2,
5941
5993
  y2: props.y2,
5942
- 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
5943
5997
  });
5944
5998
  this.pcb_silkscreen_line_id = pcb_silkscreen_line.pcb_silkscreen_line_id;
5945
5999
  }
@@ -5992,6 +6046,7 @@ var Via = class extends PrimitiveComponent {
5992
6046
  const { db } = this.root;
5993
6047
  const { _parsedProps: props } = this;
5994
6048
  const position = this._getGlobalPcbPositionBeforeLayout();
6049
+ const subcircuit = this.getSubcircuit();
5995
6050
  const pcb_via = db.pcb_via.insert({
5996
6051
  x: position.x,
5997
6052
  y: position.y,
@@ -5999,7 +6054,9 @@ var Via = class extends PrimitiveComponent {
5999
6054
  outer_diameter: props.outerDiameter,
6000
6055
  layers: ["bottom", "top"],
6001
6056
  from_layer: props.fromLayer || "bottom",
6002
- 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
6003
6060
  });
6004
6061
  this.pcb_via_id = pcb_via.pcb_via_id;
6005
6062
  }
@@ -6322,7 +6379,7 @@ var Mosfet = class extends NormalComponent {
6322
6379
  // lib/RootCircuit.ts
6323
6380
  import { su } from "@tscircuit/soup-util";
6324
6381
  import { isValidElement as isValidElement2 } from "react";
6325
- import { identity as identity5 } from "transformation-matrix";
6382
+ import { identity as identity4 } from "transformation-matrix";
6326
6383
  var RootCircuit = class {
6327
6384
  firstChild = null;
6328
6385
  children;
@@ -6433,10 +6490,10 @@ var RootCircuit = class {
6433
6490
  throw new Error("project.preview is not yet implemented");
6434
6491
  }
6435
6492
  computeSchematicGlobalTransform() {
6436
- return identity5();
6493
+ return identity4();
6437
6494
  }
6438
6495
  _computePcbGlobalTransformBeforeLayout() {
6439
- return identity5();
6496
+ return identity4();
6440
6497
  }
6441
6498
  selectAll(selector) {
6442
6499
  this._guessRootComponent();
@@ -6627,7 +6684,7 @@ var applyEditEventsToManualEditsFile = ({
6627
6684
  };
6628
6685
 
6629
6686
  // lib/utils/autorouting/getSimpleRouteJsonFromCircuitJson.ts
6630
- import { getObstaclesFromSoup as getObstaclesFromSoup4 } from "@tscircuit/infgrid-ijump-astar";
6687
+ import { getObstaclesFromSoup as getObstaclesFromSoup3 } from "@tscircuit/infgrid-ijump-astar";
6631
6688
  import { su as su3 } from "@tscircuit/soup-util";
6632
6689
  import { getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson2 } from "circuit-json-to-connectivity-map";
6633
6690
  var getSimpleRouteJsonFromCircuitJson = ({
@@ -6636,7 +6693,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
6636
6693
  }) => {
6637
6694
  const db = su3(circuitJson);
6638
6695
  const connMap = getFullConnectivityMapFromCircuitJson2(circuitJson);
6639
- const obstacles = getObstaclesFromSoup4(
6696
+ const obstacles = getObstaclesFromSoup3(
6640
6697
  [
6641
6698
  ...db.pcb_component.list(),
6642
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.275",
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.132",
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",