@tscircuit/core 0.0.798 → 0.0.799

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
@@ -1285,6 +1285,11 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
1285
1285
  doInitialPcbDesignRuleChecks(): void;
1286
1286
  doInitialSchematicReplaceNetLabelsWithSymbols(): void;
1287
1287
  doInitialSimulationSpiceEngineRender(): void;
1288
+ /**
1289
+ * Override anchor alignment to handle group-specific logic
1290
+ */
1291
+ doInitialPcbComponentAnchorAlignment(): void;
1292
+ updatePcbComponentAnchorAlignment(): void;
1288
1293
  /**
1289
1294
  * Get the minimum flex container size for this group on PCB
1290
1295
  */
@@ -14971,10 +14976,10 @@ declare const voltageSourceProps: z.ZodObject<{
14971
14976
  schX?: number | undefined;
14972
14977
  schY?: number | undefined;
14973
14978
  pcbX?: number | undefined;
14979
+ pcbY?: number | undefined;
14974
14980
  voltage?: number | undefined;
14975
14981
  frequency?: number | undefined;
14976
14982
  pcbPositionAnchor?: string | undefined;
14977
- pcbY?: number | undefined;
14978
14983
  pcbMarginTop?: number | undefined;
14979
14984
  pcbMarginRight?: number | undefined;
14980
14985
  pcbMarginBottom?: number | undefined;
@@ -15158,10 +15163,10 @@ declare const voltageSourceProps: z.ZodObject<{
15158
15163
  schX?: string | number | undefined;
15159
15164
  schY?: string | number | undefined;
15160
15165
  pcbX?: string | number | undefined;
15166
+ pcbY?: string | number | undefined;
15161
15167
  voltage?: string | number | undefined;
15162
15168
  frequency?: string | number | undefined;
15163
15169
  pcbPositionAnchor?: string | undefined;
15164
- pcbY?: string | number | undefined;
15165
15170
  pcbMarginTop?: string | number | undefined;
15166
15171
  pcbMarginRight?: string | number | undefined;
15167
15172
  pcbMarginBottom?: string | number | undefined;
@@ -16007,10 +16012,10 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
16007
16012
  schX?: number | undefined;
16008
16013
  schY?: number | undefined;
16009
16014
  pcbX?: number | undefined;
16015
+ pcbY?: number | undefined;
16010
16016
  voltage?: number | undefined;
16011
16017
  frequency?: number | undefined;
16012
16018
  pcbPositionAnchor?: string | undefined;
16013
- pcbY?: number | undefined;
16014
16019
  pcbMarginTop?: number | undefined;
16015
16020
  pcbMarginRight?: number | undefined;
16016
16021
  pcbMarginBottom?: number | undefined;
@@ -16194,10 +16199,10 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
16194
16199
  schX?: string | number | undefined;
16195
16200
  schY?: string | number | undefined;
16196
16201
  pcbX?: string | number | undefined;
16202
+ pcbY?: string | number | undefined;
16197
16203
  voltage?: string | number | undefined;
16198
16204
  frequency?: string | number | undefined;
16199
16205
  pcbPositionAnchor?: string | undefined;
16200
- pcbY?: string | number | undefined;
16201
16206
  pcbMarginTop?: string | number | undefined;
16202
16207
  pcbMarginRight?: string | number | undefined;
16203
16208
  pcbMarginBottom?: string | number | undefined;
package/dist/index.js CHANGED
@@ -12411,6 +12411,86 @@ ${spiceString}`);
12411
12411
  }
12412
12412
  }
12413
12413
 
12414
+ // lib/components/primitive-components/Group/Group_doInitialPcbComponentAnchorAlignment.ts
12415
+ function Group_doInitialPcbComponentAnchorAlignment(group) {
12416
+ if (group.root?.pcbDisabled) return;
12417
+ if (!group.pcb_group_id) return;
12418
+ const pcbPositionAnchor = group._parsedProps?.pcbPositionAnchor;
12419
+ if (!pcbPositionAnchor) return;
12420
+ const targetPosition = group._getGlobalPcbPositionBeforeLayout();
12421
+ const { pcbX, pcbY } = group._parsedProps;
12422
+ if (pcbX === void 0 && pcbY === void 0) return;
12423
+ const { db } = group.root;
12424
+ const pcbGroup = db.pcb_group.get(group.pcb_group_id);
12425
+ if (!pcbGroup) return;
12426
+ const { width, height, center } = pcbGroup;
12427
+ if (width === 0 || height === 0) return;
12428
+ const bounds = {
12429
+ left: center.x - width / 2,
12430
+ right: center.x + width / 2,
12431
+ top: center.y + height / 2,
12432
+ // Y-up: top is at higher Y
12433
+ bottom: center.y - height / 2
12434
+ // Y-up: bottom is at lower Y
12435
+ };
12436
+ const currentCenter = { ...center };
12437
+ let anchorPos = null;
12438
+ const ninePointAnchors = /* @__PURE__ */ new Set([
12439
+ "center",
12440
+ "top_left",
12441
+ "top_center",
12442
+ "top_right",
12443
+ "center_left",
12444
+ "center_right",
12445
+ "bottom_left",
12446
+ "bottom_center",
12447
+ "bottom_right"
12448
+ ]);
12449
+ if (ninePointAnchors.has(pcbPositionAnchor)) {
12450
+ switch (pcbPositionAnchor) {
12451
+ case "center":
12452
+ anchorPos = currentCenter;
12453
+ break;
12454
+ case "top_left":
12455
+ anchorPos = { x: bounds.left, y: bounds.top };
12456
+ break;
12457
+ case "top_center":
12458
+ anchorPos = { x: currentCenter.x, y: bounds.top };
12459
+ break;
12460
+ case "top_right":
12461
+ anchorPos = { x: bounds.right, y: bounds.top };
12462
+ break;
12463
+ case "center_left":
12464
+ anchorPos = { x: bounds.left, y: currentCenter.y };
12465
+ break;
12466
+ case "center_right":
12467
+ anchorPos = { x: bounds.right, y: currentCenter.y };
12468
+ break;
12469
+ case "bottom_left":
12470
+ anchorPos = { x: bounds.left, y: bounds.bottom };
12471
+ break;
12472
+ case "bottom_center":
12473
+ anchorPos = { x: currentCenter.x, y: bounds.bottom };
12474
+ break;
12475
+ case "bottom_right":
12476
+ anchorPos = { x: bounds.right, y: bounds.bottom };
12477
+ break;
12478
+ }
12479
+ }
12480
+ if (!anchorPos) return;
12481
+ const newCenter = { ...currentCenter };
12482
+ if (targetPosition.x !== void 0)
12483
+ newCenter.x += targetPosition.x - anchorPos.x;
12484
+ if (targetPosition.y !== void 0)
12485
+ newCenter.y += targetPosition.y - anchorPos.y;
12486
+ if (Math.abs(newCenter.x - currentCenter.x) > 1e-6 || Math.abs(newCenter.y - currentCenter.y) > 1e-6) {
12487
+ group._repositionOnPcb(newCenter);
12488
+ db.pcb_group.update(group.pcb_group_id, {
12489
+ center: newCenter
12490
+ });
12491
+ }
12492
+ }
12493
+
12414
12494
  // lib/components/primitive-components/Group/Group.ts
12415
12495
  var Group6 = class extends NormalComponent3 {
12416
12496
  pcb_group_id = null;
@@ -12509,11 +12589,19 @@ var Group6 = class extends NormalComponent3 {
12509
12589
  x: centerX,
12510
12590
  y: centerY
12511
12591
  } : { x: centerX, y: centerY };
12512
- db.pcb_group.update(this.pcb_group_id, {
12592
+ const updateData = {
12513
12593
  width: Number(props.width ?? width),
12514
12594
  height: Number(props.height ?? height),
12515
12595
  center
12516
- });
12596
+ };
12597
+ const pcbPositionAnchor = props.pcbPositionAnchor;
12598
+ if (pcbPositionAnchor && hasExplicitPositioning) {
12599
+ const pcbX = this._parsedProps.pcbX ?? 0;
12600
+ const pcbY = this._parsedProps.pcbY ?? 0;
12601
+ updateData.anchor_position = { x: pcbX, y: pcbY };
12602
+ updateData.anchor_alignment = pcbPositionAnchor;
12603
+ }
12604
+ db.pcb_group.update(this.pcb_group_id, updateData);
12517
12605
  }
12518
12606
  }
12519
12607
  unnamedElementCounter = {};
@@ -13168,6 +13256,15 @@ var Group6 = class extends NormalComponent3 {
13168
13256
  doInitialSimulationSpiceEngineRender() {
13169
13257
  Group_doInitialSimulationSpiceEngineRender(this);
13170
13258
  }
13259
+ /**
13260
+ * Override anchor alignment to handle group-specific logic
13261
+ */
13262
+ doInitialPcbComponentAnchorAlignment() {
13263
+ Group_doInitialPcbComponentAnchorAlignment(this);
13264
+ }
13265
+ updatePcbComponentAnchorAlignment() {
13266
+ this.doInitialPcbComponentAnchorAlignment();
13267
+ }
13171
13268
  /**
13172
13269
  * Get the minimum flex container size for this group on PCB
13173
13270
  */
@@ -16927,7 +17024,7 @@ import { identity as identity6 } from "transformation-matrix";
16927
17024
  var package_default = {
16928
17025
  name: "@tscircuit/core",
16929
17026
  type: "module",
16930
- version: "0.0.797",
17027
+ version: "0.0.798",
16931
17028
  types: "dist/index.d.ts",
16932
17029
  main: "dist/index.js",
16933
17030
  module: "dist/index.js",
@@ -16985,7 +17082,7 @@ var package_default = {
16985
17082
  "circuit-json-to-connectivity-map": "^0.0.22",
16986
17083
  "circuit-json-to-gltf": "^0.0.7",
16987
17084
  "circuit-json-to-simple-3d": "^0.0.9",
16988
- "circuit-to-svg": "^0.0.238",
17085
+ "circuit-to-svg": "^0.0.245",
16989
17086
  "circuit-json-to-spice": "^0.0.14",
16990
17087
  concurrently: "^9.1.2",
16991
17088
  "connectivity-map": "^1.0.0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.798",
4
+ "version": "0.0.799",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -59,7 +59,7 @@
59
59
  "circuit-json-to-connectivity-map": "^0.0.22",
60
60
  "circuit-json-to-gltf": "^0.0.7",
61
61
  "circuit-json-to-simple-3d": "^0.0.9",
62
- "circuit-to-svg": "^0.0.238",
62
+ "circuit-to-svg": "^0.0.245",
63
63
  "circuit-json-to-spice": "^0.0.14",
64
64
  "concurrently": "^9.1.2",
65
65
  "connectivity-map": "^1.0.0",