@tscircuit/core 0.0.1033 → 0.0.1035

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 +50 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -651,16 +651,28 @@ var defaultUnits = {
651
651
  function evaluateCalcString(input, options) {
652
652
  const { knownVariables, units: userUnits } = options;
653
653
  const units = { ...defaultUnits, ...userUnits ?? {} };
654
- const expr = extractExpression(input);
654
+ const expr = normalizeLegacyBoundsIdentifierCase(extractExpression(input));
655
655
  const tokens = tokenize(expr, units);
656
656
  const result = parseExpression(tokens, knownVariables);
657
657
  return result;
658
658
  }
659
659
  function extractCalcIdentifiers(input) {
660
- const expr = extractExpression(input);
660
+ const expr = normalizeLegacyBoundsIdentifierCase(extractExpression(input));
661
661
  const tokens = tokenize(expr, defaultUnits);
662
662
  return tokens.filter((token) => token.type === "identifier").map((token) => token.value);
663
663
  }
664
+ function normalizeLegacyBoundsIdentifierCase(expr) {
665
+ const legacyBoundNameToCamelCase = {
666
+ minx: "minX",
667
+ maxx: "maxX",
668
+ miny: "minY",
669
+ maxy: "maxY"
670
+ };
671
+ return expr.replace(/\.(minx|maxx|miny|maxy)\b/gi, (match, boundName) => {
672
+ const normalizedBoundName = legacyBoundNameToCamelCase[String(boundName).toLowerCase()];
673
+ return `.${normalizedBoundName ?? match.slice(1)}`;
674
+ });
675
+ }
664
676
  function extractExpression(raw) {
665
677
  const trimmed = raw.trim();
666
678
  if (!trimmed.toLowerCase().startsWith("calc")) {
@@ -11487,10 +11499,10 @@ function updateVarsForNamedComponent(component, vars) {
11487
11499
  vars[`${component.name}.y`] = y;
11488
11500
  vars[`${component.name}.width`] = width;
11489
11501
  vars[`${component.name}.height`] = height;
11490
- vars[`${component.name}.minx`] = x - width / 2;
11491
- vars[`${component.name}.maxx`] = x + width / 2;
11492
- vars[`${component.name}.miny`] = y - height / 2;
11493
- vars[`${component.name}.maxy`] = y + height / 2;
11502
+ vars[`${component.name}.minX`] = x - width / 2;
11503
+ vars[`${component.name}.maxX`] = x + width / 2;
11504
+ vars[`${component.name}.minY`] = y - height / 2;
11505
+ vars[`${component.name}.maxY`] = y + height / 2;
11494
11506
  const padElementsByReference = collectPadElementsByReference(component);
11495
11507
  for (const [referencePath, elements] of padElementsByReference.entries()) {
11496
11508
  const bounds = getBoundsOfPcbElements(elements);
@@ -11502,10 +11514,10 @@ function updateVarsForNamedComponent(component, vars) {
11502
11514
  vars[`${referencePath}.y`] = (minY + maxY) / 2;
11503
11515
  vars[`${referencePath}.width`] = maxX - minX;
11504
11516
  vars[`${referencePath}.height`] = maxY - minY;
11505
- vars[`${referencePath}.minx`] = minX;
11506
- vars[`${referencePath}.maxx`] = maxX;
11507
- vars[`${referencePath}.miny`] = minY;
11508
- vars[`${referencePath}.maxy`] = maxY;
11517
+ vars[`${referencePath}.minX`] = minX;
11518
+ vars[`${referencePath}.maxX`] = maxX;
11519
+ vars[`${referencePath}.minY`] = minY;
11520
+ vars[`${referencePath}.maxY`] = maxY;
11509
11521
  }
11510
11522
  }
11511
11523
  function collectPadElementsByReference(component) {
@@ -12535,7 +12547,7 @@ import { identity as identity4 } from "transformation-matrix";
12535
12547
  var package_default = {
12536
12548
  name: "@tscircuit/core",
12537
12549
  type: "module",
12538
- version: "0.0.1032",
12550
+ version: "0.0.1034",
12539
12551
  types: "dist/index.d.ts",
12540
12552
  main: "dist/index.js",
12541
12553
  module: "dist/index.js",
@@ -13467,6 +13479,21 @@ function rotateDirection(direction, degrees) {
13467
13479
  const newIndex = (currentIndex + steps) % 4;
13468
13480
  return directions[newIndex < 0 ? newIndex + 4 : newIndex];
13469
13481
  }
13482
+ function isTreeChildExplicitlyPositioned(treeChild, group) {
13483
+ if (treeChild.nodeType === "component" && treeChild.sourceComponent) {
13484
+ const component = group.children.find(
13485
+ (groupChild) => groupChild.source_component_id === treeChild.sourceComponent?.source_component_id
13486
+ );
13487
+ return component?._parsedProps?.schX !== void 0 || component?._parsedProps?.schY !== void 0;
13488
+ }
13489
+ if (treeChild.nodeType === "group" && treeChild.sourceGroup) {
13490
+ const nestedGroup = group.children.find(
13491
+ (groupChild) => groupChild.source_group_id === treeChild.sourceGroup?.source_group_id
13492
+ );
13493
+ return nestedGroup?._parsedProps?.schX !== void 0 || nestedGroup?._parsedProps?.schY !== void 0;
13494
+ }
13495
+ return false;
13496
+ }
13470
13497
  function convertTreeToInputProblem(tree, db, group) {
13471
13498
  const problem = {
13472
13499
  chipMap: {},
@@ -13482,6 +13509,12 @@ function convertTreeToInputProblem(tree, db, group) {
13482
13509
  `[${group.name}] Processing ${tree.childNodes.length} child nodes for input problem`
13483
13510
  );
13484
13511
  tree.childNodes.forEach((child, index) => {
13512
+ if (isTreeChildExplicitlyPositioned(child, group)) {
13513
+ debug6(
13514
+ `[${group.name}] Skipping explicitly positioned child ${index} from matchpack`
13515
+ );
13516
+ return;
13517
+ }
13485
13518
  debug6(
13486
13519
  `[${group.name}] Processing child ${index}: nodeType=${child.nodeType}`
13487
13520
  );
@@ -16099,6 +16132,7 @@ var Group = class extends NormalComponent3 {
16099
16132
  }
16100
16133
  _getSchematicLayoutMode() {
16101
16134
  const props = this._parsedProps;
16135
+ const schAutoLayoutEnabled = props.schAutoLayoutEnabled ?? false;
16102
16136
  if (props.schLayout?.layoutMode === "none") return "relative";
16103
16137
  if (props.schLayout?.layoutMode === "relative") return "relative";
16104
16138
  if (props.schLayout?.matchAdapt) return "match-adapt";
@@ -16117,6 +16151,7 @@ var Group = class extends NormalComponent3 {
16117
16151
  return cProps?.schX !== void 0 || cProps?.schY !== void 0;
16118
16152
  });
16119
16153
  const hasManualEdits = (props.manualEdits?.schematic_placements?.length ?? 0) > 0;
16154
+ if (schAutoLayoutEnabled && !hasManualEdits) return "match-adapt";
16120
16155
  if (!anyChildHasSchCoords && !hasManualEdits) return "match-adapt";
16121
16156
  return "relative";
16122
16157
  }
@@ -17541,10 +17576,10 @@ var Board = class extends Group {
17541
17576
  const resolvedWidth = width ?? 0;
17542
17577
  const resolvedHeight = height ?? 0;
17543
17578
  return {
17544
- "board.minx": center.x - resolvedWidth / 2,
17545
- "board.maxx": center.x + resolvedWidth / 2,
17546
- "board.miny": center.y - resolvedHeight / 2,
17547
- "board.maxy": center.y + resolvedHeight / 2
17579
+ "board.minX": center.x - resolvedWidth / 2,
17580
+ "board.maxX": center.x + resolvedWidth / 2,
17581
+ "board.minY": center.y - resolvedHeight / 2,
17582
+ "board.maxY": center.y + resolvedHeight / 2
17548
17583
  };
17549
17584
  }
17550
17585
  doInitialPcbBoardAutoSize() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1033",
4
+ "version": "0.0.1035",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",