@tscircuit/core 0.0.635 → 0.0.637
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 +242 -126
- 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
|
@@ -8889,115 +8889,178 @@ var Group_doInitialSchematicLayoutFlex = (group) => {
|
|
|
8889
8889
|
};
|
|
8890
8890
|
|
|
8891
8891
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutGrid.ts
|
|
8892
|
-
import { translate as translate5 } from "transformation-matrix";
|
|
8893
8892
|
import {
|
|
8894
|
-
|
|
8895
|
-
|
|
8893
|
+
repositionPcbComponentTo,
|
|
8894
|
+
repositionPcbGroupTo
|
|
8896
8895
|
} from "@tscircuit/circuit-json-util";
|
|
8897
8896
|
import { length as length3 } from "circuit-json";
|
|
8898
8897
|
import { CssGrid } from "minicssgrid";
|
|
8898
|
+
var MIN_GAP = 1;
|
|
8899
8899
|
function Group_doInitialPcbLayoutGrid(group) {
|
|
8900
8900
|
const { db } = group.root;
|
|
8901
8901
|
const props = group._parsedProps;
|
|
8902
|
-
const pcbChildren = group
|
|
8903
|
-
(child) => child.pcb_component_id
|
|
8904
|
-
);
|
|
8902
|
+
const pcbChildren = getPcbChildren(group);
|
|
8905
8903
|
if (pcbChildren.length === 0) return;
|
|
8906
|
-
|
|
8907
|
-
|
|
8904
|
+
const childDimensions = calculateChildDimensions({ db, pcbChildren });
|
|
8905
|
+
const gridConfig = parseGridConfiguration(props);
|
|
8906
|
+
const gridLayout = createGridLayout({
|
|
8907
|
+
props,
|
|
8908
|
+
pcbChildren,
|
|
8909
|
+
childDimensions,
|
|
8910
|
+
gridConfig
|
|
8911
|
+
});
|
|
8912
|
+
const cssGrid = createCssGrid({
|
|
8913
|
+
pcbChildren,
|
|
8914
|
+
childDimensions,
|
|
8915
|
+
gridLayout,
|
|
8916
|
+
gridConfig
|
|
8917
|
+
});
|
|
8918
|
+
const { itemCoordinates } = cssGrid.layout();
|
|
8919
|
+
positionChildren({ db, group, pcbChildren, itemCoordinates, gridLayout });
|
|
8920
|
+
updateGroupDimensions({ db, group, props, gridLayout });
|
|
8921
|
+
}
|
|
8922
|
+
function getPcbChildren(group) {
|
|
8923
|
+
return group.children.filter(
|
|
8924
|
+
(child) => child.pcb_component_id || child.pcb_group_id
|
|
8925
|
+
);
|
|
8926
|
+
}
|
|
8927
|
+
function calculateChildDimensions(params) {
|
|
8928
|
+
const { db, pcbChildren } = params;
|
|
8929
|
+
let maxWidth = 0;
|
|
8930
|
+
let maxHeight = 0;
|
|
8908
8931
|
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;
|
|
8932
|
+
let width = 0;
|
|
8933
|
+
let height = 0;
|
|
8934
|
+
if (child.pcb_group_id) {
|
|
8935
|
+
const pcbGroup = db.pcb_group.get(child.pcb_group_id);
|
|
8936
|
+
width = pcbGroup?.width ?? 0;
|
|
8937
|
+
height = pcbGroup?.height ?? 0;
|
|
8938
|
+
} else if (child.pcb_component_id) {
|
|
8939
|
+
const pcbComp = db.pcb_component.get(child.pcb_component_id);
|
|
8940
|
+
width = pcbComp?.width ?? 0;
|
|
8941
|
+
height = pcbComp?.height ?? 0;
|
|
8942
|
+
}
|
|
8943
|
+
maxWidth = Math.max(maxWidth, width);
|
|
8944
|
+
maxHeight = Math.max(maxHeight, height);
|
|
8933
8945
|
}
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8946
|
+
return {
|
|
8947
|
+
width: maxWidth,
|
|
8948
|
+
height: maxHeight
|
|
8937
8949
|
};
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8950
|
+
}
|
|
8951
|
+
function parseGridConfiguration(props) {
|
|
8952
|
+
const cols = props.pcbGridCols ?? props.gridCols ?? props.pcbLayout?.grid?.cols;
|
|
8953
|
+
const rows = props.pcbGridRows ?? props.pcbLayout?.grid?.rows;
|
|
8954
|
+
const templateColumns = props.pcbGridTemplateColumns;
|
|
8955
|
+
const templateRows = props.pcbGridTemplateRows;
|
|
8956
|
+
const parseGap = (gapValue) => {
|
|
8957
|
+
if (gapValue === void 0) return MIN_GAP;
|
|
8958
|
+
return typeof gapValue === "number" ? gapValue : length3.parse(gapValue);
|
|
8959
|
+
};
|
|
8960
|
+
const gridGapOption = props.pcbGridGap ?? props.gridGap ?? props.pcbLayout?.gridGap;
|
|
8961
|
+
const rowGapOption = props.pcbGridRowGap ?? props.gridRowGap ?? props.pcbLayout?.gridRowGap;
|
|
8962
|
+
const colGapOption = props.pcbGridColumnGap ?? props.gridColumnGap ?? props.pcbLayout?.gridColumnGap;
|
|
8963
|
+
let gapX = MIN_GAP;
|
|
8964
|
+
let gapY = MIN_GAP;
|
|
8965
|
+
if (rowGapOption !== void 0 || colGapOption !== void 0) {
|
|
8966
|
+
const fallbackX = typeof gridGapOption === "object" ? gridGapOption?.x : gridGapOption;
|
|
8967
|
+
const fallbackY = typeof gridGapOption === "object" ? gridGapOption?.y : gridGapOption;
|
|
8968
|
+
gapX = parseGap(colGapOption ?? fallbackX);
|
|
8969
|
+
gapY = parseGap(rowGapOption ?? fallbackY);
|
|
8952
8970
|
} 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");
|
|
8971
|
+
gapX = parseGap(gridGapOption.x);
|
|
8972
|
+
gapY = parseGap(gridGapOption.y);
|
|
8957
8973
|
} else {
|
|
8958
|
-
|
|
8959
|
-
|
|
8974
|
+
const gap = parseGap(gridGapOption);
|
|
8975
|
+
gapX = gap;
|
|
8976
|
+
gapY = gap;
|
|
8960
8977
|
}
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8978
|
+
return { cols, rows, gapX, gapY, templateColumns, templateRows };
|
|
8979
|
+
}
|
|
8980
|
+
function createGridLayout(params) {
|
|
8981
|
+
const { props, pcbChildren, childDimensions, gridConfig } = params;
|
|
8982
|
+
if (props.pcbGridTemplateColumns || props.pcbGridTemplateRows) {
|
|
8983
|
+
return createTemplateBasedLayout({
|
|
8984
|
+
props,
|
|
8985
|
+
gridConfig,
|
|
8986
|
+
pcbChildren,
|
|
8987
|
+
childDimensions
|
|
8988
|
+
});
|
|
8989
|
+
}
|
|
8990
|
+
return createDefaultLayout({ gridConfig, pcbChildren, childDimensions });
|
|
8991
|
+
}
|
|
8992
|
+
function createTemplateBasedLayout(params) {
|
|
8993
|
+
const { props, gridConfig, pcbChildren, childDimensions } = params;
|
|
8994
|
+
const gridTemplateColumns = props.pcbGridTemplateColumns ?? "";
|
|
8995
|
+
const gridTemplateRows = props.pcbGridTemplateRows ?? "";
|
|
8996
|
+
const extractRepeatCount = (template) => {
|
|
8997
|
+
const match = template.match(/repeat\((\d+),/);
|
|
8998
|
+
return match ? parseInt(match[1]) : Math.ceil(Math.sqrt(pcbChildren.length));
|
|
8999
|
+
};
|
|
9000
|
+
const numCols = props.pcbGridTemplateColumns ? extractRepeatCount(gridTemplateColumns) : Math.ceil(Math.sqrt(pcbChildren.length));
|
|
9001
|
+
const numRows = props.pcbGridTemplateRows ? extractRepeatCount(gridTemplateRows) : Math.ceil(pcbChildren.length / numCols);
|
|
9002
|
+
const containerWidth = numCols * childDimensions.width + Math.max(0, numCols - 1) * gridConfig.gapX;
|
|
9003
|
+
const containerHeight = numRows * childDimensions.height + Math.max(0, numRows - 1) * gridConfig.gapY;
|
|
9004
|
+
return {
|
|
9005
|
+
gridTemplateColumns,
|
|
9006
|
+
gridTemplateRows,
|
|
9007
|
+
containerWidth,
|
|
9008
|
+
containerHeight
|
|
9009
|
+
};
|
|
9010
|
+
}
|
|
9011
|
+
function createDefaultLayout(params) {
|
|
9012
|
+
const { gridConfig, pcbChildren, childDimensions } = params;
|
|
9013
|
+
let numCols;
|
|
9014
|
+
let numRows;
|
|
9015
|
+
if (gridConfig.cols !== void 0 && gridConfig.rows !== void 0) {
|
|
9016
|
+
numCols = gridConfig.cols;
|
|
9017
|
+
numRows = gridConfig.rows;
|
|
9018
|
+
} else if (gridConfig.cols !== void 0) {
|
|
9019
|
+
numCols = gridConfig.cols;
|
|
8968
9020
|
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8969
|
-
} else if (
|
|
8970
|
-
numRows =
|
|
9021
|
+
} else if (gridConfig.rows !== void 0) {
|
|
9022
|
+
numRows = gridConfig.rows;
|
|
8971
9023
|
numCols = Math.ceil(pcbChildren.length / numRows);
|
|
8972
9024
|
} else {
|
|
8973
9025
|
numCols = Math.ceil(Math.sqrt(pcbChildren.length));
|
|
8974
9026
|
numRows = Math.ceil(pcbChildren.length / numCols);
|
|
8975
9027
|
}
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
const
|
|
8979
|
-
const
|
|
8980
|
-
const gridTemplateColumns =
|
|
8981
|
-
const gridTemplateRows =
|
|
9028
|
+
numCols = Math.max(1, numCols);
|
|
9029
|
+
numRows = Math.max(1, numRows);
|
|
9030
|
+
const containerWidth = numCols * childDimensions.width + Math.max(0, numCols - 1) * gridConfig.gapX;
|
|
9031
|
+
const containerHeight = numRows * childDimensions.height + Math.max(0, numRows - 1) * gridConfig.gapY;
|
|
9032
|
+
const gridTemplateColumns = `repeat(${numCols}, ${childDimensions.width}px)`;
|
|
9033
|
+
const gridTemplateRows = `repeat(${numRows}, ${childDimensions.height}px)`;
|
|
9034
|
+
return {
|
|
9035
|
+
gridTemplateColumns,
|
|
9036
|
+
gridTemplateRows,
|
|
9037
|
+
containerWidth,
|
|
9038
|
+
containerHeight
|
|
9039
|
+
};
|
|
9040
|
+
}
|
|
9041
|
+
function createCssGrid(params) {
|
|
9042
|
+
const { pcbChildren, childDimensions, gridLayout, gridConfig } = params;
|
|
8982
9043
|
const gridChildren = pcbChildren.map((child, index) => ({
|
|
8983
9044
|
key: child.getString() || `child-${index}`,
|
|
8984
|
-
contentWidth:
|
|
8985
|
-
contentHeight:
|
|
9045
|
+
contentWidth: childDimensions.width,
|
|
9046
|
+
contentHeight: childDimensions.height
|
|
8986
9047
|
}));
|
|
8987
|
-
|
|
8988
|
-
containerWidth:
|
|
8989
|
-
containerHeight:
|
|
8990
|
-
gridTemplateColumns,
|
|
8991
|
-
gridTemplateRows,
|
|
8992
|
-
gap: [
|
|
9048
|
+
return new CssGrid({
|
|
9049
|
+
containerWidth: gridLayout.containerWidth,
|
|
9050
|
+
containerHeight: gridLayout.containerHeight,
|
|
9051
|
+
gridTemplateColumns: gridLayout.gridTemplateColumns,
|
|
9052
|
+
gridTemplateRows: gridLayout.gridTemplateRows,
|
|
9053
|
+
gap: [gridConfig.gapY, gridConfig.gapX],
|
|
8993
9054
|
// [rowGap, columnGap]
|
|
8994
9055
|
children: gridChildren
|
|
8995
9056
|
});
|
|
8996
|
-
|
|
9057
|
+
}
|
|
9058
|
+
function positionChildren(params) {
|
|
9059
|
+
const { db, group, pcbChildren, itemCoordinates, gridLayout } = params;
|
|
8997
9060
|
const groupCenter = group._getGlobalPcbPositionBeforeLayout();
|
|
9061
|
+
const allCircuitJson = db.toArray();
|
|
8998
9062
|
for (let i = 0; i < pcbChildren.length; i++) {
|
|
8999
9063
|
const child = pcbChildren[i];
|
|
9000
|
-
if (!child.pcb_component_id) continue;
|
|
9001
9064
|
const childKey = child.getString() || `child-${i}`;
|
|
9002
9065
|
const coordinates = itemCoordinates[childKey];
|
|
9003
9066
|
if (!coordinates) {
|
|
@@ -9006,35 +9069,31 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
9006
9069
|
);
|
|
9007
9070
|
continue;
|
|
9008
9071
|
}
|
|
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
|
|
9072
|
+
const targetX = groupCenter.x - gridLayout.containerWidth / 2 + coordinates.x + coordinates.width / 2;
|
|
9073
|
+
const targetY = groupCenter.y + gridLayout.containerHeight / 2 - coordinates.y - coordinates.height / 2;
|
|
9074
|
+
if (child.pcb_component_id) {
|
|
9075
|
+
repositionPcbComponentTo(allCircuitJson, child.pcb_component_id, {
|
|
9076
|
+
x: targetX,
|
|
9077
|
+
y: targetY
|
|
9031
9078
|
});
|
|
9079
|
+
} else {
|
|
9080
|
+
const groupChild = child;
|
|
9081
|
+
if (groupChild.pcb_group_id && groupChild.source_group_id) {
|
|
9082
|
+
repositionPcbGroupTo(allCircuitJson, groupChild.source_group_id, {
|
|
9083
|
+
x: targetX,
|
|
9084
|
+
y: targetY
|
|
9085
|
+
});
|
|
9086
|
+
}
|
|
9032
9087
|
}
|
|
9033
9088
|
}
|
|
9089
|
+
}
|
|
9090
|
+
function updateGroupDimensions(params) {
|
|
9091
|
+
const { db, group, props, gridLayout } = params;
|
|
9034
9092
|
if (group.pcb_group_id) {
|
|
9093
|
+
const groupCenter = group._getGlobalPcbPositionBeforeLayout();
|
|
9035
9094
|
db.pcb_group.update(group.pcb_group_id, {
|
|
9036
|
-
width: props.width ??
|
|
9037
|
-
height: props.height ??
|
|
9095
|
+
width: props.width ?? gridLayout.containerWidth,
|
|
9096
|
+
height: props.height ?? gridLayout.containerHeight,
|
|
9038
9097
|
center: groupCenter
|
|
9039
9098
|
});
|
|
9040
9099
|
}
|
|
@@ -9095,7 +9154,7 @@ function getPresetAutoroutingConfig(autorouterConfig) {
|
|
|
9095
9154
|
}
|
|
9096
9155
|
|
|
9097
9156
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack.ts
|
|
9098
|
-
import
|
|
9157
|
+
import "@tscircuit/circuit-json-util";
|
|
9099
9158
|
import {
|
|
9100
9159
|
pack,
|
|
9101
9160
|
convertCircuitJsonToPackOutput,
|
|
@@ -9104,11 +9163,17 @@ import {
|
|
|
9104
9163
|
} from "calculate-packing";
|
|
9105
9164
|
import { length as length4 } from "circuit-json";
|
|
9106
9165
|
import {
|
|
9107
|
-
transformPCBElements
|
|
9166
|
+
transformPCBElements
|
|
9108
9167
|
} from "@tscircuit/circuit-json-util";
|
|
9109
|
-
import { translate as
|
|
9168
|
+
import { translate as translate5, rotate as rotate2, compose as compose4 } from "transformation-matrix";
|
|
9110
9169
|
import Debug7 from "debug";
|
|
9111
9170
|
var debug6 = Debug7("Group_doInitialPcbLayoutPack");
|
|
9171
|
+
var isDescendantGroup = (db, groupId, ancestorId) => {
|
|
9172
|
+
if (groupId === ancestorId) return true;
|
|
9173
|
+
const group = db.source_group.get(groupId);
|
|
9174
|
+
if (!group || !group.parent_source_group_id) return false;
|
|
9175
|
+
return isDescendantGroup(db, group.parent_source_group_id, ancestorId);
|
|
9176
|
+
};
|
|
9112
9177
|
var Group_doInitialPcbLayoutPack = (group) => {
|
|
9113
9178
|
const { db } = group.root;
|
|
9114
9179
|
const { _parsedProps: props } = group;
|
|
@@ -9143,18 +9208,26 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9143
9208
|
const { center, componentId, ccwRotationOffset, ccwRotationDegrees } = packedComponent;
|
|
9144
9209
|
const pcbComponent = db.pcb_component.get(componentId);
|
|
9145
9210
|
if (pcbComponent) {
|
|
9211
|
+
const currentGroupId = group.source_group_id;
|
|
9212
|
+
const sourceComponent = db.source_component.get(
|
|
9213
|
+
pcbComponent.source_component_id
|
|
9214
|
+
);
|
|
9215
|
+
const componentGroupId = sourceComponent?.source_group_id;
|
|
9216
|
+
if (componentGroupId !== void 0 && !isDescendantGroup(db, componentGroupId, currentGroupId)) {
|
|
9217
|
+
continue;
|
|
9218
|
+
}
|
|
9146
9219
|
const originalCenter2 = pcbComponent.center;
|
|
9147
9220
|
const rotationDegrees2 = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
|
|
9148
9221
|
const transformMatrix2 = compose4(
|
|
9149
9222
|
group._computePcbGlobalTransformBeforeLayout(),
|
|
9150
|
-
|
|
9223
|
+
translate5(center.x, center.y),
|
|
9151
9224
|
rotate2(rotationDegrees2 * Math.PI / 180),
|
|
9152
|
-
|
|
9225
|
+
translate5(-originalCenter2.x, -originalCenter2.y)
|
|
9153
9226
|
);
|
|
9154
9227
|
const related = db.toArray().filter(
|
|
9155
9228
|
(elm) => "pcb_component_id" in elm && elm.pcb_component_id === componentId
|
|
9156
9229
|
);
|
|
9157
|
-
|
|
9230
|
+
transformPCBElements(related, transformMatrix2);
|
|
9158
9231
|
continue;
|
|
9159
9232
|
}
|
|
9160
9233
|
const pcbGroup = db.pcb_group.list().find((g) => g.source_group_id === componentId);
|
|
@@ -9163,12 +9236,53 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9163
9236
|
const rotationDegrees = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
|
|
9164
9237
|
const transformMatrix = compose4(
|
|
9165
9238
|
group._computePcbGlobalTransformBeforeLayout(),
|
|
9166
|
-
|
|
9239
|
+
translate5(center.x, center.y),
|
|
9167
9240
|
rotate2(rotationDegrees * Math.PI / 180),
|
|
9168
|
-
|
|
9241
|
+
translate5(-originalCenter.x, -originalCenter.y)
|
|
9169
9242
|
);
|
|
9170
|
-
const
|
|
9171
|
-
|
|
9243
|
+
const relatedElements = db.toArray().filter((elm) => {
|
|
9244
|
+
if ("source_group_id" in elm && elm.source_group_id) {
|
|
9245
|
+
if (elm.source_group_id === componentId) {
|
|
9246
|
+
return true;
|
|
9247
|
+
}
|
|
9248
|
+
if (isDescendantGroup(db, elm.source_group_id, componentId)) {
|
|
9249
|
+
return true;
|
|
9250
|
+
}
|
|
9251
|
+
}
|
|
9252
|
+
if ("source_component_id" in elm && elm.source_component_id) {
|
|
9253
|
+
const sourceComponent = db.source_component.get(elm.source_component_id);
|
|
9254
|
+
if (sourceComponent?.source_group_id) {
|
|
9255
|
+
if (sourceComponent.source_group_id === componentId) {
|
|
9256
|
+
return true;
|
|
9257
|
+
}
|
|
9258
|
+
if (isDescendantGroup(db, sourceComponent.source_group_id, componentId)) {
|
|
9259
|
+
return true;
|
|
9260
|
+
}
|
|
9261
|
+
}
|
|
9262
|
+
}
|
|
9263
|
+
if ("pcb_component_id" in elm && elm.pcb_component_id) {
|
|
9264
|
+
const pcbComponent2 = db.pcb_component.get(elm.pcb_component_id);
|
|
9265
|
+
if (pcbComponent2?.source_component_id) {
|
|
9266
|
+
const sourceComponent = db.source_component.get(
|
|
9267
|
+
pcbComponent2.source_component_id
|
|
9268
|
+
);
|
|
9269
|
+
if (sourceComponent?.source_group_id) {
|
|
9270
|
+
if (sourceComponent.source_group_id === componentId) {
|
|
9271
|
+
return true;
|
|
9272
|
+
}
|
|
9273
|
+
if (isDescendantGroup(
|
|
9274
|
+
db,
|
|
9275
|
+
sourceComponent.source_group_id,
|
|
9276
|
+
componentId
|
|
9277
|
+
)) {
|
|
9278
|
+
return true;
|
|
9279
|
+
}
|
|
9280
|
+
}
|
|
9281
|
+
}
|
|
9282
|
+
}
|
|
9283
|
+
return false;
|
|
9284
|
+
});
|
|
9285
|
+
transformPCBElements(relatedElements, transformMatrix);
|
|
9172
9286
|
db.pcb_group.update(pcbGroup.pcb_group_id, { center });
|
|
9173
9287
|
}
|
|
9174
9288
|
};
|
|
@@ -9176,8 +9290,8 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9176
9290
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutFlex.ts
|
|
9177
9291
|
import {
|
|
9178
9292
|
getCircuitJsonTree as getCircuitJsonTree3,
|
|
9179
|
-
repositionPcbComponentTo,
|
|
9180
|
-
repositionPcbGroupTo,
|
|
9293
|
+
repositionPcbComponentTo as repositionPcbComponentTo2,
|
|
9294
|
+
repositionPcbGroupTo as repositionPcbGroupTo2,
|
|
9181
9295
|
getMinimumFlexContainer as getMinimumFlexContainer2
|
|
9182
9296
|
} from "@tscircuit/circuit-json-util";
|
|
9183
9297
|
import { RootFlexBox as RootFlexBox2 } from "@tscircuit/miniflex";
|
|
@@ -9319,7 +9433,7 @@ var Group_doInitialPcbLayoutFlex = (group) => {
|
|
|
9319
9433
|
source_component_id: sourceComponent.source_component_id
|
|
9320
9434
|
});
|
|
9321
9435
|
if (!pcbComponent) continue;
|
|
9322
|
-
|
|
9436
|
+
repositionPcbComponentTo2(allCircuitJson, pcbComponent.pcb_component_id, {
|
|
9323
9437
|
x: child.position.x + child.size.width / 2 + offset.x,
|
|
9324
9438
|
y: child.position.y + child.size.height / 2 + offset.y
|
|
9325
9439
|
});
|
|
@@ -9329,7 +9443,7 @@ var Group_doInitialPcbLayoutFlex = (group) => {
|
|
|
9329
9443
|
source_group_id: sourceGroup.source_group_id
|
|
9330
9444
|
});
|
|
9331
9445
|
if (!pcbGroup) continue;
|
|
9332
|
-
|
|
9446
|
+
repositionPcbGroupTo2(allCircuitJson, sourceGroup.source_group_id, {
|
|
9333
9447
|
x: child.position.x + child.size.width / 2 + offset.x,
|
|
9334
9448
|
y: child.position.y + child.size.height / 2 + offset.y
|
|
9335
9449
|
});
|
|
@@ -9433,13 +9547,15 @@ var Group = class extends NormalComponent {
|
|
|
9433
9547
|
centerX += (padRight - padLeft) / 2;
|
|
9434
9548
|
centerY += (padTop - padBottom) / 2;
|
|
9435
9549
|
}
|
|
9550
|
+
const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
|
|
9551
|
+
const center = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
|
|
9552
|
+
x: centerX,
|
|
9553
|
+
y: centerY
|
|
9554
|
+
} : { x: centerX, y: centerY };
|
|
9436
9555
|
db.pcb_group.update(this.pcb_group_id, {
|
|
9437
9556
|
width: Number(props.width ?? width),
|
|
9438
9557
|
height: Number(props.height ?? height),
|
|
9439
|
-
center
|
|
9440
|
-
x: centerX,
|
|
9441
|
-
y: centerY
|
|
9442
|
-
}
|
|
9558
|
+
center
|
|
9443
9559
|
});
|
|
9444
9560
|
}
|
|
9445
9561
|
}
|
|
@@ -11345,7 +11461,7 @@ import { netLabelProps } from "@tscircuit/props";
|
|
|
11345
11461
|
import {
|
|
11346
11462
|
applyToPoint as applyToPoint8,
|
|
11347
11463
|
identity as identity4,
|
|
11348
|
-
translate as
|
|
11464
|
+
translate as translate6
|
|
11349
11465
|
} from "transformation-matrix";
|
|
11350
11466
|
var NetLabel = class extends PrimitiveComponent2 {
|
|
11351
11467
|
source_net_label_id;
|
|
@@ -11397,7 +11513,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
11397
11513
|
this.parent?.computeSchematicGlobalTransform?.() ?? identity4(),
|
|
11398
11514
|
{ x: 0, y: 0 }
|
|
11399
11515
|
);
|
|
11400
|
-
return
|
|
11516
|
+
return translate6(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
|
|
11401
11517
|
}
|
|
11402
11518
|
}
|
|
11403
11519
|
return super.computeSchematicPropsTransform();
|
|
@@ -12627,7 +12743,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
12627
12743
|
var package_default = {
|
|
12628
12744
|
name: "@tscircuit/core",
|
|
12629
12745
|
type: "module",
|
|
12630
|
-
version: "0.0.
|
|
12746
|
+
version: "0.0.636",
|
|
12631
12747
|
types: "dist/index.d.ts",
|
|
12632
12748
|
main: "dist/index.js",
|
|
12633
12749
|
module: "dist/index.js",
|
|
@@ -12685,7 +12801,7 @@ var package_default = {
|
|
|
12685
12801
|
howfat: "^0.3.8",
|
|
12686
12802
|
"live-server": "^1.2.2",
|
|
12687
12803
|
"looks-same": "^9.0.1",
|
|
12688
|
-
minicssgrid: "^0.0.
|
|
12804
|
+
minicssgrid: "^0.0.8",
|
|
12689
12805
|
"pkg-pr-new": "^0.0.37",
|
|
12690
12806
|
react: "^19.1.0",
|
|
12691
12807
|
"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.637",
|
|
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",
|