@tscircuit/core 0.0.1099 → 0.0.1101
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 +1 -0
- package/dist/index.js +60 -11
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -497,6 +497,7 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
|
|
|
497
497
|
schematic_component_id: string | null;
|
|
498
498
|
pcb_component_id: string | null;
|
|
499
499
|
cad_component_id: string | null;
|
|
500
|
+
_reportedInvalidPcbCalcWarnings: Set<string>;
|
|
500
501
|
fallbackUnassignedName?: string;
|
|
501
502
|
constructor(props: z.input<ZodProps>);
|
|
502
503
|
setProps(props: Partial<z.input<ZodProps>>): void;
|
package/dist/index.js
CHANGED
|
@@ -840,6 +840,42 @@ function parseExpression(tokens, vars) {
|
|
|
840
840
|
return result;
|
|
841
841
|
}
|
|
842
842
|
|
|
843
|
+
// lib/utils/getSubcircuitPcbCalcVariables.ts
|
|
844
|
+
function setSubcircuitPcbComponentCalcVariables(params) {
|
|
845
|
+
const { vars, componentName, position, size } = params;
|
|
846
|
+
vars[`${componentName}.x`] = position.x;
|
|
847
|
+
vars[`${componentName}.y`] = position.y;
|
|
848
|
+
vars[`${componentName}.width`] = size.width;
|
|
849
|
+
vars[`${componentName}.height`] = size.height;
|
|
850
|
+
vars[`${componentName}.minX`] = position.x - size.width / 2;
|
|
851
|
+
vars[`${componentName}.maxX`] = position.x + size.width / 2;
|
|
852
|
+
vars[`${componentName}.minY`] = position.y - size.height / 2;
|
|
853
|
+
vars[`${componentName}.maxY`] = position.y + size.height / 2;
|
|
854
|
+
}
|
|
855
|
+
function getSubcircuitPcbCalcVariables(db) {
|
|
856
|
+
const vars = {};
|
|
857
|
+
for (const sourceComponent of db.source_component.list()) {
|
|
858
|
+
if (!sourceComponent.name) continue;
|
|
859
|
+
const pcbComponent = db.pcb_component.getWhere({
|
|
860
|
+
source_component_id: sourceComponent.source_component_id
|
|
861
|
+
});
|
|
862
|
+
if (!pcbComponent) continue;
|
|
863
|
+
setSubcircuitPcbComponentCalcVariables({
|
|
864
|
+
vars,
|
|
865
|
+
componentName: sourceComponent.name,
|
|
866
|
+
position: {
|
|
867
|
+
x: pcbComponent.center.x,
|
|
868
|
+
y: pcbComponent.center.y
|
|
869
|
+
},
|
|
870
|
+
size: {
|
|
871
|
+
width: pcbComponent.width ?? 0,
|
|
872
|
+
height: pcbComponent.height ?? 0
|
|
873
|
+
}
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
return vars;
|
|
877
|
+
}
|
|
878
|
+
|
|
843
879
|
// lib/utils/pcbSx/convert-pcb-style-to-pcb-sx.ts
|
|
844
880
|
function convertPcbStyleToPcbSx(pcbStyle) {
|
|
845
881
|
if (!pcbStyle) return void 0;
|
|
@@ -1163,6 +1199,7 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
1163
1199
|
schematic_component_id = null;
|
|
1164
1200
|
pcb_component_id = null;
|
|
1165
1201
|
cad_component_id = null;
|
|
1202
|
+
_reportedInvalidPcbCalcWarnings = /* @__PURE__ */ new Set();
|
|
1166
1203
|
fallbackUnassignedName;
|
|
1167
1204
|
constructor(props) {
|
|
1168
1205
|
super(props);
|
|
@@ -1221,7 +1258,8 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
1221
1258
|
);
|
|
1222
1259
|
}
|
|
1223
1260
|
const allowBoardVariables = options.allowBoardVariables ?? this._shouldAllowBoardVariablesByDefault();
|
|
1224
|
-
const
|
|
1261
|
+
const isNormalComponent = this._isNormalComponent === true;
|
|
1262
|
+
const allowComponentVariables = options.allowComponentVariables ?? (!isNormalComponent && !this._isInsideFootprint());
|
|
1225
1263
|
const includesBoardVariable = rawValue.includes("board.");
|
|
1226
1264
|
const knownVariables = {};
|
|
1227
1265
|
if (allowBoardVariables) {
|
|
@@ -1240,6 +1278,10 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
1240
1278
|
Object.assign(knownVariables, boardVariables);
|
|
1241
1279
|
}
|
|
1242
1280
|
if (allowComponentVariables) {
|
|
1281
|
+
const db = this.root?.db;
|
|
1282
|
+
if (db) {
|
|
1283
|
+
Object.assign(knownVariables, getSubcircuitPcbCalcVariables(db));
|
|
1284
|
+
}
|
|
1243
1285
|
Object.assign(knownVariables, options.componentVariables ?? {});
|
|
1244
1286
|
}
|
|
1245
1287
|
try {
|
|
@@ -1248,6 +1290,15 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
1248
1290
|
(identifier) => !identifier.startsWith("board.")
|
|
1249
1291
|
);
|
|
1250
1292
|
if (includesComponentVariable && !allowComponentVariables) {
|
|
1293
|
+
if (this._isInsideFootprint() && this.root && !this._reportedInvalidPcbCalcWarnings.has(axis)) {
|
|
1294
|
+
this.root.db.source_invalid_component_property_error.insert({
|
|
1295
|
+
source_component_id: this.source_component_id || "",
|
|
1296
|
+
property_name: axis,
|
|
1297
|
+
message: `component-relative calc references are not supported for footprint elements (${this.componentName}); ${axis} will be ignored. expression="${rawValue}"`,
|
|
1298
|
+
error_type: "source_invalid_component_property_error"
|
|
1299
|
+
});
|
|
1300
|
+
this._reportedInvalidPcbCalcWarnings.add(axis);
|
|
1301
|
+
}
|
|
1251
1302
|
return 0;
|
|
1252
1303
|
}
|
|
1253
1304
|
return evaluateCalcString(rawValue, { knownVariables });
|
|
@@ -13109,14 +13160,12 @@ function updateVarsForNamedComponent(component, vars) {
|
|
|
13109
13160
|
const height = pcbComponent.height ?? 0;
|
|
13110
13161
|
const x = pcbComponent.center.x;
|
|
13111
13162
|
const y = pcbComponent.center.y;
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
vars[`${component.name}.minY`] = y - height / 2;
|
|
13119
|
-
vars[`${component.name}.maxY`] = y + height / 2;
|
|
13163
|
+
setSubcircuitPcbComponentCalcVariables({
|
|
13164
|
+
vars,
|
|
13165
|
+
componentName: component.name,
|
|
13166
|
+
position: { x, y },
|
|
13167
|
+
size: { width, height }
|
|
13168
|
+
});
|
|
13120
13169
|
const padElementsByReference = collectPadElementsByReference(component);
|
|
13121
13170
|
for (const [referencePath, elements] of padElementsByReference.entries()) {
|
|
13122
13171
|
const bounds = getBoundsOfPcbElements(elements);
|
|
@@ -18211,7 +18260,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
18211
18260
|
var package_default = {
|
|
18212
18261
|
name: "@tscircuit/core",
|
|
18213
18262
|
type: "module",
|
|
18214
|
-
version: "0.0.
|
|
18263
|
+
version: "0.0.1100",
|
|
18215
18264
|
types: "dist/index.d.ts",
|
|
18216
18265
|
main: "dist/index.js",
|
|
18217
18266
|
module: "dist/index.js",
|
|
@@ -18270,7 +18319,7 @@ var package_default = {
|
|
|
18270
18319
|
"bun-match-svg": "0.0.12",
|
|
18271
18320
|
"calculate-elbow": "^0.0.12",
|
|
18272
18321
|
"chokidar-cli": "^3.0.0",
|
|
18273
|
-
"circuit-json": "^0.0.
|
|
18322
|
+
"circuit-json": "^0.0.397",
|
|
18274
18323
|
"circuit-json-to-bpc": "^0.0.13",
|
|
18275
18324
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
18276
18325
|
"circuit-json-to-gltf": "^0.0.73",
|
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.1101",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"bun-match-svg": "0.0.12",
|
|
61
61
|
"calculate-elbow": "^0.0.12",
|
|
62
62
|
"chokidar-cli": "^3.0.0",
|
|
63
|
-
"circuit-json": "^0.0.
|
|
63
|
+
"circuit-json": "^0.0.397",
|
|
64
64
|
"circuit-json-to-bpc": "^0.0.13",
|
|
65
65
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
66
66
|
"circuit-json-to-gltf": "^0.0.73",
|