@tscircuit/core 0.0.707 → 0.0.709
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 +1596 -0
- package/dist/index.js +337 -74
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ __export(components_exports, {
|
|
|
13
13
|
BreakoutPoint: () => BreakoutPoint,
|
|
14
14
|
Capacitor: () => Capacitor,
|
|
15
15
|
Chip: () => Chip,
|
|
16
|
-
Constraint: () =>
|
|
16
|
+
Constraint: () => Constraint3,
|
|
17
17
|
Crystal: () => Crystal,
|
|
18
18
|
Cutout: () => Cutout,
|
|
19
19
|
Diode: () => Diode,
|
|
@@ -8582,12 +8582,22 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
8582
8582
|
if (component?._parsedProps?.schRotation !== void 0) {
|
|
8583
8583
|
availableRotations = [0];
|
|
8584
8584
|
}
|
|
8585
|
+
const marginLeft = component?._parsedProps?.schMarginLeft ?? component?._parsedProps?.schMarginX ?? 0;
|
|
8586
|
+
const marginRight = component?._parsedProps?.schMarginRight ?? component?._parsedProps?.schMarginX ?? 0;
|
|
8587
|
+
let marginTop = component?._parsedProps?.schMarginTop ?? component?._parsedProps?.schMarginY ?? 0;
|
|
8588
|
+
let marginBottom = component?._parsedProps?.schMarginBottom ?? component?._parsedProps?.schMarginY ?? 0;
|
|
8589
|
+
if (component?.config.shouldRenderAsSchematicBox) {
|
|
8590
|
+
marginTop += 0.4;
|
|
8591
|
+
marginBottom += 0.4;
|
|
8592
|
+
}
|
|
8593
|
+
const marginXShift = (marginRight - marginLeft) / 2;
|
|
8594
|
+
const marginYShift = (marginTop - marginBottom) / 2;
|
|
8585
8595
|
problem.chipMap[chipId] = {
|
|
8586
8596
|
chipId,
|
|
8587
8597
|
pins: [],
|
|
8588
8598
|
size: {
|
|
8589
|
-
x: schematicComponent.size?.width || 1,
|
|
8590
|
-
y: schematicComponent.size?.height || 1
|
|
8599
|
+
x: (schematicComponent.size?.width || 1) + marginLeft + marginRight,
|
|
8600
|
+
y: (schematicComponent.size?.height || 1) + marginTop + marginBottom
|
|
8591
8601
|
},
|
|
8592
8602
|
availableRotations
|
|
8593
8603
|
};
|
|
@@ -8603,8 +8613,8 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
8603
8613
|
problem.chipPinMap[pinId] = {
|
|
8604
8614
|
pinId,
|
|
8605
8615
|
offset: {
|
|
8606
|
-
x: (port.center?.x || 0) - (schematicComponent.center.x || 0),
|
|
8607
|
-
y: (port.center?.y || 0) - (schematicComponent.center.y || 0)
|
|
8616
|
+
x: (port.center?.x || 0) - (schematicComponent.center.x || 0) + marginXShift,
|
|
8617
|
+
y: (port.center?.y || 0) - (schematicComponent.center.y || 0) + marginYShift
|
|
8608
8618
|
},
|
|
8609
8619
|
side
|
|
8610
8620
|
};
|
|
@@ -8615,6 +8625,9 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
8615
8625
|
const schematicGroup = db.schematic_group?.getWhere?.({
|
|
8616
8626
|
source_group_id: child.sourceGroup.source_group_id
|
|
8617
8627
|
});
|
|
8628
|
+
const groupInstance = group.children.find(
|
|
8629
|
+
(groupChild) => groupChild.source_group_id === child.sourceGroup?.source_group_id
|
|
8630
|
+
);
|
|
8618
8631
|
debug5(
|
|
8619
8632
|
`[${group.name}] Found schematic_group for ${groupId}:`,
|
|
8620
8633
|
schematicGroup
|
|
@@ -8644,8 +8657,14 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
8644
8657
|
maxY = Math.max(maxY, comp.center.y + halfHeight);
|
|
8645
8658
|
}
|
|
8646
8659
|
}
|
|
8647
|
-
const
|
|
8648
|
-
const
|
|
8660
|
+
const marginLeft = groupInstance?._parsedProps?.schMarginLeft ?? groupInstance?._parsedProps?.schMarginX ?? 0;
|
|
8661
|
+
const marginRight = groupInstance?._parsedProps?.schMarginRight ?? groupInstance?._parsedProps?.schMarginX ?? 0;
|
|
8662
|
+
const marginTop = groupInstance?._parsedProps?.schMarginTop ?? groupInstance?._parsedProps?.schMarginY ?? 0;
|
|
8663
|
+
const marginBottom = groupInstance?._parsedProps?.schMarginBottom ?? groupInstance?._parsedProps?.schMarginY ?? 0;
|
|
8664
|
+
const marginXShift = (marginRight - marginLeft) / 2;
|
|
8665
|
+
const marginYShift = (marginTop - marginBottom) / 2;
|
|
8666
|
+
const groupWidth = (hasValidBounds ? maxX - minX : 2) + marginLeft + marginRight;
|
|
8667
|
+
const groupHeight = (hasValidBounds ? maxY - minY : 2) + marginTop + marginBottom;
|
|
8649
8668
|
debug5(
|
|
8650
8669
|
`[${group.name}] Group ${groupId} computed size: ${groupWidth} x ${groupHeight}`
|
|
8651
8670
|
);
|
|
@@ -8664,8 +8683,8 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
8664
8683
|
problem.chipPinMap[pinId] = {
|
|
8665
8684
|
pinId,
|
|
8666
8685
|
offset: {
|
|
8667
|
-
x: (port.center?.x || 0) - groupCenter.x,
|
|
8668
|
-
y: (port.center?.y || 0) - groupCenter.y
|
|
8686
|
+
x: (port.center?.x || 0) - groupCenter.x + marginXShift,
|
|
8687
|
+
y: (port.center?.y || 0) - groupCenter.y + marginYShift
|
|
8669
8688
|
},
|
|
8670
8689
|
side
|
|
8671
8690
|
};
|
|
@@ -9740,8 +9759,7 @@ function getPresetAutoroutingConfig(autorouterConfig) {
|
|
|
9740
9759
|
}
|
|
9741
9760
|
}
|
|
9742
9761
|
|
|
9743
|
-
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack.ts
|
|
9744
|
-
import "@tscircuit/circuit-json-util";
|
|
9762
|
+
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack/Group_doInitialPcbLayoutPack.ts
|
|
9745
9763
|
import {
|
|
9746
9764
|
pack,
|
|
9747
9765
|
convertCircuitJsonToPackOutput,
|
|
@@ -9749,64 +9767,263 @@ import {
|
|
|
9749
9767
|
getGraphicsFromPackOutput
|
|
9750
9768
|
} from "calculate-packing";
|
|
9751
9769
|
import { length as length4 } from "circuit-json";
|
|
9752
|
-
import {
|
|
9753
|
-
transformPCBElements
|
|
9754
|
-
} from "@tscircuit/circuit-json-util";
|
|
9755
|
-
import { translate as translate5, rotate as rotate2, compose as compose4 } from "transformation-matrix";
|
|
9756
9770
|
import Debug7 from "debug";
|
|
9757
|
-
|
|
9758
|
-
|
|
9771
|
+
|
|
9772
|
+
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack/applyComponentConstraintClusters.ts
|
|
9773
|
+
import * as kiwi2 from "@lume/kiwi";
|
|
9774
|
+
var applyComponentConstraintClusters = (group, packInput) => {
|
|
9775
|
+
const constraints = group.children.filter(
|
|
9776
|
+
(c) => c.componentName === "Constraint" && c._parsedProps.pcb
|
|
9777
|
+
);
|
|
9778
|
+
const clusterByRoot = /* @__PURE__ */ new Map();
|
|
9779
|
+
const parent = {};
|
|
9780
|
+
const find = (x) => {
|
|
9781
|
+
if (parent[x] !== x) parent[x] = find(parent[x]);
|
|
9782
|
+
return parent[x];
|
|
9783
|
+
};
|
|
9784
|
+
const union = (a, b) => {
|
|
9785
|
+
const ra = find(a);
|
|
9786
|
+
const rb = find(b);
|
|
9787
|
+
if (ra !== rb) parent[rb] = ra;
|
|
9788
|
+
};
|
|
9789
|
+
const makeSet = (x) => {
|
|
9790
|
+
if (!(x in parent)) parent[x] = x;
|
|
9791
|
+
};
|
|
9792
|
+
const getIdFromSelector = (sel2) => {
|
|
9793
|
+
const name = sel2.startsWith(".") ? sel2.slice(1) : sel2;
|
|
9794
|
+
const child = group.children.find((c) => c.name === name);
|
|
9795
|
+
return child?.pcb_component_id ?? void 0;
|
|
9796
|
+
};
|
|
9797
|
+
for (const constraint of constraints) {
|
|
9798
|
+
const props = constraint._parsedProps;
|
|
9799
|
+
if ("left" in props && "right" in props) {
|
|
9800
|
+
const a = getIdFromSelector(props.left);
|
|
9801
|
+
const b = getIdFromSelector(props.right);
|
|
9802
|
+
if (a && b) {
|
|
9803
|
+
makeSet(a);
|
|
9804
|
+
makeSet(b);
|
|
9805
|
+
union(a, b);
|
|
9806
|
+
}
|
|
9807
|
+
} else if ("top" in props && "bottom" in props) {
|
|
9808
|
+
const a = getIdFromSelector(props.top);
|
|
9809
|
+
const b = getIdFromSelector(props.bottom);
|
|
9810
|
+
if (a && b) {
|
|
9811
|
+
makeSet(a);
|
|
9812
|
+
makeSet(b);
|
|
9813
|
+
union(a, b);
|
|
9814
|
+
}
|
|
9815
|
+
} else if ("for" in props && Array.isArray(props.for)) {
|
|
9816
|
+
const ids = props.for.map((s) => getIdFromSelector(s)).filter((s) => !!s);
|
|
9817
|
+
for (const id of ids) makeSet(id);
|
|
9818
|
+
for (let i = 1; i < ids.length; i++) union(ids[0], ids[i]);
|
|
9819
|
+
}
|
|
9820
|
+
}
|
|
9821
|
+
for (const id of Object.keys(parent)) {
|
|
9822
|
+
const rootId = find(id);
|
|
9823
|
+
if (!clusterByRoot.has(rootId))
|
|
9824
|
+
clusterByRoot.set(rootId, { componentIds: [], constraints: [] });
|
|
9825
|
+
clusterByRoot.get(rootId).componentIds.push(id);
|
|
9826
|
+
}
|
|
9827
|
+
for (const constraint of constraints) {
|
|
9828
|
+
const props = constraint._parsedProps;
|
|
9829
|
+
let compId;
|
|
9830
|
+
if ("left" in props) compId = getIdFromSelector(props.left);
|
|
9831
|
+
else if ("top" in props) compId = getIdFromSelector(props.top);
|
|
9832
|
+
else if ("for" in props) compId = getIdFromSelector(props.for[0]);
|
|
9833
|
+
if (!compId) continue;
|
|
9834
|
+
const root = find(compId);
|
|
9835
|
+
clusterByRoot.get(root)?.constraints.push(constraint);
|
|
9836
|
+
}
|
|
9837
|
+
const clusterMap = {};
|
|
9838
|
+
const packCompById = Object.fromEntries(
|
|
9839
|
+
packInput.components.map((c) => [c.componentId, c])
|
|
9840
|
+
);
|
|
9841
|
+
for (const [rootId, info] of clusterByRoot.entries()) {
|
|
9842
|
+
if (info.componentIds.length <= 1) continue;
|
|
9843
|
+
const solver = new kiwi2.Solver();
|
|
9844
|
+
const kVars = {};
|
|
9845
|
+
const getVar = (id, axis) => {
|
|
9846
|
+
const key = `${id}_${axis}`;
|
|
9847
|
+
if (!kVars[key]) kVars[key] = new kiwi2.Variable(key);
|
|
9848
|
+
return kVars[key];
|
|
9849
|
+
};
|
|
9850
|
+
const anchor = info.componentIds[0];
|
|
9851
|
+
solver.addConstraint(
|
|
9852
|
+
new kiwi2.Constraint(
|
|
9853
|
+
getVar(anchor, "x"),
|
|
9854
|
+
kiwi2.Operator.Eq,
|
|
9855
|
+
0,
|
|
9856
|
+
kiwi2.Strength.required
|
|
9857
|
+
)
|
|
9858
|
+
);
|
|
9859
|
+
solver.addConstraint(
|
|
9860
|
+
new kiwi2.Constraint(
|
|
9861
|
+
getVar(anchor, "y"),
|
|
9862
|
+
kiwi2.Operator.Eq,
|
|
9863
|
+
0,
|
|
9864
|
+
kiwi2.Strength.required
|
|
9865
|
+
)
|
|
9866
|
+
);
|
|
9867
|
+
for (const constraint of info.constraints) {
|
|
9868
|
+
const props = constraint._parsedProps;
|
|
9869
|
+
if ("xDist" in props) {
|
|
9870
|
+
const left = getIdFromSelector(props.left);
|
|
9871
|
+
const right = getIdFromSelector(props.right);
|
|
9872
|
+
if (left && right) {
|
|
9873
|
+
solver.addConstraint(
|
|
9874
|
+
new kiwi2.Constraint(
|
|
9875
|
+
new kiwi2.Expression(getVar(right, "x"), [-1, getVar(left, "x")]),
|
|
9876
|
+
kiwi2.Operator.Eq,
|
|
9877
|
+
props.xDist,
|
|
9878
|
+
kiwi2.Strength.required
|
|
9879
|
+
)
|
|
9880
|
+
);
|
|
9881
|
+
}
|
|
9882
|
+
} else if ("yDist" in props) {
|
|
9883
|
+
const top = getIdFromSelector(props.top);
|
|
9884
|
+
const bottom = getIdFromSelector(props.bottom);
|
|
9885
|
+
if (top && bottom) {
|
|
9886
|
+
solver.addConstraint(
|
|
9887
|
+
new kiwi2.Constraint(
|
|
9888
|
+
new kiwi2.Expression(getVar(top, "y"), [-1, getVar(bottom, "y")]),
|
|
9889
|
+
kiwi2.Operator.Eq,
|
|
9890
|
+
props.yDist,
|
|
9891
|
+
kiwi2.Strength.required
|
|
9892
|
+
)
|
|
9893
|
+
);
|
|
9894
|
+
}
|
|
9895
|
+
} else if ("sameX" in props && Array.isArray(props.for)) {
|
|
9896
|
+
const ids = props.for.map((s) => getIdFromSelector(s)).filter((s) => !!s);
|
|
9897
|
+
if (ids.length > 1) {
|
|
9898
|
+
const base = getVar(ids[0], "x");
|
|
9899
|
+
for (let i = 1; i < ids.length; i++) {
|
|
9900
|
+
solver.addConstraint(
|
|
9901
|
+
new kiwi2.Constraint(
|
|
9902
|
+
new kiwi2.Expression(getVar(ids[i], "x"), [-1, base]),
|
|
9903
|
+
kiwi2.Operator.Eq,
|
|
9904
|
+
0,
|
|
9905
|
+
kiwi2.Strength.required
|
|
9906
|
+
)
|
|
9907
|
+
);
|
|
9908
|
+
}
|
|
9909
|
+
}
|
|
9910
|
+
} else if ("sameY" in props && Array.isArray(props.for)) {
|
|
9911
|
+
const ids = props.for.map((s) => getIdFromSelector(s)).filter((s) => !!s);
|
|
9912
|
+
if (ids.length > 1) {
|
|
9913
|
+
const base = getVar(ids[0], "y");
|
|
9914
|
+
for (let i = 1; i < ids.length; i++) {
|
|
9915
|
+
solver.addConstraint(
|
|
9916
|
+
new kiwi2.Constraint(
|
|
9917
|
+
new kiwi2.Expression(getVar(ids[i], "y"), [-1, base]),
|
|
9918
|
+
kiwi2.Operator.Eq,
|
|
9919
|
+
0,
|
|
9920
|
+
kiwi2.Strength.required
|
|
9921
|
+
)
|
|
9922
|
+
);
|
|
9923
|
+
}
|
|
9924
|
+
}
|
|
9925
|
+
}
|
|
9926
|
+
}
|
|
9927
|
+
solver.updateVariables();
|
|
9928
|
+
const positions = {};
|
|
9929
|
+
for (const id of info.componentIds) {
|
|
9930
|
+
positions[id] = {
|
|
9931
|
+
x: getVar(id, "x").value(),
|
|
9932
|
+
y: getVar(id, "y").value()
|
|
9933
|
+
};
|
|
9934
|
+
}
|
|
9935
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
9936
|
+
for (const id of info.componentIds) {
|
|
9937
|
+
const comp = packCompById[id];
|
|
9938
|
+
const pos = positions[id];
|
|
9939
|
+
if (!comp) continue;
|
|
9940
|
+
for (const pad of comp.pads) {
|
|
9941
|
+
const ax = pos.x + pad.offset.x;
|
|
9942
|
+
const ay = pos.y + pad.offset.y;
|
|
9943
|
+
minX = Math.min(minX, ax - pad.size.x / 2);
|
|
9944
|
+
maxX = Math.max(maxX, ax + pad.size.x / 2);
|
|
9945
|
+
minY = Math.min(minY, ay - pad.size.y / 2);
|
|
9946
|
+
maxY = Math.max(maxY, ay + pad.size.y / 2);
|
|
9947
|
+
}
|
|
9948
|
+
}
|
|
9949
|
+
const clusterCenter = { x: (minX + maxX) / 2, y: (minY + maxY) / 2 };
|
|
9950
|
+
const mergedPads = [];
|
|
9951
|
+
const relCenters = {};
|
|
9952
|
+
for (const id of info.componentIds) {
|
|
9953
|
+
const comp = packCompById[id];
|
|
9954
|
+
const pos = positions[id];
|
|
9955
|
+
if (!comp) continue;
|
|
9956
|
+
relCenters[id] = {
|
|
9957
|
+
x: pos.x - clusterCenter.x,
|
|
9958
|
+
y: pos.y - clusterCenter.y
|
|
9959
|
+
};
|
|
9960
|
+
for (const pad of comp.pads) {
|
|
9961
|
+
mergedPads.push({
|
|
9962
|
+
padId: pad.padId,
|
|
9963
|
+
networkId: pad.networkId,
|
|
9964
|
+
type: pad.type,
|
|
9965
|
+
size: pad.size,
|
|
9966
|
+
offset: {
|
|
9967
|
+
x: pos.x + pad.offset.x - clusterCenter.x,
|
|
9968
|
+
y: pos.y + pad.offset.y - clusterCenter.y
|
|
9969
|
+
}
|
|
9970
|
+
});
|
|
9971
|
+
}
|
|
9972
|
+
}
|
|
9973
|
+
packInput.components = packInput.components.filter(
|
|
9974
|
+
(c) => !info.componentIds.includes(c.componentId)
|
|
9975
|
+
);
|
|
9976
|
+
packInput.components.push({
|
|
9977
|
+
componentId: info.componentIds[0],
|
|
9978
|
+
pads: mergedPads,
|
|
9979
|
+
availableRotationDegrees: [0]
|
|
9980
|
+
});
|
|
9981
|
+
info.relativeCenters = relCenters;
|
|
9982
|
+
clusterMap[info.componentIds[0]] = info;
|
|
9983
|
+
}
|
|
9984
|
+
return clusterMap;
|
|
9985
|
+
};
|
|
9986
|
+
|
|
9987
|
+
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack/applyPackOutput.ts
|
|
9988
|
+
import { translate as translate5, rotate as rotate2, compose as compose4 } from "transformation-matrix";
|
|
9989
|
+
import { transformPCBElements } from "@tscircuit/circuit-json-util";
|
|
9759
9990
|
var isDescendantGroup = (db, groupId, ancestorId) => {
|
|
9760
9991
|
if (groupId === ancestorId) return true;
|
|
9761
9992
|
const group = db.source_group.get(groupId);
|
|
9762
9993
|
if (!group || !group.parent_source_group_id) return false;
|
|
9763
9994
|
return isDescendantGroup(db, group.parent_source_group_id, ancestorId);
|
|
9764
9995
|
};
|
|
9765
|
-
var
|
|
9996
|
+
var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
9766
9997
|
const { db } = group.root;
|
|
9767
|
-
const { _parsedProps: props } = group;
|
|
9768
|
-
const {
|
|
9769
|
-
packOrderStrategy,
|
|
9770
|
-
packPlacementStrategy,
|
|
9771
|
-
gap: gapProp,
|
|
9772
|
-
pcbGap,
|
|
9773
|
-
// @ts-expect-error remove when props introduces pcbPackGap
|
|
9774
|
-
pcbPackGap
|
|
9775
|
-
} = props;
|
|
9776
|
-
const gap = pcbPackGap ?? pcbGap ?? gapProp;
|
|
9777
|
-
const gapMm = length4.parse(gap ?? DEFAULT_MIN_GAP);
|
|
9778
|
-
const packInput = {
|
|
9779
|
-
...convertPackOutputToPackInput(
|
|
9780
|
-
convertCircuitJsonToPackOutput(db.toArray(), {
|
|
9781
|
-
source_group_id: group.source_group_id,
|
|
9782
|
-
shouldAddInnerObstacles: true
|
|
9783
|
-
})
|
|
9784
|
-
),
|
|
9785
|
-
// @ts-expect-error we're missing some pack order strategies
|
|
9786
|
-
orderStrategy: packOrderStrategy ?? "largest_to_smallest",
|
|
9787
|
-
placementStrategy: packPlacementStrategy ?? "minimum_sum_squared_distance_to_network",
|
|
9788
|
-
minGap: gapMm
|
|
9789
|
-
};
|
|
9790
|
-
if (debug6.enabled) {
|
|
9791
|
-
group.root?.emit("debug:logOutput", {
|
|
9792
|
-
type: "debug:logOutput",
|
|
9793
|
-
name: `packInput-circuitjson-${group.name}`,
|
|
9794
|
-
content: JSON.stringify(db.toArray())
|
|
9795
|
-
});
|
|
9796
|
-
group.root?.emit("debug:logOutput", {
|
|
9797
|
-
type: "debug:logOutput",
|
|
9798
|
-
name: `packInput-${group.name}`,
|
|
9799
|
-
content: packInput
|
|
9800
|
-
});
|
|
9801
|
-
}
|
|
9802
|
-
const packOutput = pack(packInput);
|
|
9803
|
-
if (debug6.enabled) {
|
|
9804
|
-
const graphics = getGraphicsFromPackOutput(packOutput);
|
|
9805
|
-
graphics.title = `packOutput-${group.name}`;
|
|
9806
|
-
global.debugGraphics?.push(graphics);
|
|
9807
|
-
}
|
|
9808
9998
|
for (const packedComponent of packOutput.components) {
|
|
9809
9999
|
const { center, componentId, ccwRotationOffset, ccwRotationDegrees } = packedComponent;
|
|
10000
|
+
const cluster = clusterMap[componentId];
|
|
10001
|
+
if (cluster) {
|
|
10002
|
+
const rotationDegrees2 = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
|
|
10003
|
+
const angleRad = rotationDegrees2 * Math.PI / 180;
|
|
10004
|
+
for (const memberId of cluster.componentIds) {
|
|
10005
|
+
const rel = cluster.relativeCenters[memberId];
|
|
10006
|
+
if (!rel) continue;
|
|
10007
|
+
const rotatedRel = {
|
|
10008
|
+
x: rel.x * Math.cos(angleRad) - rel.y * Math.sin(angleRad),
|
|
10009
|
+
y: rel.x * Math.sin(angleRad) + rel.y * Math.cos(angleRad)
|
|
10010
|
+
};
|
|
10011
|
+
const member = db.pcb_component.get(memberId);
|
|
10012
|
+
if (!member) continue;
|
|
10013
|
+
const originalCenter2 = member.center;
|
|
10014
|
+
const transformMatrix2 = compose4(
|
|
10015
|
+
group._computePcbGlobalTransformBeforeLayout(),
|
|
10016
|
+
translate5(center.x + rotatedRel.x, center.y + rotatedRel.y),
|
|
10017
|
+
rotate2(angleRad),
|
|
10018
|
+
translate5(-originalCenter2.x, -originalCenter2.y)
|
|
10019
|
+
);
|
|
10020
|
+
const related = db.toArray().filter(
|
|
10021
|
+
(elm) => "pcb_component_id" in elm && elm.pcb_component_id === memberId
|
|
10022
|
+
);
|
|
10023
|
+
transformPCBElements(related, transformMatrix2);
|
|
10024
|
+
}
|
|
10025
|
+
continue;
|
|
10026
|
+
}
|
|
9810
10027
|
const pcbComponent = db.pcb_component.get(componentId);
|
|
9811
10028
|
if (pcbComponent) {
|
|
9812
10029
|
const currentGroupId = group.source_group_id;
|
|
@@ -9862,20 +10079,16 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9862
10079
|
}
|
|
9863
10080
|
}
|
|
9864
10081
|
if ("pcb_component_id" in elm && elm.pcb_component_id) {
|
|
9865
|
-
const
|
|
9866
|
-
if (
|
|
9867
|
-
const
|
|
9868
|
-
|
|
10082
|
+
const pcbComp = db.pcb_component.get(elm.pcb_component_id);
|
|
10083
|
+
if (pcbComp?.source_component_id) {
|
|
10084
|
+
const sourceComp = db.source_component.get(
|
|
10085
|
+
pcbComp.source_component_id
|
|
9869
10086
|
);
|
|
9870
|
-
if (
|
|
9871
|
-
if (
|
|
10087
|
+
if (sourceComp?.source_group_id) {
|
|
10088
|
+
if (sourceComp.source_group_id === componentId) {
|
|
9872
10089
|
return true;
|
|
9873
10090
|
}
|
|
9874
|
-
if (isDescendantGroup(
|
|
9875
|
-
db,
|
|
9876
|
-
sourceComponent.source_group_id,
|
|
9877
|
-
componentId
|
|
9878
|
-
)) {
|
|
10091
|
+
if (isDescendantGroup(db, sourceComp.source_group_id, componentId)) {
|
|
9879
10092
|
return true;
|
|
9880
10093
|
}
|
|
9881
10094
|
}
|
|
@@ -9888,6 +10101,56 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9888
10101
|
}
|
|
9889
10102
|
};
|
|
9890
10103
|
|
|
10104
|
+
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack/Group_doInitialPcbLayoutPack.ts
|
|
10105
|
+
var DEFAULT_MIN_GAP = "1mm";
|
|
10106
|
+
var debug6 = Debug7("Group_doInitialPcbLayoutPack");
|
|
10107
|
+
var Group_doInitialPcbLayoutPack = (group) => {
|
|
10108
|
+
const { db } = group.root;
|
|
10109
|
+
const { _parsedProps: props } = group;
|
|
10110
|
+
const {
|
|
10111
|
+
packOrderStrategy,
|
|
10112
|
+
packPlacementStrategy,
|
|
10113
|
+
gap: gapProp,
|
|
10114
|
+
pcbGap,
|
|
10115
|
+
// @ts-expect-error remove when props introduces pcbPackGap
|
|
10116
|
+
pcbPackGap
|
|
10117
|
+
} = props;
|
|
10118
|
+
const gap = pcbPackGap ?? pcbGap ?? gapProp;
|
|
10119
|
+
const gapMm = length4.parse(gap ?? DEFAULT_MIN_GAP);
|
|
10120
|
+
const packInput = {
|
|
10121
|
+
...convertPackOutputToPackInput(
|
|
10122
|
+
convertCircuitJsonToPackOutput(db.toArray(), {
|
|
10123
|
+
source_group_id: group.source_group_id,
|
|
10124
|
+
shouldAddInnerObstacles: true
|
|
10125
|
+
})
|
|
10126
|
+
),
|
|
10127
|
+
// @ts-expect-error we're missing some pack order strategies
|
|
10128
|
+
orderStrategy: packOrderStrategy ?? "largest_to_smallest",
|
|
10129
|
+
placementStrategy: packPlacementStrategy ?? "minimum_sum_squared_distance_to_network",
|
|
10130
|
+
minGap: gapMm
|
|
10131
|
+
};
|
|
10132
|
+
const clusterMap = applyComponentConstraintClusters(group, packInput);
|
|
10133
|
+
if (debug6.enabled) {
|
|
10134
|
+
group.root?.emit("debug:logOutput", {
|
|
10135
|
+
type: "debug:logOutput",
|
|
10136
|
+
name: `packInput-circuitjson-${group.name}`,
|
|
10137
|
+
content: JSON.stringify(db.toArray())
|
|
10138
|
+
});
|
|
10139
|
+
group.root?.emit("debug:logOutput", {
|
|
10140
|
+
type: "debug:logOutput",
|
|
10141
|
+
name: `packInput-${group.name}`,
|
|
10142
|
+
content: packInput
|
|
10143
|
+
});
|
|
10144
|
+
}
|
|
10145
|
+
const packOutput = pack(packInput);
|
|
10146
|
+
if (debug6.enabled) {
|
|
10147
|
+
const graphics = getGraphicsFromPackOutput(packOutput);
|
|
10148
|
+
graphics.title = `packOutput-${group.name}`;
|
|
10149
|
+
global.debugGraphics?.push(graphics);
|
|
10150
|
+
}
|
|
10151
|
+
applyPackOutput(group, packOutput, clusterMap);
|
|
10152
|
+
};
|
|
10153
|
+
|
|
9891
10154
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutFlex.ts
|
|
9892
10155
|
import { getMinimumFlexContainer as getMinimumFlexContainer2 } from "@tscircuit/circuit-json-util";
|
|
9893
10156
|
import { RootFlexBox as RootFlexBox2 } from "@tscircuit/miniflex";
|
|
@@ -12696,7 +12959,7 @@ var edgeSpecifiers = [
|
|
|
12696
12959
|
"bottomedge",
|
|
12697
12960
|
"center"
|
|
12698
12961
|
];
|
|
12699
|
-
var
|
|
12962
|
+
var Constraint3 = class extends PrimitiveComponent2 {
|
|
12700
12963
|
get config() {
|
|
12701
12964
|
return {
|
|
12702
12965
|
componentName: "Constraint",
|
|
@@ -14379,7 +14642,7 @@ import { identity as identity6 } from "transformation-matrix";
|
|
|
14379
14642
|
var package_default = {
|
|
14380
14643
|
name: "@tscircuit/core",
|
|
14381
14644
|
type: "module",
|
|
14382
|
-
version: "0.0.
|
|
14645
|
+
version: "0.0.708",
|
|
14383
14646
|
types: "dist/index.d.ts",
|
|
14384
14647
|
main: "dist/index.js",
|
|
14385
14648
|
module: "dist/index.js",
|
|
@@ -14418,7 +14681,7 @@ var package_default = {
|
|
|
14418
14681
|
"@tscircuit/matchpack": "^0.0.16",
|
|
14419
14682
|
"@tscircuit/math-utils": "^0.0.21",
|
|
14420
14683
|
"@tscircuit/miniflex": "^0.0.4",
|
|
14421
|
-
"@tscircuit/props": "0.0.
|
|
14684
|
+
"@tscircuit/props": "0.0.310",
|
|
14422
14685
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
14423
14686
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
14424
14687
|
"@tscircuit/schematic-trace-solver": "^0.0.35",
|
|
@@ -14889,7 +15152,7 @@ export {
|
|
|
14889
15152
|
Capacitor,
|
|
14890
15153
|
Chip,
|
|
14891
15154
|
Circuit,
|
|
14892
|
-
|
|
15155
|
+
Constraint3 as Constraint,
|
|
14893
15156
|
Crystal,
|
|
14894
15157
|
Cutout,
|
|
14895
15158
|
Diode,
|
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.709",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@tscircuit/matchpack": "^0.0.16",
|
|
41
41
|
"@tscircuit/math-utils": "^0.0.21",
|
|
42
42
|
"@tscircuit/miniflex": "^0.0.4",
|
|
43
|
-
"@tscircuit/props": "0.0.
|
|
43
|
+
"@tscircuit/props": "0.0.310",
|
|
44
44
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
45
45
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
46
46
|
"@tscircuit/schematic-trace-solver": "^0.0.35",
|