@tscircuit/core 0.0.111 → 0.0.112
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 +61 -53
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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;
|
|
@@ -3705,59 +3766,6 @@ var FabricationNoteText = class extends PrimitiveComponent {
|
|
|
3705
3766
|
}
|
|
3706
3767
|
};
|
|
3707
3768
|
|
|
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
3769
|
// lib/components/primitive-components/SilkscreenCircle.ts
|
|
3762
3770
|
import { silkscreenCircleProps } from "@tscircuit/props";
|
|
3763
3771
|
var SilkscreenCircle = class extends PrimitiveComponent {
|