@tscircuit/core 0.0.1034 → 0.0.1036
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.js +28 -16
- package/package.json +2 -2
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}.
|
|
11491
|
-
vars[`${component.name}.
|
|
11492
|
-
vars[`${component.name}.
|
|
11493
|
-
vars[`${component.name}.
|
|
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}.
|
|
11506
|
-
vars[`${referencePath}.
|
|
11507
|
-
vars[`${referencePath}.
|
|
11508
|
-
vars[`${referencePath}.
|
|
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.
|
|
12550
|
+
version: "0.0.1035",
|
|
12539
12551
|
types: "dist/index.d.ts",
|
|
12540
12552
|
main: "dist/index.js",
|
|
12541
12553
|
module: "dist/index.js",
|
|
@@ -12596,7 +12608,7 @@ var package_default = {
|
|
|
12596
12608
|
"circuit-json": "^0.0.378",
|
|
12597
12609
|
"circuit-json-to-bpc": "^0.0.13",
|
|
12598
12610
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
12599
|
-
"circuit-json-to-gltf": "^0.0.
|
|
12611
|
+
"circuit-json-to-gltf": "^0.0.65",
|
|
12600
12612
|
"circuit-json-to-simple-3d": "^0.0.9",
|
|
12601
12613
|
"circuit-json-to-spice": "^0.0.34",
|
|
12602
12614
|
"circuit-to-svg": "^0.0.327",
|
|
@@ -17564,10 +17576,10 @@ var Board = class extends Group {
|
|
|
17564
17576
|
const resolvedWidth = width ?? 0;
|
|
17565
17577
|
const resolvedHeight = height ?? 0;
|
|
17566
17578
|
return {
|
|
17567
|
-
"board.
|
|
17568
|
-
"board.
|
|
17569
|
-
"board.
|
|
17570
|
-
"board.
|
|
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
|
|
17571
17583
|
};
|
|
17572
17584
|
}
|
|
17573
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.
|
|
4
|
+
"version": "0.0.1036",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"circuit-json": "^0.0.378",
|
|
63
63
|
"circuit-json-to-bpc": "^0.0.13",
|
|
64
64
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
65
|
-
"circuit-json-to-gltf": "^0.0.
|
|
65
|
+
"circuit-json-to-gltf": "^0.0.65",
|
|
66
66
|
"circuit-json-to-simple-3d": "^0.0.9",
|
|
67
67
|
"circuit-json-to-spice": "^0.0.34",
|
|
68
68
|
"circuit-to-svg": "^0.0.327",
|