@tscircuit/core 0.0.1066 → 0.0.1067

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
@@ -509,6 +509,9 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
509
509
  allowComponentVariables?: boolean;
510
510
  componentVariables?: Record<string, number>;
511
511
  }): number;
512
+ private _shouldAllowBoardVariablesByDefault;
513
+ private _isInsideFootprint;
514
+ private _isInsideNonBoardSubcircuit;
512
515
  resolvePcbCoordinate(rawValue: unknown, axis: "pcbX" | "pcbY", options?: {
513
516
  allowBoardVariables?: boolean;
514
517
  allowComponentVariables?: boolean;
package/dist/index.js CHANGED
@@ -1218,7 +1218,7 @@ var PrimitiveComponent2 = class extends Renderable {
1218
1218
  `Invalid ${axis} value for ${this.componentName}: ${String(rawValue)}`
1219
1219
  );
1220
1220
  }
1221
- const allowBoardVariables = options.allowBoardVariables ?? this._isNormalComponent === true;
1221
+ const allowBoardVariables = options.allowBoardVariables ?? this._shouldAllowBoardVariablesByDefault();
1222
1222
  const allowComponentVariables = options.allowComponentVariables ?? false;
1223
1223
  const includesBoardVariable = rawValue.includes("board.");
1224
1224
  const knownVariables = {};
@@ -1256,6 +1256,35 @@ var PrimitiveComponent2 = class extends Renderable {
1256
1256
  );
1257
1257
  }
1258
1258
  }
1259
+ _shouldAllowBoardVariablesByDefault() {
1260
+ const isNormalComponent = this._isNormalComponent === true;
1261
+ if (isNormalComponent) return true;
1262
+ return !this._isInsideFootprint() && !this._isInsideNonBoardSubcircuit();
1263
+ }
1264
+ _isInsideFootprint() {
1265
+ let current = this.parent;
1266
+ while (current) {
1267
+ if (current.componentName === "Footprint") {
1268
+ return true;
1269
+ }
1270
+ current = current.parent;
1271
+ }
1272
+ return false;
1273
+ }
1274
+ _isInsideNonBoardSubcircuit() {
1275
+ let current = this.parent;
1276
+ while (current) {
1277
+ const componentName = current.componentName;
1278
+ if (componentName === "Board" || componentName === "MountedBoard") {
1279
+ return false;
1280
+ }
1281
+ if (current.isSubcircuit) {
1282
+ return true;
1283
+ }
1284
+ current = current.parent;
1285
+ }
1286
+ return false;
1287
+ }
1259
1288
  resolvePcbCoordinate(rawValue, axis, options = {}) {
1260
1289
  return this._resolvePcbCoordinate(rawValue, axis, options);
1261
1290
  }
@@ -18114,7 +18143,7 @@ import { identity as identity5 } from "transformation-matrix";
18114
18143
  var package_default = {
18115
18144
  name: "@tscircuit/core",
18116
18145
  type: "module",
18117
- version: "0.0.1065",
18146
+ version: "0.0.1066",
18118
18147
  types: "dist/index.d.ts",
18119
18148
  main: "dist/index.js",
18120
18149
  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.1066",
4
+ "version": "0.0.1067",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",