@tscircuit/core 0.0.636 → 0.0.638
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 -4
- package/dist/index.js +206 -123
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -7820,9 +7820,9 @@ declare const voltageSourceProps: z.ZodObject<{
|
|
|
7820
7820
|
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
7821
7821
|
phase?: number | undefined;
|
|
7822
7822
|
voltage?: number | undefined;
|
|
7823
|
+
frequency?: number | undefined;
|
|
7823
7824
|
pcbX?: number | undefined;
|
|
7824
7825
|
pcbY?: number | undefined;
|
|
7825
|
-
frequency?: number | undefined;
|
|
7826
7826
|
pcbRotation?: number | undefined;
|
|
7827
7827
|
schX?: number | undefined;
|
|
7828
7828
|
schY?: number | undefined;
|
|
@@ -7906,9 +7906,9 @@ declare const voltageSourceProps: z.ZodObject<{
|
|
|
7906
7906
|
} | undefined;
|
|
7907
7907
|
phase?: string | number | undefined;
|
|
7908
7908
|
voltage?: string | number | undefined;
|
|
7909
|
+
frequency?: string | number | undefined;
|
|
7909
7910
|
pcbX?: string | number | undefined;
|
|
7910
7911
|
pcbY?: string | number | undefined;
|
|
7911
|
-
frequency?: string | number | undefined;
|
|
7912
7912
|
pcbRotation?: string | number | undefined;
|
|
7913
7913
|
schX?: string | number | undefined;
|
|
7914
7914
|
schY?: string | number | undefined;
|
|
@@ -8283,9 +8283,9 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
|
|
|
8283
8283
|
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
8284
8284
|
phase?: number | undefined;
|
|
8285
8285
|
voltage?: number | undefined;
|
|
8286
|
+
frequency?: number | undefined;
|
|
8286
8287
|
pcbX?: number | undefined;
|
|
8287
8288
|
pcbY?: number | undefined;
|
|
8288
|
-
frequency?: number | undefined;
|
|
8289
8289
|
pcbRotation?: number | undefined;
|
|
8290
8290
|
schX?: number | undefined;
|
|
8291
8291
|
schY?: number | undefined;
|
|
@@ -8369,9 +8369,9 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
|
|
|
8369
8369
|
} | undefined;
|
|
8370
8370
|
phase?: string | number | undefined;
|
|
8371
8371
|
voltage?: string | number | undefined;
|
|
8372
|
+
frequency?: string | number | undefined;
|
|
8372
8373
|
pcbX?: string | number | undefined;
|
|
8373
8374
|
pcbY?: string | number | undefined;
|
|
8374
|
-
frequency?: string | number | undefined;
|
|
8375
8375
|
pcbRotation?: string | number | undefined;
|
|
8376
8376
|
schX?: string | number | undefined;
|
|
8377
8377
|
schY?: string | number | undefined;
|
package/dist/index.js
CHANGED
|
@@ -8742,10 +8742,34 @@ var getSizeOfTreeNodeChild = (db, child) => {
|
|
|
8742
8742
|
const schGroup = db.schematic_group.getWhere({
|
|
8743
8743
|
source_group_id: sourceGroup?.source_group_id
|
|
8744
8744
|
});
|
|
8745
|
-
if (
|
|
8745
|
+
if (schGroup?.width && schGroup?.height) {
|
|
8746
|
+
return {
|
|
8747
|
+
width: schGroup.width,
|
|
8748
|
+
height: schGroup.height
|
|
8749
|
+
};
|
|
8750
|
+
}
|
|
8751
|
+
const groupComponents = db.schematic_component.list({
|
|
8752
|
+
schematic_group_id: schGroup?.schematic_group_id
|
|
8753
|
+
});
|
|
8754
|
+
let minX = Infinity;
|
|
8755
|
+
let maxX = -Infinity;
|
|
8756
|
+
let minY = Infinity;
|
|
8757
|
+
let maxY = -Infinity;
|
|
8758
|
+
for (const comp of groupComponents) {
|
|
8759
|
+
if (comp.center && comp.size) {
|
|
8760
|
+
const halfWidth = comp.size.width / 2;
|
|
8761
|
+
const halfHeight = comp.size.height / 2;
|
|
8762
|
+
minX = Math.min(minX, comp.center.x - halfWidth);
|
|
8763
|
+
maxX = Math.max(maxX, comp.center.x + halfWidth);
|
|
8764
|
+
minY = Math.min(minY, comp.center.y - halfHeight);
|
|
8765
|
+
maxY = Math.max(maxY, comp.center.y + halfHeight);
|
|
8766
|
+
}
|
|
8767
|
+
}
|
|
8768
|
+
const groupWidth = maxX - minX;
|
|
8769
|
+
const groupHeight = maxY - minY;
|
|
8746
8770
|
return {
|
|
8747
|
-
width:
|
|
8748
|
-
height:
|
|
8771
|
+
width: groupWidth,
|
|
8772
|
+
height: groupHeight
|
|
8749
8773
|
};
|
|
8750
8774
|
}
|
|
8751
8775
|
return null;
|
|
@@ -8889,115 +8913,178 @@ var Group_doInitialSchematicLayoutFlex = (group) => {
|
|
|
8889
8913
|
};
|
|
8890
8914
|
|
|
8891
8915
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutGrid.ts
|
|
8892
|
-
import { translate as translate5 } from "transformation-matrix";
|
|
8893
8916
|
import {
|
|
8894
|
-
|
|
8895
|
-
|
|
8917
|
+
repositionPcbComponentTo,
|
|
8918
|
+
repositionPcbGroupTo
|
|
8896
8919
|
} from "@tscircuit/circuit-json-util";
|
|
8897
8920
|
import { length as length3 } from "circuit-json";
|
|
8898
8921
|
import { CssGrid } from "minicssgrid";
|
|
8922
|
+
var MIN_GAP = 1;
|
|
8899
8923
|
function Group_doInitialPcbLayoutGrid(group) {
|
|
8900
8924
|
const { db } = group.root;
|
|
8901
8925
|
const props = group._parsedProps;
|
|
8902
|
-
const pcbChildren = group
|
|
8903
|
-
(child) => child.pcb_component_id
|
|
8904
|
-
);
|
|
8926
|
+
const pcbChildren = getPcbChildren(group);
|
|
8905
8927
|
if (pcbChildren.length === 0) return;
|
|
8906
|
-
|
|
8907
|
-
|
|
8928
|
+
const childDimensions = calculateChildDimensions({ db, pcbChildren });
|
|
8929
|
+
const gridConfig = parseGridConfiguration(props);
|
|
8930
|
+
const gridLayout = createGridLayout({
|
|
8931
|
+
props,
|
|
8932
|
+
pcbChildren,
|
|
8933
|
+
childDimensions,
|
|
8934
|
+
gridConfig
|
|
8935
|
+
});
|
|
8936
|
+
const cssGrid = createCssGrid({
|
|
8937
|
+
pcbChildren,
|
|
8938
|
+
childDimensions,
|
|
8939
|
+
gridLayout,
|
|
8940
|
+
gridConfig
|
|
8941
|
+
});
|
|
8942
|
+
const { itemCoordinates } = cssGrid.layout();
|
|
8943
|
+
positionChildren({ db, group, pcbChildren, itemCoordinates, gridLayout });
|
|
8944
|
+
updateGroupDimensions({ db, group, props, gridLayout });
|
|
8945
|
+
}
|
|
8946
|
+
function getPcbChildren(group) {
|
|
8947
|
+
return group.children.filter(
|
|
8948
|
+
(child) => child.pcb_component_id || child.pcb_group_id
|
|
8949
|
+
);
|
|
8950
|
+
}
|
|
8951
|
+
function calculateChildDimensions(params) {
|
|
8952
|
+
const { db, pcbChildren } = params;
|
|
8953
|
+
let maxWidth = 0;
|
|
8954
|
+
let maxHeight = 0;
|
|
8908
8955
|
for (const child of pcbChildren) {
|
|
8909
|
-
|
|
8910
|
-
let
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
let gridColsOption = props.pcbGridCols ?? props.gridCols;
|
|
8923
|
-
let gridRowsOption = props.pcbGridRows;
|
|
8924
|
-
let gridGapOption = props.pcbGridGap ?? props.gridGap;
|
|
8925
|
-
let gridRowGapOption = props.pcbGridRowGap ?? props.gridRowGap;
|
|
8926
|
-
let gridColumnGapOption = props.pcbGridColumnGap ?? props.gridColumnGap;
|
|
8927
|
-
if (props.pcbLayout?.grid) {
|
|
8928
|
-
gridColsOption = props.pcbLayout.grid.cols ?? gridColsOption;
|
|
8929
|
-
gridRowsOption = props.pcbLayout.grid.rows;
|
|
8930
|
-
gridGapOption = props.pcbLayout.gridGap ?? gridGapOption;
|
|
8931
|
-
gridRowGapOption = props.pcbLayout.gridRowGap ?? gridRowGapOption;
|
|
8932
|
-
gridColumnGapOption = props.pcbLayout.gridColumnGap ?? gridColumnGapOption;
|
|
8956
|
+
let width = 0;
|
|
8957
|
+
let height = 0;
|
|
8958
|
+
if (child.pcb_group_id) {
|
|
8959
|
+
const pcbGroup = db.pcb_group.get(child.pcb_group_id);
|
|
8960
|
+
width = pcbGroup?.width ?? 0;
|
|
8961
|
+
height = pcbGroup?.height ?? 0;
|
|
8962
|
+
} else if (child.pcb_component_id) {
|
|
8963
|
+
const pcbComp = db.pcb_component.get(child.pcb_component_id);
|
|
8964
|
+
width = pcbComp?.width ?? 0;
|
|
8965
|
+
height = pcbComp?.height ?? 0;
|
|
8966
|
+
}
|
|
8967
|
+
maxWidth = Math.max(maxWidth, width);
|
|
8968
|
+
maxHeight = Math.max(maxHeight, height);
|
|
8933
8969
|
}
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8970
|
+
return {
|
|
8971
|
+
width: maxWidth,
|
|
8972
|
+
height: maxHeight
|
|
8937
8973
|
};
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8974
|
+
}
|
|
8975
|
+
function parseGridConfiguration(props) {
|
|
8976
|
+
const cols = props.pcbGridCols ?? props.gridCols ?? props.pcbLayout?.grid?.cols;
|
|
8977
|
+
const rows = props.pcbGridRows ?? props.pcbLayout?.grid?.rows;
|
|
8978
|
+
const templateColumns = props.pcbGridTemplateColumns;
|
|
8979
|
+
const templateRows = props.pcbGridTemplateRows;
|
|
8980
|
+
const parseGap = (gapValue) => {
|
|
8981
|
+
if (gapValue === void 0) return MIN_GAP;
|
|
8982
|
+
return typeof gapValue === "number" ? gapValue : length3.parse(gapValue);
|
|
8983
|
+
};
|
|
8984
|
+
const gridGapOption = props.pcbGridGap ?? props.gridGap ?? props.pcbLayout?.gridGap;
|
|
8985
|
+
const rowGapOption = props.pcbGridRowGap ?? props.gridRowGap ?? props.pcbLayout?.gridRowGap;
|
|
8986
|
+
const colGapOption = props.pcbGridColumnGap ?? props.gridColumnGap ?? props.pcbLayout?.gridColumnGap;
|
|
8987
|
+
let gapX = MIN_GAP;
|
|
8988
|
+
let gapY = MIN_GAP;
|
|
8989
|
+
if (rowGapOption !== void 0 || colGapOption !== void 0) {
|
|
8990
|
+
const fallbackX = typeof gridGapOption === "object" ? gridGapOption?.x : gridGapOption;
|
|
8991
|
+
const fallbackY = typeof gridGapOption === "object" ? gridGapOption?.y : gridGapOption;
|
|
8992
|
+
gapX = parseGap(colGapOption ?? fallbackX);
|
|
8993
|
+
gapY = parseGap(rowGapOption ?? fallbackY);
|
|
8952
8994
|
} else if (typeof gridGapOption === "object" && gridGapOption !== null) {
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
gridGapX = typeof xRaw === "number" ? xRaw : length3.parse(xRaw ?? "0mm");
|
|
8956
|
-
gridGapY = typeof yRaw === "number" ? yRaw : length3.parse(yRaw ?? "0mm");
|
|
8995
|
+
gapX = parseGap(gridGapOption.x);
|
|
8996
|
+
gapY = parseGap(gridGapOption.y);
|
|
8957
8997
|
} else {
|
|
8958
|
-
|
|
8959
|
-
|
|
8998
|
+
const gap = parseGap(gridGapOption);
|
|
8999
|
+
gapX = gap;
|
|
9000
|
+
gapY = gap;
|
|
8960
9001
|
}
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
9002
|
+
return { cols, rows, gapX, gapY, templateColumns, templateRows };
|
|
9003
|
+
}
|
|
9004
|
+
function createGridLayout(params) {
|
|
9005
|
+
const { props, pcbChildren, childDimensions, gridConfig } = params;
|
|
9006
|
+
if (props.pcbGridTemplateColumns || props.pcbGridTemplateRows) {
|
|
9007
|
+
return createTemplateBasedLayout({
|
|
9008
|
+
props,
|
|
9009
|
+
gridConfig,
|
|
9010
|
+
pcbChildren,
|
|
9011
|
+
childDimensions
|
|
9012
|
+
});
|
|
9013
|
+
}
|
|
9014
|
+
return createDefaultLayout({ gridConfig, pcbChildren, childDimensions });
|
|
9015
|
+
}
|
|
9016
|
+
function createTemplateBasedLayout(params) {
|
|
9017
|
+
const { props, gridConfig, pcbChildren, childDimensions } = params;
|
|
9018
|
+
const gridTemplateColumns = props.pcbGridTemplateColumns ?? "";
|
|
9019
|
+
const gridTemplateRows = props.pcbGridTemplateRows ?? "";
|
|
9020
|
+
const extractRepeatCount = (template) => {
|
|
9021
|
+
const match = template.match(/repeat\((\d+),/);
|
|
9022
|
+
return match ? parseInt(match[1]) : Math.ceil(Math.sqrt(pcbChildren.length));
|
|
9023
|
+
};
|
|
9024
|
+
const numCols = props.pcbGridTemplateColumns ? extractRepeatCount(gridTemplateColumns) : Math.ceil(Math.sqrt(pcbChildren.length));
|
|
9025
|
+
const numRows = props.pcbGridTemplateRows ? extractRepeatCount(gridTemplateRows) : Math.ceil(pcbChildren.length / numCols);
|
|
9026
|
+
const containerWidth = numCols * childDimensions.width + Math.max(0, numCols - 1) * gridConfig.gapX;
|
|
9027
|
+
const containerHeight = numRows * childDimensions.height + Math.max(0, numRows - 1) * gridConfig.gapY;
|
|
9028
|
+
return {
|
|
9029
|
+
gridTemplateColumns,
|
|
9030
|
+
gridTemplateRows,
|
|
9031
|
+
containerWidth,
|
|
9032
|
+
containerHeight
|
|
9033
|
+
};
|
|
9034
|
+
}
|
|
9035
|
+
function createDefaultLayout(params) {
|
|
9036
|
+
const { gridConfig, pcbChildren, childDimensions } = params;
|
|
9037
|
+
let numCols;
|
|
9038
|
+
let numRows;
|
|
9039
|
+
if (gridConfig.cols !== void 0 && gridConfig.rows !== void 0) {
|
|
9040
|
+
numCols = gridConfig.cols;
|
|
9041
|
+
numRows = gridConfig.rows;
|
|
9042
|
+
} else if (gridConfig.cols !== void 0) {
|
|
9043
|
+
numCols = gridConfig.cols;
|
|
8968
9044
|
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8969
|
-
} else if (
|
|
8970
|
-
numRows =
|
|
9045
|
+
} else if (gridConfig.rows !== void 0) {
|
|
9046
|
+
numRows = gridConfig.rows;
|
|
8971
9047
|
numCols = Math.ceil(pcbChildren.length / numRows);
|
|
8972
9048
|
} else {
|
|
8973
9049
|
numCols = Math.ceil(Math.sqrt(pcbChildren.length));
|
|
8974
9050
|
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8975
9051
|
}
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
const
|
|
8979
|
-
const
|
|
8980
|
-
const gridTemplateColumns =
|
|
8981
|
-
const gridTemplateRows =
|
|
9052
|
+
numCols = Math.max(1, numCols);
|
|
9053
|
+
numRows = Math.max(1, numRows);
|
|
9054
|
+
const containerWidth = numCols * childDimensions.width + Math.max(0, numCols - 1) * gridConfig.gapX;
|
|
9055
|
+
const containerHeight = numRows * childDimensions.height + Math.max(0, numRows - 1) * gridConfig.gapY;
|
|
9056
|
+
const gridTemplateColumns = `repeat(${numCols}, ${childDimensions.width}px)`;
|
|
9057
|
+
const gridTemplateRows = `repeat(${numRows}, ${childDimensions.height}px)`;
|
|
9058
|
+
return {
|
|
9059
|
+
gridTemplateColumns,
|
|
9060
|
+
gridTemplateRows,
|
|
9061
|
+
containerWidth,
|
|
9062
|
+
containerHeight
|
|
9063
|
+
};
|
|
9064
|
+
}
|
|
9065
|
+
function createCssGrid(params) {
|
|
9066
|
+
const { pcbChildren, childDimensions, gridLayout, gridConfig } = params;
|
|
8982
9067
|
const gridChildren = pcbChildren.map((child, index) => ({
|
|
8983
9068
|
key: child.getString() || `child-${index}`,
|
|
8984
|
-
contentWidth:
|
|
8985
|
-
contentHeight:
|
|
9069
|
+
contentWidth: childDimensions.width,
|
|
9070
|
+
contentHeight: childDimensions.height
|
|
8986
9071
|
}));
|
|
8987
|
-
|
|
8988
|
-
containerWidth:
|
|
8989
|
-
containerHeight:
|
|
8990
|
-
gridTemplateColumns,
|
|
8991
|
-
gridTemplateRows,
|
|
8992
|
-
gap: [
|
|
9072
|
+
return new CssGrid({
|
|
9073
|
+
containerWidth: gridLayout.containerWidth,
|
|
9074
|
+
containerHeight: gridLayout.containerHeight,
|
|
9075
|
+
gridTemplateColumns: gridLayout.gridTemplateColumns,
|
|
9076
|
+
gridTemplateRows: gridLayout.gridTemplateRows,
|
|
9077
|
+
gap: [gridConfig.gapY, gridConfig.gapX],
|
|
8993
9078
|
// [rowGap, columnGap]
|
|
8994
9079
|
children: gridChildren
|
|
8995
9080
|
});
|
|
8996
|
-
|
|
9081
|
+
}
|
|
9082
|
+
function positionChildren(params) {
|
|
9083
|
+
const { db, group, pcbChildren, itemCoordinates, gridLayout } = params;
|
|
8997
9084
|
const groupCenter = group._getGlobalPcbPositionBeforeLayout();
|
|
9085
|
+
const allCircuitJson = db.toArray();
|
|
8998
9086
|
for (let i = 0; i < pcbChildren.length; i++) {
|
|
8999
9087
|
const child = pcbChildren[i];
|
|
9000
|
-
if (!child.pcb_component_id) continue;
|
|
9001
9088
|
const childKey = child.getString() || `child-${i}`;
|
|
9002
9089
|
const coordinates = itemCoordinates[childKey];
|
|
9003
9090
|
if (!coordinates) {
|
|
@@ -9006,35 +9093,31 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
9006
9093
|
);
|
|
9007
9094
|
continue;
|
|
9008
9095
|
}
|
|
9009
|
-
const
|
|
9010
|
-
const
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
const deltaX = newCenter.x - oldCenter.x;
|
|
9016
|
-
const deltaY = newCenter.y - oldCenter.y;
|
|
9017
|
-
const mat = translate5(deltaX, deltaY);
|
|
9018
|
-
const related = db.toArray().filter((e) => e.pcb_component_id === child.pcb_component_id);
|
|
9019
|
-
const moved = transformPCBElements(related, mat);
|
|
9020
|
-
for (const elm of moved) {
|
|
9021
|
-
const idProp = getPrimaryId(elm);
|
|
9022
|
-
db[elm.type].update(elm[idProp], elm);
|
|
9023
|
-
}
|
|
9024
|
-
db.pcb_component.update(child.pcb_component_id, {
|
|
9025
|
-
center: newCenter
|
|
9026
|
-
});
|
|
9027
|
-
child.setProps({
|
|
9028
|
-
...child.props,
|
|
9029
|
-
pcbX: (child.props.pcbX ?? 0) + deltaX,
|
|
9030
|
-
pcbY: (child.props.pcbY ?? 0) + deltaY
|
|
9096
|
+
const targetX = groupCenter.x - gridLayout.containerWidth / 2 + coordinates.x + coordinates.width / 2;
|
|
9097
|
+
const targetY = groupCenter.y + gridLayout.containerHeight / 2 - coordinates.y - coordinates.height / 2;
|
|
9098
|
+
if (child.pcb_component_id) {
|
|
9099
|
+
repositionPcbComponentTo(allCircuitJson, child.pcb_component_id, {
|
|
9100
|
+
x: targetX,
|
|
9101
|
+
y: targetY
|
|
9031
9102
|
});
|
|
9103
|
+
} else {
|
|
9104
|
+
const groupChild = child;
|
|
9105
|
+
if (groupChild.pcb_group_id && groupChild.source_group_id) {
|
|
9106
|
+
repositionPcbGroupTo(allCircuitJson, groupChild.source_group_id, {
|
|
9107
|
+
x: targetX,
|
|
9108
|
+
y: targetY
|
|
9109
|
+
});
|
|
9110
|
+
}
|
|
9032
9111
|
}
|
|
9033
9112
|
}
|
|
9113
|
+
}
|
|
9114
|
+
function updateGroupDimensions(params) {
|
|
9115
|
+
const { db, group, props, gridLayout } = params;
|
|
9034
9116
|
if (group.pcb_group_id) {
|
|
9117
|
+
const groupCenter = group._getGlobalPcbPositionBeforeLayout();
|
|
9035
9118
|
db.pcb_group.update(group.pcb_group_id, {
|
|
9036
|
-
width: props.width ??
|
|
9037
|
-
height: props.height ??
|
|
9119
|
+
width: props.width ?? gridLayout.containerWidth,
|
|
9120
|
+
height: props.height ?? gridLayout.containerHeight,
|
|
9038
9121
|
center: groupCenter
|
|
9039
9122
|
});
|
|
9040
9123
|
}
|
|
@@ -9104,9 +9187,9 @@ import {
|
|
|
9104
9187
|
} from "calculate-packing";
|
|
9105
9188
|
import { length as length4 } from "circuit-json";
|
|
9106
9189
|
import {
|
|
9107
|
-
transformPCBElements
|
|
9190
|
+
transformPCBElements
|
|
9108
9191
|
} from "@tscircuit/circuit-json-util";
|
|
9109
|
-
import { translate as
|
|
9192
|
+
import { translate as translate5, rotate as rotate2, compose as compose4 } from "transformation-matrix";
|
|
9110
9193
|
import Debug7 from "debug";
|
|
9111
9194
|
var debug6 = Debug7("Group_doInitialPcbLayoutPack");
|
|
9112
9195
|
var isDescendantGroup = (db, groupId, ancestorId) => {
|
|
@@ -9161,14 +9244,14 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9161
9244
|
const rotationDegrees2 = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
|
|
9162
9245
|
const transformMatrix2 = compose4(
|
|
9163
9246
|
group._computePcbGlobalTransformBeforeLayout(),
|
|
9164
|
-
|
|
9247
|
+
translate5(center.x, center.y),
|
|
9165
9248
|
rotate2(rotationDegrees2 * Math.PI / 180),
|
|
9166
|
-
|
|
9249
|
+
translate5(-originalCenter2.x, -originalCenter2.y)
|
|
9167
9250
|
);
|
|
9168
9251
|
const related = db.toArray().filter(
|
|
9169
9252
|
(elm) => "pcb_component_id" in elm && elm.pcb_component_id === componentId
|
|
9170
9253
|
);
|
|
9171
|
-
|
|
9254
|
+
transformPCBElements(related, transformMatrix2);
|
|
9172
9255
|
continue;
|
|
9173
9256
|
}
|
|
9174
9257
|
const pcbGroup = db.pcb_group.list().find((g) => g.source_group_id === componentId);
|
|
@@ -9177,9 +9260,9 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9177
9260
|
const rotationDegrees = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
|
|
9178
9261
|
const transformMatrix = compose4(
|
|
9179
9262
|
group._computePcbGlobalTransformBeforeLayout(),
|
|
9180
|
-
|
|
9263
|
+
translate5(center.x, center.y),
|
|
9181
9264
|
rotate2(rotationDegrees * Math.PI / 180),
|
|
9182
|
-
|
|
9265
|
+
translate5(-originalCenter.x, -originalCenter.y)
|
|
9183
9266
|
);
|
|
9184
9267
|
const relatedElements = db.toArray().filter((elm) => {
|
|
9185
9268
|
if ("source_group_id" in elm && elm.source_group_id) {
|
|
@@ -9223,7 +9306,7 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9223
9306
|
}
|
|
9224
9307
|
return false;
|
|
9225
9308
|
});
|
|
9226
|
-
|
|
9309
|
+
transformPCBElements(relatedElements, transformMatrix);
|
|
9227
9310
|
db.pcb_group.update(pcbGroup.pcb_group_id, { center });
|
|
9228
9311
|
}
|
|
9229
9312
|
};
|
|
@@ -9231,8 +9314,8 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9231
9314
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutFlex.ts
|
|
9232
9315
|
import {
|
|
9233
9316
|
getCircuitJsonTree as getCircuitJsonTree3,
|
|
9234
|
-
repositionPcbComponentTo,
|
|
9235
|
-
repositionPcbGroupTo,
|
|
9317
|
+
repositionPcbComponentTo as repositionPcbComponentTo2,
|
|
9318
|
+
repositionPcbGroupTo as repositionPcbGroupTo2,
|
|
9236
9319
|
getMinimumFlexContainer as getMinimumFlexContainer2
|
|
9237
9320
|
} from "@tscircuit/circuit-json-util";
|
|
9238
9321
|
import { RootFlexBox as RootFlexBox2 } from "@tscircuit/miniflex";
|
|
@@ -9374,7 +9457,7 @@ var Group_doInitialPcbLayoutFlex = (group) => {
|
|
|
9374
9457
|
source_component_id: sourceComponent.source_component_id
|
|
9375
9458
|
});
|
|
9376
9459
|
if (!pcbComponent) continue;
|
|
9377
|
-
|
|
9460
|
+
repositionPcbComponentTo2(allCircuitJson, pcbComponent.pcb_component_id, {
|
|
9378
9461
|
x: child.position.x + child.size.width / 2 + offset.x,
|
|
9379
9462
|
y: child.position.y + child.size.height / 2 + offset.y
|
|
9380
9463
|
});
|
|
@@ -9384,7 +9467,7 @@ var Group_doInitialPcbLayoutFlex = (group) => {
|
|
|
9384
9467
|
source_group_id: sourceGroup.source_group_id
|
|
9385
9468
|
});
|
|
9386
9469
|
if (!pcbGroup) continue;
|
|
9387
|
-
|
|
9470
|
+
repositionPcbGroupTo2(allCircuitJson, sourceGroup.source_group_id, {
|
|
9388
9471
|
x: child.position.x + child.size.width / 2 + offset.x,
|
|
9389
9472
|
y: child.position.y + child.size.height / 2 + offset.y
|
|
9390
9473
|
});
|
|
@@ -11402,7 +11485,7 @@ import { netLabelProps } from "@tscircuit/props";
|
|
|
11402
11485
|
import {
|
|
11403
11486
|
applyToPoint as applyToPoint8,
|
|
11404
11487
|
identity as identity4,
|
|
11405
|
-
translate as
|
|
11488
|
+
translate as translate6
|
|
11406
11489
|
} from "transformation-matrix";
|
|
11407
11490
|
var NetLabel = class extends PrimitiveComponent2 {
|
|
11408
11491
|
source_net_label_id;
|
|
@@ -11454,7 +11537,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
11454
11537
|
this.parent?.computeSchematicGlobalTransform?.() ?? identity4(),
|
|
11455
11538
|
{ x: 0, y: 0 }
|
|
11456
11539
|
);
|
|
11457
|
-
return
|
|
11540
|
+
return translate6(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
|
|
11458
11541
|
}
|
|
11459
11542
|
}
|
|
11460
11543
|
return super.computeSchematicPropsTransform();
|
|
@@ -12684,7 +12767,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
12684
12767
|
var package_default = {
|
|
12685
12768
|
name: "@tscircuit/core",
|
|
12686
12769
|
type: "module",
|
|
12687
|
-
version: "0.0.
|
|
12770
|
+
version: "0.0.637",
|
|
12688
12771
|
types: "dist/index.d.ts",
|
|
12689
12772
|
main: "dist/index.js",
|
|
12690
12773
|
module: "dist/index.js",
|
|
@@ -12742,7 +12825,7 @@ var package_default = {
|
|
|
12742
12825
|
howfat: "^0.3.8",
|
|
12743
12826
|
"live-server": "^1.2.2",
|
|
12744
12827
|
"looks-same": "^9.0.1",
|
|
12745
|
-
minicssgrid: "^0.0.
|
|
12828
|
+
minicssgrid: "^0.0.8",
|
|
12746
12829
|
"pkg-pr-new": "^0.0.37",
|
|
12747
12830
|
react: "^19.1.0",
|
|
12748
12831
|
"react-dom": "^19.1.0",
|
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.638",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"howfat": "^0.3.8",
|
|
60
60
|
"live-server": "^1.2.2",
|
|
61
61
|
"looks-same": "^9.0.1",
|
|
62
|
-
"minicssgrid": "^0.0.
|
|
62
|
+
"minicssgrid": "^0.0.8",
|
|
63
63
|
"pkg-pr-new": "^0.0.37",
|
|
64
64
|
"react": "^19.1.0",
|
|
65
65
|
"react-dom": "^19.1.0",
|