@tscircuit/core 0.0.957 → 0.0.958

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
@@ -1362,6 +1362,8 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
1362
1362
  doInitialSourceParentAttachment(): void;
1363
1363
  doInitialPcbComponentRender(): void;
1364
1364
  doInitialPcbPrimitiveRender(): void;
1365
+ calculatePcbGroupBounds(): void;
1366
+ updatePcbPrimitiveRender(): void;
1365
1367
  unnamedElementCounter: Record<string, number>;
1366
1368
  getNextAvailableName(elm: PrimitiveComponent): string;
1367
1369
  _resolvePcbPadding(): {
package/dist/index.js CHANGED
@@ -14061,52 +14061,57 @@ var Group6 = class extends NormalComponent3 {
14061
14061
  }
14062
14062
  }
14063
14063
  doInitialPcbPrimitiveRender() {
14064
+ this.calculatePcbGroupBounds();
14065
+ }
14066
+ calculatePcbGroupBounds() {
14067
+ if (!this.pcb_group_id) return;
14064
14068
  if (this.root?.pcbDisabled) return;
14065
14069
  const { db } = this.root;
14066
14070
  const props = this._parsedProps;
14067
14071
  const hasOutline = props.outline && props.outline.length > 0;
14068
- if (this.pcb_group_id) {
14069
- const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
14070
- if (hasOutline) {
14071
- const numericOutline = props.outline.map((point2) => ({
14072
- x: distance8.parse(point2.x),
14073
- y: distance8.parse(point2.y)
14074
- }));
14075
- const outlineBounds = getBoundsFromPoints3(numericOutline);
14076
- if (!outlineBounds) return;
14077
- const centerX2 = (outlineBounds.minX + outlineBounds.maxX) / 2;
14078
- const centerY2 = (outlineBounds.minY + outlineBounds.maxY) / 2;
14079
- const center2 = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
14080
- x: centerX2,
14081
- y: centerY2
14082
- } : { x: centerX2, y: centerY2 };
14083
- db.pcb_group.update(this.pcb_group_id, {
14084
- center: center2
14085
- });
14086
- return;
14087
- }
14088
- const bounds = getBoundsOfPcbComponents(this.children);
14089
- let width = bounds.width;
14090
- let height = bounds.height;
14091
- let centerX = (bounds.minX + bounds.maxX) / 2;
14092
- let centerY = (bounds.minY + bounds.maxY) / 2;
14093
- if (this.isSubcircuit) {
14094
- const { padLeft, padRight, padTop, padBottom } = this._resolvePcbPadding();
14095
- width += padLeft + padRight;
14096
- height += padTop + padBottom;
14097
- centerX += (padRight - padLeft) / 2;
14098
- centerY += (padTop - padBottom) / 2;
14099
- }
14100
- const center = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
14101
- x: centerX,
14102
- y: centerY
14103
- } : { x: centerX, y: centerY };
14072
+ const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
14073
+ if (hasOutline) {
14074
+ const numericOutline = props.outline.map((point2) => ({
14075
+ x: distance8.parse(point2.x),
14076
+ y: distance8.parse(point2.y)
14077
+ }));
14078
+ const outlineBounds = getBoundsFromPoints3(numericOutline);
14079
+ if (!outlineBounds) return;
14080
+ const centerX2 = (outlineBounds.minX + outlineBounds.maxX) / 2;
14081
+ const centerY2 = (outlineBounds.minY + outlineBounds.maxY) / 2;
14082
+ const center2 = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
14083
+ x: centerX2,
14084
+ y: centerY2
14085
+ } : { x: centerX2, y: centerY2 };
14104
14086
  db.pcb_group.update(this.pcb_group_id, {
14105
- width: Number(props.width ?? width),
14106
- height: Number(props.height ?? height),
14107
- center
14087
+ center: center2
14108
14088
  });
14089
+ return;
14109
14090
  }
14091
+ const bounds = getBoundsOfPcbComponents(this.children);
14092
+ let width = bounds.width;
14093
+ let height = bounds.height;
14094
+ let centerX = (bounds.minX + bounds.maxX) / 2;
14095
+ let centerY = (bounds.minY + bounds.maxY) / 2;
14096
+ if (this.isSubcircuit) {
14097
+ const { padLeft, padRight, padTop, padBottom } = this._resolvePcbPadding();
14098
+ width += padLeft + padRight;
14099
+ height += padTop + padBottom;
14100
+ centerX += (padRight - padLeft) / 2;
14101
+ centerY += (padTop - padBottom) / 2;
14102
+ }
14103
+ const center = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
14104
+ x: centerX,
14105
+ y: centerY
14106
+ } : { x: centerX, y: centerY };
14107
+ db.pcb_group.update(this.pcb_group_id, {
14108
+ width: Number(props.width ?? width),
14109
+ height: Number(props.height ?? height),
14110
+ center
14111
+ });
14112
+ }
14113
+ updatePcbPrimitiveRender() {
14114
+ this.calculatePcbGroupBounds();
14110
14115
  }
14111
14116
  unnamedElementCounter = {};
14112
14117
  getNextAvailableName(elm) {
@@ -20371,7 +20376,7 @@ import { identity as identity5 } from "transformation-matrix";
20371
20376
  var package_default = {
20372
20377
  name: "@tscircuit/core",
20373
20378
  type: "module",
20374
- version: "0.0.956",
20379
+ version: "0.0.957",
20375
20380
  types: "dist/index.d.ts",
20376
20381
  main: "dist/index.js",
20377
20382
  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.957",
4
+ "version": "0.0.958",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",