@tscircuit/core 0.0.635 → 0.0.636

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9095,7 +9095,7 @@ function getPresetAutoroutingConfig(autorouterConfig) {
9095
9095
  }
9096
9096
 
9097
9097
  // lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack.ts
9098
- import { buildSubtree as buildSubtree2 } from "@tscircuit/circuit-json-util";
9098
+ import "@tscircuit/circuit-json-util";
9099
9099
  import {
9100
9100
  pack,
9101
9101
  convertCircuitJsonToPackOutput,
@@ -9109,6 +9109,12 @@ import {
9109
9109
  import { translate as translate6, rotate as rotate2, compose as compose4 } from "transformation-matrix";
9110
9110
  import Debug7 from "debug";
9111
9111
  var debug6 = Debug7("Group_doInitialPcbLayoutPack");
9112
+ var isDescendantGroup = (db, groupId, ancestorId) => {
9113
+ if (groupId === ancestorId) return true;
9114
+ const group = db.source_group.get(groupId);
9115
+ if (!group || !group.parent_source_group_id) return false;
9116
+ return isDescendantGroup(db, group.parent_source_group_id, ancestorId);
9117
+ };
9112
9118
  var Group_doInitialPcbLayoutPack = (group) => {
9113
9119
  const { db } = group.root;
9114
9120
  const { _parsedProps: props } = group;
@@ -9143,6 +9149,14 @@ var Group_doInitialPcbLayoutPack = (group) => {
9143
9149
  const { center, componentId, ccwRotationOffset, ccwRotationDegrees } = packedComponent;
9144
9150
  const pcbComponent = db.pcb_component.get(componentId);
9145
9151
  if (pcbComponent) {
9152
+ const currentGroupId = group.source_group_id;
9153
+ const sourceComponent = db.source_component.get(
9154
+ pcbComponent.source_component_id
9155
+ );
9156
+ const componentGroupId = sourceComponent?.source_group_id;
9157
+ if (componentGroupId !== void 0 && !isDescendantGroup(db, componentGroupId, currentGroupId)) {
9158
+ continue;
9159
+ }
9146
9160
  const originalCenter2 = pcbComponent.center;
9147
9161
  const rotationDegrees2 = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
9148
9162
  const transformMatrix2 = compose4(
@@ -9167,8 +9181,49 @@ var Group_doInitialPcbLayoutPack = (group) => {
9167
9181
  rotate2(rotationDegrees * Math.PI / 180),
9168
9182
  translate6(-originalCenter.x, -originalCenter.y)
9169
9183
  );
9170
- const subtree = buildSubtree2(db.toArray(), { source_group_id: componentId });
9171
- transformPCBElements2(subtree, transformMatrix);
9184
+ const relatedElements = db.toArray().filter((elm) => {
9185
+ if ("source_group_id" in elm && elm.source_group_id) {
9186
+ if (elm.source_group_id === componentId) {
9187
+ return true;
9188
+ }
9189
+ if (isDescendantGroup(db, elm.source_group_id, componentId)) {
9190
+ return true;
9191
+ }
9192
+ }
9193
+ if ("source_component_id" in elm && elm.source_component_id) {
9194
+ const sourceComponent = db.source_component.get(elm.source_component_id);
9195
+ if (sourceComponent?.source_group_id) {
9196
+ if (sourceComponent.source_group_id === componentId) {
9197
+ return true;
9198
+ }
9199
+ if (isDescendantGroup(db, sourceComponent.source_group_id, componentId)) {
9200
+ return true;
9201
+ }
9202
+ }
9203
+ }
9204
+ if ("pcb_component_id" in elm && elm.pcb_component_id) {
9205
+ const pcbComponent2 = db.pcb_component.get(elm.pcb_component_id);
9206
+ if (pcbComponent2?.source_component_id) {
9207
+ const sourceComponent = db.source_component.get(
9208
+ pcbComponent2.source_component_id
9209
+ );
9210
+ if (sourceComponent?.source_group_id) {
9211
+ if (sourceComponent.source_group_id === componentId) {
9212
+ return true;
9213
+ }
9214
+ if (isDescendantGroup(
9215
+ db,
9216
+ sourceComponent.source_group_id,
9217
+ componentId
9218
+ )) {
9219
+ return true;
9220
+ }
9221
+ }
9222
+ }
9223
+ }
9224
+ return false;
9225
+ });
9226
+ transformPCBElements2(relatedElements, transformMatrix);
9172
9227
  db.pcb_group.update(pcbGroup.pcb_group_id, { center });
9173
9228
  }
9174
9229
  };
@@ -9433,13 +9488,15 @@ var Group = class extends NormalComponent {
9433
9488
  centerX += (padRight - padLeft) / 2;
9434
9489
  centerY += (padTop - padBottom) / 2;
9435
9490
  }
9491
+ const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
9492
+ const center = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
9493
+ x: centerX,
9494
+ y: centerY
9495
+ } : { x: centerX, y: centerY };
9436
9496
  db.pcb_group.update(this.pcb_group_id, {
9437
9497
  width: Number(props.width ?? width),
9438
9498
  height: Number(props.height ?? height),
9439
- center: {
9440
- x: centerX,
9441
- y: centerY
9442
- }
9499
+ center
9443
9500
  });
9444
9501
  }
9445
9502
  }
@@ -12627,7 +12684,7 @@ import { identity as identity5 } from "transformation-matrix";
12627
12684
  var package_default = {
12628
12685
  name: "@tscircuit/core",
12629
12686
  type: "module",
12630
- version: "0.0.634",
12687
+ version: "0.0.635",
12631
12688
  types: "dist/index.d.ts",
12632
12689
  main: "dist/index.js",
12633
12690
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.635",
4
+ "version": "0.0.636",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",