@tscircuit/core 0.0.595 → 0.0.597
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 +4 -0
- package/dist/index.js +45 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8648,6 +8648,10 @@ declare class SilkscreenPath extends PrimitiveComponent<typeof silkscreenPathPro
|
|
|
8648
8648
|
}>;
|
|
8649
8649
|
};
|
|
8650
8650
|
doInitialPcbPrimitiveRender(): void;
|
|
8651
|
+
_setPositionFromLayout(newCenter: {
|
|
8652
|
+
x: number;
|
|
8653
|
+
y: number;
|
|
8654
|
+
}): void;
|
|
8651
8655
|
getPcbSize(): {
|
|
8652
8656
|
width: number;
|
|
8653
8657
|
height: number;
|
package/dist/index.js
CHANGED
|
@@ -1978,8 +1978,9 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
|
|
|
1978
1978
|
}
|
|
1979
1979
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
1980
1980
|
const subcircuit = this.getSubcircuit();
|
|
1981
|
+
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
1981
1982
|
const pcb_silkscreen_path = db.pcb_silkscreen_path.insert({
|
|
1982
|
-
pcb_component_id
|
|
1983
|
+
pcb_component_id,
|
|
1983
1984
|
layer,
|
|
1984
1985
|
route: props.route.map((p) => {
|
|
1985
1986
|
const transformedPosition = applyToPoint2(transform, {
|
|
@@ -1998,6 +1999,30 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
|
|
|
1998
1999
|
});
|
|
1999
2000
|
this.pcb_silkscreen_path_id = pcb_silkscreen_path.pcb_silkscreen_path_id;
|
|
2000
2001
|
}
|
|
2002
|
+
_setPositionFromLayout(newCenter) {
|
|
2003
|
+
const { db } = this.root;
|
|
2004
|
+
const { _parsedProps: props } = this;
|
|
2005
|
+
const currentPath = db.pcb_silkscreen_path.get(this.pcb_silkscreen_path_id);
|
|
2006
|
+
if (!currentPath) return;
|
|
2007
|
+
let currentCenterX = 0;
|
|
2008
|
+
let currentCenterY = 0;
|
|
2009
|
+
for (const point of currentPath.route) {
|
|
2010
|
+
currentCenterX += point.x;
|
|
2011
|
+
currentCenterY += point.y;
|
|
2012
|
+
}
|
|
2013
|
+
currentCenterX /= currentPath.route.length;
|
|
2014
|
+
currentCenterY /= currentPath.route.length;
|
|
2015
|
+
const offsetX = newCenter.x - currentCenterX;
|
|
2016
|
+
const offsetY = newCenter.y - currentCenterY;
|
|
2017
|
+
const newRoute = currentPath.route.map((point) => ({
|
|
2018
|
+
...point,
|
|
2019
|
+
x: point.x + offsetX,
|
|
2020
|
+
y: point.y + offsetY
|
|
2021
|
+
}));
|
|
2022
|
+
db.pcb_silkscreen_path.update(this.pcb_silkscreen_path_id, {
|
|
2023
|
+
route: newRoute
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2001
2026
|
getPcbSize() {
|
|
2002
2027
|
const { _parsedProps: props } = this;
|
|
2003
2028
|
if (!props.route || props.route.length === 0) {
|
|
@@ -8155,6 +8180,7 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
8155
8180
|
);
|
|
8156
8181
|
const subtree = buildSubtree2(db.toArray(), { source_group_id: componentId });
|
|
8157
8182
|
transformPCBElements2(subtree, transformMatrix);
|
|
8183
|
+
db.pcb_group.update(pcbGroup.pcb_group_id, { center });
|
|
8158
8184
|
}
|
|
8159
8185
|
};
|
|
8160
8186
|
|
|
@@ -8957,15 +8983,21 @@ var Board = class extends Group {
|
|
|
8957
8983
|
let maxX = -Infinity;
|
|
8958
8984
|
let maxY = -Infinity;
|
|
8959
8985
|
const allPcbComponents = db.pcb_component.list();
|
|
8986
|
+
const allPcbGroups = db.pcb_group.list();
|
|
8960
8987
|
let hasComponents = false;
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
if (width === 0 || height === 0) continue;
|
|
8988
|
+
const updateBounds = (center2, width, height) => {
|
|
8989
|
+
if (width === 0 || height === 0) return;
|
|
8964
8990
|
hasComponents = true;
|
|
8965
8991
|
minX = Math.min(minX, center2.x - width / 2);
|
|
8966
8992
|
minY = Math.min(minY, center2.y - height / 2);
|
|
8967
8993
|
maxX = Math.max(maxX, center2.x + width / 2);
|
|
8968
8994
|
maxY = Math.max(maxY, center2.y + height / 2);
|
|
8995
|
+
};
|
|
8996
|
+
for (const pcbComponent of allPcbComponents) {
|
|
8997
|
+
updateBounds(pcbComponent.center, pcbComponent.width, pcbComponent.height);
|
|
8998
|
+
}
|
|
8999
|
+
for (const pcbGroup of allPcbGroups) {
|
|
9000
|
+
updateBounds(pcbGroup.center, pcbGroup.width, pcbGroup.height);
|
|
8969
9001
|
}
|
|
8970
9002
|
const padding = 2;
|
|
8971
9003
|
const computedWidth = hasComponents ? maxX - minX + padding * 2 : 0;
|
|
@@ -9812,8 +9844,9 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
|
|
|
9812
9844
|
);
|
|
9813
9845
|
}
|
|
9814
9846
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
9847
|
+
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
9815
9848
|
const fabrication_note_path = db.pcb_fabrication_note_path.insert({
|
|
9816
|
-
pcb_component_id
|
|
9849
|
+
pcb_component_id,
|
|
9817
9850
|
layer,
|
|
9818
9851
|
color: props.color,
|
|
9819
9852
|
route: props.route.map((p) => {
|
|
@@ -10133,8 +10166,9 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
|
|
|
10133
10166
|
}
|
|
10134
10167
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
10135
10168
|
const subcircuit = this.getSubcircuit();
|
|
10169
|
+
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
10136
10170
|
const pcb_silkscreen_circle = db.pcb_silkscreen_circle.insert({
|
|
10137
|
-
pcb_component_id
|
|
10171
|
+
pcb_component_id,
|
|
10138
10172
|
layer,
|
|
10139
10173
|
center: {
|
|
10140
10174
|
x: props.pcbX ?? 0,
|
|
@@ -10177,8 +10211,9 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
|
|
|
10177
10211
|
);
|
|
10178
10212
|
}
|
|
10179
10213
|
const subcircuit = this.getSubcircuit();
|
|
10214
|
+
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
10180
10215
|
const pcb_silkscreen_rect = db.pcb_silkscreen_rect.insert({
|
|
10181
|
-
pcb_component_id
|
|
10216
|
+
pcb_component_id,
|
|
10182
10217
|
layer,
|
|
10183
10218
|
center: {
|
|
10184
10219
|
x: props.pcbX ?? 0,
|
|
@@ -10221,8 +10256,9 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
|
|
|
10221
10256
|
);
|
|
10222
10257
|
}
|
|
10223
10258
|
const subcircuit = this.getSubcircuit();
|
|
10259
|
+
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
10224
10260
|
const pcb_silkscreen_line = db.pcb_silkscreen_line.insert({
|
|
10225
|
-
pcb_component_id
|
|
10261
|
+
pcb_component_id,
|
|
10226
10262
|
layer,
|
|
10227
10263
|
x1: props.x1,
|
|
10228
10264
|
y1: props.y1,
|
|
@@ -11228,7 +11264,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
11228
11264
|
var package_default = {
|
|
11229
11265
|
name: "@tscircuit/core",
|
|
11230
11266
|
type: "module",
|
|
11231
|
-
version: "0.0.
|
|
11267
|
+
version: "0.0.596",
|
|
11232
11268
|
types: "dist/index.d.ts",
|
|
11233
11269
|
main: "dist/index.js",
|
|
11234
11270
|
module: "dist/index.js",
|