@tscircuit/core 0.0.889 → 0.0.890

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 (3) hide show
  1. package/dist/index.d.ts +775 -258
  2. package/dist/index.js +320 -26
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -479,6 +479,182 @@ import {
479
479
  import { z } from "zod";
480
480
  import { selectOne, selectAll } from "css-select";
481
481
 
482
+ // lib/utils/evaluateCalcString.ts
483
+ var defaultUnits = {
484
+ mm: 1
485
+ // You can add more if you need them:
486
+ // cm: 10,
487
+ // in: 25.4,
488
+ // mil: 0.0254,
489
+ };
490
+ function evaluateCalcString(input, options) {
491
+ const { knownVariables, units: userUnits } = options;
492
+ const units = { ...defaultUnits, ...userUnits ?? {} };
493
+ const expr = extractExpression(input);
494
+ const tokens = tokenize(expr, units);
495
+ const result = parseExpression(tokens, knownVariables);
496
+ return result;
497
+ }
498
+ function extractExpression(raw) {
499
+ const trimmed = raw.trim();
500
+ if (!trimmed.toLowerCase().startsWith("calc")) {
501
+ return trimmed;
502
+ }
503
+ const match = trimmed.match(/^calc\s*\((.*)\)$/is);
504
+ if (!match) {
505
+ throw new Error(`Invalid calc() expression: "${raw}"`);
506
+ }
507
+ return match[1].trim();
508
+ }
509
+ function tokenize(expr, units) {
510
+ const tokens = [];
511
+ let i = 0;
512
+ const isDigit = (ch) => ch >= "0" && ch <= "9";
513
+ const isIdentStart = (ch) => ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
514
+ const isIdentChar = (ch) => isIdentStart(ch) || isDigit(ch) || ch === ".";
515
+ while (i < expr.length) {
516
+ const ch = expr[i];
517
+ if (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
518
+ i++;
519
+ continue;
520
+ }
521
+ if (isDigit(ch) || ch === "." && i + 1 < expr.length && isDigit(expr[i + 1])) {
522
+ const start = i;
523
+ i++;
524
+ while (i < expr.length) {
525
+ const c = expr[i];
526
+ if (isDigit(c) || c === ".") {
527
+ i++;
528
+ } else {
529
+ break;
530
+ }
531
+ }
532
+ const numberText = expr.slice(start, i);
533
+ let num = Number(numberText);
534
+ if (Number.isNaN(num)) {
535
+ throw new Error(`Invalid number: "${numberText}"`);
536
+ }
537
+ const unitStart = i;
538
+ while (i < expr.length && /[A-Za-z]/.test(expr[i])) {
539
+ i++;
540
+ }
541
+ if (i > unitStart) {
542
+ const unitText = expr.slice(unitStart, i);
543
+ const factor = units[unitText];
544
+ if (factor == null) {
545
+ throw new Error(`Unknown unit: "${unitText}"`);
546
+ }
547
+ num *= factor;
548
+ }
549
+ tokens.push({ type: "number", value: num });
550
+ continue;
551
+ }
552
+ if (isIdentStart(ch)) {
553
+ const start = i;
554
+ i++;
555
+ while (i < expr.length && isIdentChar(expr[i])) {
556
+ i++;
557
+ }
558
+ const ident = expr.slice(start, i);
559
+ tokens.push({ type: "identifier", value: ident });
560
+ continue;
561
+ }
562
+ if (ch === "(" || ch === ")") {
563
+ tokens.push({ type: "paren", value: ch });
564
+ i++;
565
+ continue;
566
+ }
567
+ if (ch === "+" || ch === "-" || ch === "*" || ch === "/") {
568
+ tokens.push({ type: "operator", value: ch });
569
+ i++;
570
+ continue;
571
+ }
572
+ throw new Error(`Unexpected character "${ch}" in expression "${expr}"`);
573
+ }
574
+ return tokens;
575
+ }
576
+ function parseExpression(tokens, vars) {
577
+ let index = 0;
578
+ const peek = () => tokens[index];
579
+ const consume = () => tokens[index++];
580
+ const parsePrimary = () => {
581
+ const token = peek();
582
+ if (!token) {
583
+ throw new Error("Unexpected end of expression");
584
+ }
585
+ if (token.type === "number") {
586
+ consume();
587
+ return token.value;
588
+ }
589
+ if (token.type === "identifier") {
590
+ consume();
591
+ const value = vars[token.value];
592
+ if (value == null) {
593
+ throw new Error(`Unknown variable: "${token.value}"`);
594
+ }
595
+ return value;
596
+ }
597
+ if (token.type === "paren" && token.value === "(") {
598
+ consume();
599
+ const value = parseExpr();
600
+ const next = peek();
601
+ if (!next || next.type !== "paren" || next.value !== ")") {
602
+ throw new Error('Expected ")"');
603
+ }
604
+ consume();
605
+ return value;
606
+ }
607
+ throw new Error(`Unexpected token "${token.value}"`);
608
+ };
609
+ const parseFactor = () => {
610
+ const token = peek();
611
+ if (token && token.type === "operator" && (token.value === "+" || token.value === "-")) {
612
+ consume();
613
+ const value = parseFactor();
614
+ return token.value === "+" ? value : -value;
615
+ }
616
+ return parsePrimary();
617
+ };
618
+ const parseTerm = () => {
619
+ let value = parseFactor();
620
+ while (true) {
621
+ const token = peek();
622
+ if (!token || token.type !== "operator") break;
623
+ if (token.value !== "*" && token.value !== "/") break;
624
+ consume();
625
+ const rhs = parseFactor();
626
+ if (token.value === "*") {
627
+ value *= rhs;
628
+ } else {
629
+ value /= rhs;
630
+ }
631
+ }
632
+ return value;
633
+ };
634
+ const parseExpr = () => {
635
+ let value = parseTerm();
636
+ while (true) {
637
+ const token = peek();
638
+ if (!token || token.type !== "operator") break;
639
+ if (token.value !== "+" && token.value !== "-") break;
640
+ consume();
641
+ const rhs = parseTerm();
642
+ if (token.value === "+") {
643
+ value += rhs;
644
+ } else {
645
+ value -= rhs;
646
+ }
647
+ }
648
+ return value;
649
+ };
650
+ const result = parseExpr();
651
+ if (index < tokens.length) {
652
+ const leftover = tokens.slice(index).map((t) => "value" in t ? t.value : "?").join(" ");
653
+ throw new Error(`Unexpected tokens at end of expression: ${leftover}`);
654
+ }
655
+ return result;
656
+ }
657
+
482
658
  // lib/components/base-components/PrimitiveComponent/cssSelectPrimitiveComponentAdapter.ts
483
659
  var cssSelectPrimitiveComponentAdapter = {
484
660
  // Is the node an element?
@@ -756,15 +932,56 @@ var PrimitiveComponent2 = class extends Renderable {
756
932
  }
757
933
  return pcbRotation ?? null;
758
934
  }
935
+ getResolvedPcbPositionProp() {
936
+ return {
937
+ pcbX: this._resolvePcbCoordinate(this._parsedProps.pcbX, "pcbX"),
938
+ pcbY: this._resolvePcbCoordinate(this._parsedProps.pcbY, "pcbY")
939
+ };
940
+ }
941
+ _resolvePcbCoordinate(rawValue, axis, options = {}) {
942
+ if (rawValue == null) return 0;
943
+ if (typeof rawValue === "number") return rawValue;
944
+ if (typeof rawValue !== "string") {
945
+ throw new Error(
946
+ `Invalid ${axis} value for ${this.componentName}: ${String(rawValue)}`
947
+ );
948
+ }
949
+ const allowBoardVariables = options.allowBoardVariables ?? this._isNormalComponent === true;
950
+ const includesBoardVariable = rawValue.includes("board.");
951
+ const knownVariables = {};
952
+ if (allowBoardVariables) {
953
+ const board = this._getBoard();
954
+ const boardVariables = board?._getBoardCalcVariables() ?? {};
955
+ if (includesBoardVariable && !board) {
956
+ throw new Error(
957
+ `Cannot resolve ${axis} for ${this.componentName}: no board found for board.* variables`
958
+ );
959
+ }
960
+ if (includesBoardVariable && board && Object.keys(boardVariables).length === 0) {
961
+ throw new Error(
962
+ "Cannot do calculations based on board size when the board is auto-sized"
963
+ );
964
+ }
965
+ Object.assign(knownVariables, boardVariables);
966
+ }
967
+ try {
968
+ return evaluateCalcString(rawValue, { knownVariables });
969
+ } catch (error) {
970
+ const message = error instanceof Error ? error.message : String(error);
971
+ throw new Error(
972
+ `Invalid ${axis} value for ${this.componentName}: ${message}`
973
+ );
974
+ }
975
+ }
759
976
  /**
760
977
  * Computes a transformation matrix from the props of this component for PCB
761
978
  * components
762
979
  */
763
980
  computePcbPropsTransform() {
764
- const { _parsedProps: props } = this;
765
981
  const rotation4 = this._getPcbRotationBeforeLayout() ?? 0;
982
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
766
983
  const matrix = compose(
767
- translate(props.pcbX ?? 0, props.pcbY ?? 0),
984
+ translate(pcbX, pcbY),
768
985
  rotate(rotation4 * Math.PI / 180)
769
986
  );
770
987
  return matrix;
@@ -1021,6 +1238,17 @@ var PrimitiveComponent2 = class extends Renderable {
1021
1238
  _getGlobalSchematicPositionBeforeLayout() {
1022
1239
  return applyToPoint(this.computeSchematicGlobalTransform(), { x: 0, y: 0 });
1023
1240
  }
1241
+ _getBoard() {
1242
+ let current = this;
1243
+ while (current) {
1244
+ const maybePrimitive = current;
1245
+ if (maybePrimitive.componentName === "Board") {
1246
+ return maybePrimitive;
1247
+ }
1248
+ current = current.parent ?? null;
1249
+ }
1250
+ return this.root?._getBoard();
1251
+ }
1024
1252
  get root() {
1025
1253
  return this.parent?.root ?? null;
1026
1254
  }
@@ -1237,7 +1465,7 @@ var PrimitiveComponent2 = class extends Renderable {
1237
1465
  return this._parsedProps.layers;
1238
1466
  }
1239
1467
  if (this.componentName === "PlatedHole") {
1240
- return this.root?._getBoard()?.allLayers ?? ["top", "bottom"];
1468
+ return [...this.root?._getBoard()?.allLayers ?? ["top", "bottom"]];
1241
1469
  }
1242
1470
  return [];
1243
1471
  }
@@ -1353,6 +1581,19 @@ import { z as z2 } from "zod";
1353
1581
  var ErrorPlaceholderComponent = class extends PrimitiveComponent2 {
1354
1582
  constructor(props, error) {
1355
1583
  super(props);
1584
+ const resolveCoordinate = (value, axis) => {
1585
+ if (typeof value === "number") return value;
1586
+ if (typeof value === "string") {
1587
+ try {
1588
+ return this._resolvePcbCoordinate(value, axis, {
1589
+ allowBoardVariables: false
1590
+ });
1591
+ } catch (err) {
1592
+ return 0;
1593
+ }
1594
+ }
1595
+ return 0;
1596
+ };
1356
1597
  this._parsedProps = {
1357
1598
  ...props,
1358
1599
  error,
@@ -1360,8 +1601,8 @@ var ErrorPlaceholderComponent = class extends PrimitiveComponent2 {
1360
1601
  component_name: props.name,
1361
1602
  error_type: "source_failed_to_create_component_error",
1362
1603
  message: error instanceof Error ? error.message : String(error),
1363
- pcbX: props.pcbX,
1364
- pcbY: props.pcbY,
1604
+ pcbX: resolveCoordinate(props.pcbX, "pcbX"),
1605
+ pcbY: resolveCoordinate(props.pcbY, "pcbY"),
1365
1606
  schX: props.schX,
1366
1607
  schY: props.schY
1367
1608
  };
@@ -4791,9 +5032,10 @@ var CadModel = class extends PrimitiveComponent2 {
4791
5032
  rotationOffset.y = Number(parsed.y);
4792
5033
  rotationOffset.z = Number(parsed.z);
4793
5034
  }
5035
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
4794
5036
  const positionOffset = point3.parse({
4795
- x: props.pcbX ?? 0,
4796
- y: props.pcbY ?? 0,
5037
+ x: pcbX,
5038
+ y: pcbY,
4797
5039
  z: props.pcbZ ?? 0,
4798
5040
  ...typeof props.positionOffset === "object" ? props.positionOffset : {}
4799
5041
  });
@@ -14330,6 +14572,12 @@ var Board = class extends Group6 {
14330
14572
  }
14331
14573
  get boardThickness() {
14332
14574
  const { _parsedProps: props } = this;
14575
+ const pcbX = this._resolvePcbCoordinate(props.pcbX, "pcbX", {
14576
+ allowBoardVariables: false
14577
+ });
14578
+ const pcbY = this._resolvePcbCoordinate(props.pcbY, "pcbY", {
14579
+ allowBoardVariables: false
14580
+ });
14333
14581
  return props.thickness ?? 1.4;
14334
14582
  }
14335
14583
  /**
@@ -14345,11 +14593,45 @@ var Board = class extends Group6 {
14345
14593
  _getSubcircuitLayerCount() {
14346
14594
  return this._parsedProps.layers ?? 2;
14347
14595
  }
14596
+ _getBoardCalcVariables() {
14597
+ const { _parsedProps: props } = this;
14598
+ const isAutoSized = (props.width == null || props.height == null) && !props.outline;
14599
+ if (isAutoSized) return {};
14600
+ const dbBoard = this.pcb_board_id ? this.root?.db.pcb_board.get(this.pcb_board_id) : null;
14601
+ let width = dbBoard?.width ?? props.width;
14602
+ let height = dbBoard?.height ?? props.height;
14603
+ if ((width == null || height == null) && props.outline?.length) {
14604
+ const outlineBounds = getBoundsFromPoints4(props.outline);
14605
+ if (outlineBounds) {
14606
+ width ??= outlineBounds.maxX - outlineBounds.minX;
14607
+ height ??= outlineBounds.maxY - outlineBounds.minY;
14608
+ }
14609
+ }
14610
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
14611
+ const center = dbBoard?.center ?? {
14612
+ x: pcbX + (props.outlineOffsetX ?? 0),
14613
+ y: pcbY + (props.outlineOffsetY ?? 0)
14614
+ };
14615
+ const resolvedWidth = width ?? 0;
14616
+ const resolvedHeight = height ?? 0;
14617
+ return {
14618
+ "board.minx": center.x - resolvedWidth / 2,
14619
+ "board.maxx": center.x + resolvedWidth / 2,
14620
+ "board.miny": center.y - resolvedHeight / 2,
14621
+ "board.maxy": center.y + resolvedHeight / 2
14622
+ };
14623
+ }
14348
14624
  doInitialPcbBoardAutoSize() {
14349
14625
  if (this.root?.pcbDisabled) return;
14350
14626
  if (!this.pcb_board_id) return;
14351
14627
  const { db } = this.root;
14352
14628
  const { _parsedProps: props } = this;
14629
+ const pcbX = this._resolvePcbCoordinate(props.pcbX, "pcbX", {
14630
+ allowBoardVariables: false
14631
+ });
14632
+ const pcbY = this._resolvePcbCoordinate(props.pcbY, "pcbY", {
14633
+ allowBoardVariables: false
14634
+ });
14353
14635
  if (props.width && props.height || props.outline) return;
14354
14636
  let minX = Infinity;
14355
14637
  let minY = Infinity;
@@ -14398,8 +14680,8 @@ var Board = class extends Group6 {
14398
14680
  const computedWidth = hasComponents ? maxX - minX + padding * 2 : 0;
14399
14681
  const computedHeight = hasComponents ? maxY - minY + padding * 2 : 0;
14400
14682
  const center = {
14401
- x: hasComponents ? (minX + maxX) / 2 + (props.outlineOffsetX ?? 0) : props.outlineOffsetX ?? 0,
14402
- y: hasComponents ? (minY + maxY) / 2 + (props.outlineOffsetY ?? 0) : props.outlineOffsetY ?? 0
14683
+ x: hasComponents ? (minX + maxX) / 2 + (props.outlineOffsetX ?? 0) : (props.outlineOffsetX ?? 0) + pcbX,
14684
+ y: hasComponents ? (minY + maxY) / 2 + (props.outlineOffsetY ?? 0) : (props.outlineOffsetY ?? 0) + pcbY
14403
14685
  };
14404
14686
  const finalWidth = props.width ?? computedWidth;
14405
14687
  const finalHeight = props.height ?? computedHeight;
@@ -14475,9 +14757,10 @@ var Board = class extends Group6 {
14475
14757
  const { _parsedProps: props } = this;
14476
14758
  let computedWidth = props.width ?? 0;
14477
14759
  let computedHeight = props.height ?? 0;
14760
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
14478
14761
  let center = {
14479
- x: (props.pcbX ?? 0) + (props.outlineOffsetX ?? 0),
14480
- y: (props.pcbY ?? 0) + (props.outlineOffsetY ?? 0)
14762
+ x: pcbX + (props.outlineOffsetX ?? 0),
14763
+ y: pcbY + (props.outlineOffsetY ?? 0)
14481
14764
  };
14482
14765
  const { boardAnchorPosition, boardAnchorAlignment } = props;
14483
14766
  if (boardAnchorPosition) {
@@ -15122,6 +15405,7 @@ var Chip = class extends NormalComponent3 {
15122
15405
  initPorts(opts = {}) {
15123
15406
  super.initPorts(opts);
15124
15407
  const { _parsedProps: props } = this;
15408
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15125
15409
  if (props.externallyConnectedPins) {
15126
15410
  const requiredPorts = /* @__PURE__ */ new Set();
15127
15411
  for (const [pin1, pin2] of props.externallyConnectedPins) {
@@ -15162,6 +15446,7 @@ var Chip = class extends NormalComponent3 {
15162
15446
  doInitialSourceRender() {
15163
15447
  const { db } = this.root;
15164
15448
  const { _parsedProps: props } = this;
15449
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15165
15450
  const source_component = db.source_component.insert({
15166
15451
  ftype: "simple_chip",
15167
15452
  name: this.name,
@@ -15174,6 +15459,7 @@ var Chip = class extends NormalComponent3 {
15174
15459
  if (this.root?.pcbDisabled) return;
15175
15460
  const { db } = this.root;
15176
15461
  const { _parsedProps: props } = this;
15462
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15177
15463
  const componentLayer = props.layer ?? "top";
15178
15464
  if (componentLayer !== "top" && componentLayer !== "bottom") {
15179
15465
  const subcircuit = this.getSubcircuit();
@@ -15187,7 +15473,7 @@ var Chip = class extends NormalComponent3 {
15187
15473
  db.pcb_component_invalid_layer_error.insert(error);
15188
15474
  }
15189
15475
  const pcb_component = db.pcb_component.insert({
15190
- center: { x: props.pcbX ?? 0, y: props.pcbY ?? 0 },
15476
+ center: { x: pcbX, y: pcbY },
15191
15477
  width: 2,
15192
15478
  // Default width, adjust as needed
15193
15479
  height: 3,
@@ -15398,6 +15684,7 @@ var Jumper = class extends NormalComponent3 {
15398
15684
  doInitialSourceRender() {
15399
15685
  const { db } = this.root;
15400
15686
  const { _parsedProps: props } = this;
15687
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15401
15688
  const source_component = db.source_component.insert({
15402
15689
  ftype: "simple_chip",
15403
15690
  // TODO unknown or jumper
@@ -15412,8 +15699,9 @@ var Jumper = class extends NormalComponent3 {
15412
15699
  if (this.root?.pcbDisabled) return;
15413
15700
  const { db } = this.root;
15414
15701
  const { _parsedProps: props } = this;
15702
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15415
15703
  const pcb_component = db.pcb_component.insert({
15416
- center: { x: props.pcbX ?? 0, y: props.pcbY ?? 0 },
15704
+ center: { x: pcbX, y: pcbY },
15417
15705
  width: 2,
15418
15706
  // Default width, adjust as needed
15419
15707
  height: 3,
@@ -15554,6 +15842,7 @@ var SolderJumper = class extends NormalComponent3 {
15554
15842
  doInitialSourceRender() {
15555
15843
  const { db } = this.root;
15556
15844
  const { _parsedProps: props } = this;
15845
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15557
15846
  const source_component = db.source_component.insert({
15558
15847
  ftype: "simple_chip",
15559
15848
  // TODO unknown or jumper
@@ -15568,8 +15857,9 @@ var SolderJumper = class extends NormalComponent3 {
15568
15857
  if (this.root?.pcbDisabled) return;
15569
15858
  const { db } = this.root;
15570
15859
  const { _parsedProps: props } = this;
15860
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15571
15861
  const pcb_component = db.pcb_component.insert({
15572
- center: { x: props.pcbX ?? 0, y: props.pcbY ?? 0 },
15862
+ center: { x: pcbX, y: pcbY },
15573
15863
  width: 2,
15574
15864
  // Default width, adjust as needed
15575
15865
  height: 3,
@@ -15953,6 +16243,7 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
15953
16243
  if (this.root?.pcbDisabled) return;
15954
16244
  const { db } = this.root;
15955
16245
  const { _parsedProps: props } = this;
16246
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15956
16247
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
15957
16248
  const layer = maybeFlipLayer(props.layer ?? "top");
15958
16249
  if (layer !== "top" && layer !== "bottom") {
@@ -15968,8 +16259,8 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
15968
16259
  layer,
15969
16260
  color: props.color,
15970
16261
  center: {
15971
- x: props.pcbX ?? 0,
15972
- y: props.pcbY ?? 0
16262
+ x: pcbX,
16263
+ y: pcbY
15973
16264
  },
15974
16265
  width: props.width,
15975
16266
  height: props.height,
@@ -16048,13 +16339,14 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
16048
16339
  if (this.root?.pcbDisabled) return;
16049
16340
  const { db } = this.root;
16050
16341
  const { _parsedProps: props } = this;
16342
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
16051
16343
  const container = this.getPrimitiveContainer();
16052
16344
  const subcircuit = this.getSubcircuit();
16053
16345
  db.pcb_fabrication_note_text.insert({
16054
16346
  anchor_alignment: props.anchorAlignment,
16055
16347
  anchor_position: {
16056
- x: props.pcbX ?? 0,
16057
- y: props.pcbY ?? 0
16348
+ x: pcbX,
16349
+ y: pcbY
16058
16350
  },
16059
16351
  font: props.font ?? "tscircuit2024",
16060
16352
  font_size: props.fontSize ?? 1,
@@ -17035,7 +17327,7 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
17035
17327
  if (this.root?.pcbDisabled) return;
17036
17328
  const { db } = this.root;
17037
17329
  this._matchConnection();
17038
- const { pcbX = 0, pcbY = 0 } = this._parsedProps;
17330
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17039
17331
  const group = this.parent?.getGroup();
17040
17332
  const subcircuit = this.getSubcircuit();
17041
17333
  if (!group || !group.pcb_group_id) return;
@@ -17051,7 +17343,7 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
17051
17343
  this.pcb_breakout_point_id = pcb_breakout_point.pcb_breakout_point_id;
17052
17344
  }
17053
17345
  _getPcbCircuitJsonBounds() {
17054
- const { pcbX = 0, pcbY = 0 } = this._parsedProps;
17346
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17055
17347
  return {
17056
17348
  center: { x: pcbX, y: pcbY },
17057
17349
  bounds: { left: pcbX, top: pcbY, right: pcbX, bottom: pcbY },
@@ -17286,6 +17578,7 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
17286
17578
  if (this.root?.pcbDisabled) return;
17287
17579
  const { db } = this.root;
17288
17580
  const { _parsedProps: props } = this;
17581
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17289
17582
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
17290
17583
  const layer = maybeFlipLayer(props.layer ?? "top");
17291
17584
  if (layer !== "top" && layer !== "bottom") {
@@ -17300,8 +17593,8 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
17300
17593
  pcb_component_id,
17301
17594
  layer,
17302
17595
  center: {
17303
- x: props.pcbX ?? 0,
17304
- y: props.pcbY ?? 0
17596
+ x: pcbX,
17597
+ y: pcbY
17305
17598
  },
17306
17599
  radius: props.radius,
17307
17600
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
@@ -17340,13 +17633,14 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
17340
17633
  );
17341
17634
  }
17342
17635
  const subcircuit = this.getSubcircuit();
17636
+ const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17343
17637
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
17344
17638
  const pcb_silkscreen_rect = db.pcb_silkscreen_rect.insert({
17345
17639
  pcb_component_id,
17346
17640
  layer,
17347
17641
  center: {
17348
- x: props.pcbX ?? 0,
17349
- y: props.pcbY ?? 0
17642
+ x: pcbX,
17643
+ y: pcbY
17350
17644
  },
17351
17645
  width: props.width,
17352
17646
  height: props.height,
@@ -18866,7 +19160,7 @@ import { identity as identity6 } from "transformation-matrix";
18866
19160
  var package_default = {
18867
19161
  name: "@tscircuit/core",
18868
19162
  type: "module",
18869
- version: "0.0.888",
19163
+ version: "0.0.889",
18870
19164
  types: "dist/index.d.ts",
18871
19165
  main: "dist/index.js",
18872
19166
  module: "dist/index.js",
@@ -18910,7 +19204,7 @@ var package_default = {
18910
19204
  "@tscircuit/math-utils": "^0.0.29",
18911
19205
  "@tscircuit/miniflex": "^0.0.4",
18912
19206
  "@tscircuit/ngspice-spice-engine": "^0.0.4",
18913
- "@tscircuit/props": "^0.0.419",
19207
+ "@tscircuit/props": "^0.0.421",
18914
19208
  "@tscircuit/schematic-autolayout": "^0.0.6",
18915
19209
  "@tscircuit/schematic-match-adapt": "^0.0.16",
18916
19210
  "@tscircuit/schematic-trace-solver": "^v0.0.45",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.889",
4
+ "version": "0.0.890",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -45,7 +45,7 @@
45
45
  "@tscircuit/math-utils": "^0.0.29",
46
46
  "@tscircuit/miniflex": "^0.0.4",
47
47
  "@tscircuit/ngspice-spice-engine": "^0.0.4",
48
- "@tscircuit/props": "^0.0.419",
48
+ "@tscircuit/props": "^0.0.421",
49
49
  "@tscircuit/schematic-autolayout": "^0.0.6",
50
50
  "@tscircuit/schematic-match-adapt": "^0.0.16",
51
51
  "@tscircuit/schematic-trace-solver": "^v0.0.45",