@tscircuit/core 0.0.111 → 0.0.113
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 +71 -57
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ __export(components_exports, {
|
|
|
39
39
|
|
|
40
40
|
// lib/components/base-components/NormalComponent.ts
|
|
41
41
|
import { fp } from "@tscircuit/footprinter";
|
|
42
|
-
import { rotation } from "circuit-json";
|
|
42
|
+
import { point3, rotation } from "circuit-json";
|
|
43
43
|
|
|
44
44
|
// lib/fiber/create-instance-from-react-element.ts
|
|
45
45
|
import ReactReconciler from "react-reconciler";
|
|
@@ -1268,6 +1268,59 @@ var Keepout = class extends PrimitiveComponent {
|
|
|
1268
1268
|
}
|
|
1269
1269
|
};
|
|
1270
1270
|
|
|
1271
|
+
// lib/components/primitive-components/Hole.ts
|
|
1272
|
+
import { holeProps } from "@tscircuit/props";
|
|
1273
|
+
var Hole = class extends PrimitiveComponent {
|
|
1274
|
+
pcb_hole_id = null;
|
|
1275
|
+
isPcbPrimitive = true;
|
|
1276
|
+
get config() {
|
|
1277
|
+
return {
|
|
1278
|
+
componentName: "Hole",
|
|
1279
|
+
zodProps: holeProps
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
getPcbSize() {
|
|
1283
|
+
const { _parsedProps: props } = this;
|
|
1284
|
+
return { width: props.diameter, height: props.diameter };
|
|
1285
|
+
}
|
|
1286
|
+
doInitialPcbPrimitiveRender() {
|
|
1287
|
+
const { db } = this.root;
|
|
1288
|
+
const { _parsedProps: props } = this;
|
|
1289
|
+
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
1290
|
+
const inserted_hole = db.pcb_hole.insert({
|
|
1291
|
+
hole_shape: "circle",
|
|
1292
|
+
// @ts-ignore
|
|
1293
|
+
hole_diameter: props.diameter,
|
|
1294
|
+
x: position.x,
|
|
1295
|
+
y: position.y
|
|
1296
|
+
});
|
|
1297
|
+
this.pcb_hole_id = inserted_hole.pcb_hole_id;
|
|
1298
|
+
}
|
|
1299
|
+
_getPcbCircuitJsonBounds() {
|
|
1300
|
+
const { db } = this.root;
|
|
1301
|
+
const hole = db.pcb_hole.get(this.pcb_hole_id);
|
|
1302
|
+
const size = this.getPcbSize();
|
|
1303
|
+
return {
|
|
1304
|
+
center: { x: hole.x, y: hole.y },
|
|
1305
|
+
bounds: {
|
|
1306
|
+
left: hole.x - size.width / 2,
|
|
1307
|
+
top: hole.y - size.height / 2,
|
|
1308
|
+
right: hole.x + size.width / 2,
|
|
1309
|
+
bottom: hole.y + size.height / 2
|
|
1310
|
+
},
|
|
1311
|
+
width: size.width,
|
|
1312
|
+
height: size.height
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
_setPositionFromLayout(newCenter) {
|
|
1316
|
+
const { db } = this.root;
|
|
1317
|
+
db.pcb_hole.update(this.pcb_hole_id, {
|
|
1318
|
+
x: newCenter.x,
|
|
1319
|
+
y: newCenter.y
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1271
1324
|
// lib/utils/createComponentsFromSoup.ts
|
|
1272
1325
|
var createComponentsFromSoup = (soup) => {
|
|
1273
1326
|
const components = [];
|
|
@@ -1335,6 +1388,14 @@ var createComponentsFromSoup = (soup) => {
|
|
|
1335
1388
|
height: elm.height
|
|
1336
1389
|
})
|
|
1337
1390
|
);
|
|
1391
|
+
} else if (elm.type === "pcb_hole" && elm.hole_shape === "circle") {
|
|
1392
|
+
components.push(
|
|
1393
|
+
new Hole({
|
|
1394
|
+
pcbX: elm.x,
|
|
1395
|
+
pcbY: elm.y,
|
|
1396
|
+
diameter: elm.hole_diameter
|
|
1397
|
+
})
|
|
1398
|
+
);
|
|
1338
1399
|
}
|
|
1339
1400
|
}
|
|
1340
1401
|
return components;
|
|
@@ -2171,12 +2232,18 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2171
2232
|
z: typeof cadModel?.rotationOffset === "number" ? cadModel.rotationOffset : 0,
|
|
2172
2233
|
...typeof cadModel?.rotationOffset === "object" ? cadModel.rotationOffset ?? {} : {}
|
|
2173
2234
|
});
|
|
2235
|
+
const positionOffset = point3.parse({
|
|
2236
|
+
x: 0,
|
|
2237
|
+
y: 0,
|
|
2238
|
+
z: 0,
|
|
2239
|
+
...typeof cadModel?.positionOffset === "object" ? cadModel.positionOffset : {}
|
|
2240
|
+
});
|
|
2174
2241
|
const cad_model = db.cad_component.insert({
|
|
2175
2242
|
// TODO z maybe depends on layer
|
|
2176
2243
|
position: {
|
|
2177
|
-
x: bounds.center.x,
|
|
2178
|
-
y: bounds.center.y,
|
|
2179
|
-
z: this.props.layer === "bottom" ? -boardThickness / 2 : boardThickness / 2
|
|
2244
|
+
x: bounds.center.x + positionOffset.x,
|
|
2245
|
+
y: bounds.center.y + positionOffset.y,
|
|
2246
|
+
z: (this.props.layer === "bottom" ? -boardThickness / 2 : boardThickness / 2) + positionOffset.z
|
|
2180
2247
|
},
|
|
2181
2248
|
rotation: {
|
|
2182
2249
|
x: rotationOffset.x,
|
|
@@ -3705,59 +3772,6 @@ var FabricationNoteText = class extends PrimitiveComponent {
|
|
|
3705
3772
|
}
|
|
3706
3773
|
};
|
|
3707
3774
|
|
|
3708
|
-
// lib/components/primitive-components/Hole.ts
|
|
3709
|
-
import { holeProps } from "@tscircuit/props";
|
|
3710
|
-
var Hole = class extends PrimitiveComponent {
|
|
3711
|
-
pcb_hole_id = null;
|
|
3712
|
-
isPcbPrimitive = true;
|
|
3713
|
-
get config() {
|
|
3714
|
-
return {
|
|
3715
|
-
componentName: "Hole",
|
|
3716
|
-
zodProps: holeProps
|
|
3717
|
-
};
|
|
3718
|
-
}
|
|
3719
|
-
getPcbSize() {
|
|
3720
|
-
const { _parsedProps: props } = this;
|
|
3721
|
-
return { width: props.diameter, height: props.diameter };
|
|
3722
|
-
}
|
|
3723
|
-
doInitialPcbPrimitiveRender() {
|
|
3724
|
-
const { db } = this.root;
|
|
3725
|
-
const { _parsedProps: props } = this;
|
|
3726
|
-
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
3727
|
-
const inserted_hole = db.pcb_hole.insert({
|
|
3728
|
-
hole_shape: "circle",
|
|
3729
|
-
// @ts-ignore
|
|
3730
|
-
hole_diameter: props.diameter,
|
|
3731
|
-
x: position.x,
|
|
3732
|
-
y: position.y
|
|
3733
|
-
});
|
|
3734
|
-
this.pcb_hole_id = inserted_hole.pcb_hole_id;
|
|
3735
|
-
}
|
|
3736
|
-
_getPcbCircuitJsonBounds() {
|
|
3737
|
-
const { db } = this.root;
|
|
3738
|
-
const hole = db.pcb_hole.get(this.pcb_hole_id);
|
|
3739
|
-
const size = this.getPcbSize();
|
|
3740
|
-
return {
|
|
3741
|
-
center: { x: hole.x, y: hole.y },
|
|
3742
|
-
bounds: {
|
|
3743
|
-
left: hole.x - size.width / 2,
|
|
3744
|
-
top: hole.y - size.height / 2,
|
|
3745
|
-
right: hole.x + size.width / 2,
|
|
3746
|
-
bottom: hole.y + size.height / 2
|
|
3747
|
-
},
|
|
3748
|
-
width: size.width,
|
|
3749
|
-
height: size.height
|
|
3750
|
-
};
|
|
3751
|
-
}
|
|
3752
|
-
_setPositionFromLayout(newCenter) {
|
|
3753
|
-
const { db } = this.root;
|
|
3754
|
-
db.pcb_hole.update(this.pcb_hole_id, {
|
|
3755
|
-
x: newCenter.x,
|
|
3756
|
-
y: newCenter.y
|
|
3757
|
-
});
|
|
3758
|
-
}
|
|
3759
|
-
};
|
|
3760
|
-
|
|
3761
3775
|
// lib/components/primitive-components/SilkscreenCircle.ts
|
|
3762
3776
|
import { silkscreenCircleProps } from "@tscircuit/props";
|
|
3763
3777
|
var SilkscreenCircle = class extends PrimitiveComponent {
|