@tscircuit/core 0.0.624 → 0.0.626
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 +1 -0
- package/dist/index.js +329 -68
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2705,6 +2705,7 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, Polarized
|
|
|
2705
2705
|
}>;
|
|
2706
2706
|
sourceFtype: "simple_capacitor";
|
|
2707
2707
|
};
|
|
2708
|
+
initPorts(): void;
|
|
2708
2709
|
_getSchematicSymbolDisplayValue(): string | undefined;
|
|
2709
2710
|
doInitialCreateNetsFromProps(): void;
|
|
2710
2711
|
doInitialCreateTracesFromProps(): void;
|
package/dist/index.js
CHANGED
|
@@ -7952,6 +7952,20 @@ import {
|
|
|
7952
7952
|
import { LayoutPipelineSolver } from "@tscircuit/matchpack";
|
|
7953
7953
|
import Debug6 from "debug";
|
|
7954
7954
|
var debug5 = Debug6("Group_doInitialSchematicLayoutMatchpack");
|
|
7955
|
+
function facingDirectionToSide(facingDirection) {
|
|
7956
|
+
switch (facingDirection) {
|
|
7957
|
+
case "up":
|
|
7958
|
+
return "y+";
|
|
7959
|
+
case "down":
|
|
7960
|
+
return "y-";
|
|
7961
|
+
case "left":
|
|
7962
|
+
return "x-";
|
|
7963
|
+
case "right":
|
|
7964
|
+
return "x+";
|
|
7965
|
+
default:
|
|
7966
|
+
return "y+";
|
|
7967
|
+
}
|
|
7968
|
+
}
|
|
7955
7969
|
function rotateDirection(direction, degrees) {
|
|
7956
7970
|
const directions = [
|
|
7957
7971
|
"up",
|
|
@@ -7977,7 +7991,18 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
7977
7991
|
chipGap: 0.4,
|
|
7978
7992
|
partitionGap: 1.2
|
|
7979
7993
|
};
|
|
7994
|
+
debug5(
|
|
7995
|
+
`[${group.name}] Processing ${tree.childNodes.length} child nodes for input problem`
|
|
7996
|
+
);
|
|
7980
7997
|
tree.childNodes.forEach((child, index) => {
|
|
7998
|
+
debug5(
|
|
7999
|
+
`[${group.name}] Processing child ${index}: nodeType=${child.nodeType}`
|
|
8000
|
+
);
|
|
8001
|
+
if (child.nodeType === "component") {
|
|
8002
|
+
debug5(`[${group.name}] - Component: ${child.sourceComponent?.name}`);
|
|
8003
|
+
} else if (child.nodeType === "group") {
|
|
8004
|
+
debug5(`[${group.name}] - Group: ${child.sourceGroup?.name}`);
|
|
8005
|
+
}
|
|
7981
8006
|
if (child.nodeType === "component" && child.sourceComponent) {
|
|
7982
8007
|
const chipId = child.sourceComponent.name || `chip_${index}`;
|
|
7983
8008
|
const schematicComponent = db.schematic_component.getWhere({
|
|
@@ -8011,21 +8036,7 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
8011
8036
|
if (!sourcePort) continue;
|
|
8012
8037
|
const pinId = `${chipId}.${sourcePort.pin_number || sourcePort.name || port.schematic_port_id}`;
|
|
8013
8038
|
problem.chipMap[chipId].pins.push(pinId);
|
|
8014
|
-
|
|
8015
|
-
switch (port.facing_direction) {
|
|
8016
|
-
case "up":
|
|
8017
|
-
side = "y+";
|
|
8018
|
-
break;
|
|
8019
|
-
case "down":
|
|
8020
|
-
side = "y-";
|
|
8021
|
-
break;
|
|
8022
|
-
case "left":
|
|
8023
|
-
side = "x-";
|
|
8024
|
-
break;
|
|
8025
|
-
case "right":
|
|
8026
|
-
side = "x+";
|
|
8027
|
-
break;
|
|
8028
|
-
}
|
|
8039
|
+
const side = facingDirectionToSide(port.facing_direction);
|
|
8029
8040
|
problem.chipPinMap[pinId] = {
|
|
8030
8041
|
pinId,
|
|
8031
8042
|
offset: {
|
|
@@ -8037,67 +8048,226 @@ function convertTreeToInputProblem(tree, db, group) {
|
|
|
8037
8048
|
}
|
|
8038
8049
|
} else if (child.nodeType === "group" && child.sourceGroup) {
|
|
8039
8050
|
const groupId = child.sourceGroup.name || `group_${index}`;
|
|
8051
|
+
debug5(`[${group.name}] Processing nested group: ${groupId}`);
|
|
8040
8052
|
const schematicGroup = db.schematic_group?.getWhere?.({
|
|
8041
8053
|
source_group_id: child.sourceGroup.source_group_id
|
|
8042
8054
|
});
|
|
8055
|
+
debug5(
|
|
8056
|
+
`[${group.name}] Found schematic_group for ${groupId}:`,
|
|
8057
|
+
schematicGroup
|
|
8058
|
+
);
|
|
8043
8059
|
if (schematicGroup) {
|
|
8060
|
+
debug5(`[${group.name}] Treating group ${groupId} as composite chip`);
|
|
8061
|
+
const groupComponents = db.schematic_component.list({
|
|
8062
|
+
schematic_group_id: schematicGroup.schematic_group_id
|
|
8063
|
+
});
|
|
8064
|
+
debug5(
|
|
8065
|
+
`[${group.name}] Group ${groupId} has ${groupComponents.length} components:`,
|
|
8066
|
+
groupComponents.map((c) => c.source_component_id)
|
|
8067
|
+
);
|
|
8068
|
+
let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
|
|
8069
|
+
let hasValidBounds = false;
|
|
8070
|
+
for (const comp of groupComponents) {
|
|
8071
|
+
if (comp.center && comp.size) {
|
|
8072
|
+
hasValidBounds = true;
|
|
8073
|
+
const halfWidth = comp.size.width / 2;
|
|
8074
|
+
const halfHeight = comp.size.height / 2;
|
|
8075
|
+
minX = Math.min(minX, comp.center.x - halfWidth);
|
|
8076
|
+
maxX = Math.max(maxX, comp.center.x + halfWidth);
|
|
8077
|
+
minY = Math.min(minY, comp.center.y - halfHeight);
|
|
8078
|
+
maxY = Math.max(maxY, comp.center.y + halfHeight);
|
|
8079
|
+
}
|
|
8080
|
+
}
|
|
8081
|
+
const groupWidth = hasValidBounds ? maxX - minX : 2;
|
|
8082
|
+
const groupHeight = hasValidBounds ? maxY - minY : 2;
|
|
8083
|
+
debug5(
|
|
8084
|
+
`[${group.name}] Group ${groupId} computed size: ${groupWidth} x ${groupHeight}`
|
|
8085
|
+
);
|
|
8086
|
+
const groupPins = [];
|
|
8087
|
+
for (const comp of groupComponents) {
|
|
8088
|
+
const ports = db.schematic_port.list({
|
|
8089
|
+
schematic_component_id: comp.schematic_component_id
|
|
8090
|
+
});
|
|
8091
|
+
for (const port of ports) {
|
|
8092
|
+
const sourcePort = db.source_port.get(port.source_port_id);
|
|
8093
|
+
if (!sourcePort) continue;
|
|
8094
|
+
const pinId = `${groupId}.${sourcePort.pin_number || sourcePort.name || port.schematic_port_id}`;
|
|
8095
|
+
groupPins.push(pinId);
|
|
8096
|
+
const groupCenter = schematicGroup.center || { x: 0, y: 0 };
|
|
8097
|
+
const side = facingDirectionToSide(port.facing_direction);
|
|
8098
|
+
problem.chipPinMap[pinId] = {
|
|
8099
|
+
pinId,
|
|
8100
|
+
offset: {
|
|
8101
|
+
x: (port.center?.x || 0) - groupCenter.x,
|
|
8102
|
+
y: (port.center?.y || 0) - groupCenter.y
|
|
8103
|
+
},
|
|
8104
|
+
side
|
|
8105
|
+
};
|
|
8106
|
+
}
|
|
8107
|
+
}
|
|
8108
|
+
debug5(
|
|
8109
|
+
`[${group.name}] Group ${groupId} has ${groupPins.length} pins:`,
|
|
8110
|
+
groupPins
|
|
8111
|
+
);
|
|
8044
8112
|
problem.chipMap[groupId] = {
|
|
8045
8113
|
chipId: groupId,
|
|
8046
|
-
pins:
|
|
8114
|
+
pins: groupPins,
|
|
8047
8115
|
size: {
|
|
8048
|
-
x:
|
|
8049
|
-
y:
|
|
8116
|
+
x: groupWidth,
|
|
8117
|
+
y: groupHeight
|
|
8050
8118
|
}
|
|
8051
8119
|
};
|
|
8120
|
+
debug5(`[${group.name}] Added group ${groupId} to chipMap`);
|
|
8121
|
+
} else {
|
|
8122
|
+
debug5(
|
|
8123
|
+
`[${group.name}] Warning: No schematic_group found for group ${groupId}`
|
|
8124
|
+
);
|
|
8052
8125
|
}
|
|
8053
8126
|
}
|
|
8054
8127
|
});
|
|
8055
|
-
|
|
8056
|
-
const
|
|
8057
|
-
for (const
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
const
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8128
|
+
debug5(`[${group.name}] Creating connections using connectivity keys`);
|
|
8129
|
+
const connectivityGroups = /* @__PURE__ */ new Map();
|
|
8130
|
+
for (const [chipId, chip] of Object.entries(problem.chipMap)) {
|
|
8131
|
+
for (const pinId of chip.pins) {
|
|
8132
|
+
const pinNumber = pinId.split(".").pop();
|
|
8133
|
+
const treeNode = tree.childNodes.find((child) => {
|
|
8134
|
+
if (child.nodeType === "component" && child.sourceComponent) {
|
|
8135
|
+
return child.sourceComponent.name === chipId;
|
|
8136
|
+
}
|
|
8137
|
+
if (child.nodeType === "group" && child.sourceGroup) {
|
|
8138
|
+
const expectedChipId = `group_${tree.childNodes.indexOf(child)}`;
|
|
8139
|
+
return expectedChipId === chipId;
|
|
8140
|
+
}
|
|
8141
|
+
return false;
|
|
8142
|
+
});
|
|
8143
|
+
if (treeNode?.nodeType === "group" && treeNode.sourceGroup) {
|
|
8144
|
+
const schematicGroup = db.schematic_group?.getWhere?.({
|
|
8145
|
+
source_group_id: treeNode.sourceGroup.source_group_id
|
|
8146
|
+
});
|
|
8147
|
+
if (schematicGroup) {
|
|
8148
|
+
const groupComponents = db.schematic_component.list({
|
|
8149
|
+
schematic_group_id: schematicGroup.schematic_group_id
|
|
8150
|
+
});
|
|
8151
|
+
for (const comp of groupComponents) {
|
|
8152
|
+
const sourcePorts = db.source_port.list({
|
|
8153
|
+
source_component_id: comp.source_component_id
|
|
8154
|
+
});
|
|
8155
|
+
for (const sourcePort of sourcePorts) {
|
|
8156
|
+
const portNumber = sourcePort.pin_number || sourcePort.name;
|
|
8157
|
+
if (String(portNumber) === String(pinNumber)) {
|
|
8158
|
+
if (sourcePort.subcircuit_connectivity_map_key) {
|
|
8159
|
+
const connectivityKey = sourcePort.subcircuit_connectivity_map_key;
|
|
8160
|
+
if (!connectivityGroups.has(connectivityKey)) {
|
|
8161
|
+
connectivityGroups.set(connectivityKey, []);
|
|
8162
|
+
}
|
|
8163
|
+
connectivityGroups.get(connectivityKey).push(pinId);
|
|
8164
|
+
debug5(
|
|
8165
|
+
`[${group.name}] \u2713 Pin ${pinId} has connectivity key: ${connectivityKey}`
|
|
8166
|
+
);
|
|
8167
|
+
} else {
|
|
8168
|
+
debug5(`[${group.name}] Pin ${pinId} has no connectivity key`);
|
|
8169
|
+
}
|
|
8170
|
+
}
|
|
8086
8171
|
}
|
|
8087
8172
|
}
|
|
8088
8173
|
}
|
|
8174
|
+
} else if (treeNode?.nodeType === "component" && treeNode.sourceComponent) {
|
|
8175
|
+
const sourcePorts = db.source_port.list({
|
|
8176
|
+
source_component_id: treeNode.sourceComponent.source_component_id
|
|
8177
|
+
});
|
|
8178
|
+
for (const sourcePort of sourcePorts) {
|
|
8179
|
+
const portNumber = sourcePort.pin_number || sourcePort.name;
|
|
8180
|
+
if (String(portNumber) === String(pinNumber) && sourcePort.subcircuit_connectivity_map_key) {
|
|
8181
|
+
const connectivityKey = sourcePort.subcircuit_connectivity_map_key;
|
|
8182
|
+
if (!connectivityGroups.has(connectivityKey)) {
|
|
8183
|
+
connectivityGroups.set(connectivityKey, []);
|
|
8184
|
+
}
|
|
8185
|
+
connectivityGroups.get(connectivityKey).push(pinId);
|
|
8186
|
+
debug5(
|
|
8187
|
+
`[${group.name}] Pin ${pinId} has connectivity key: ${connectivityKey}`
|
|
8188
|
+
);
|
|
8189
|
+
}
|
|
8190
|
+
}
|
|
8089
8191
|
}
|
|
8090
8192
|
}
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8193
|
+
}
|
|
8194
|
+
debug5(
|
|
8195
|
+
`[${group.name}] Found ${connectivityGroups.size} connectivity groups:`,
|
|
8196
|
+
Array.from(connectivityGroups.entries()).map(([key, pins]) => ({
|
|
8197
|
+
key,
|
|
8198
|
+
pins
|
|
8199
|
+
}))
|
|
8200
|
+
);
|
|
8201
|
+
for (const [connectivityKey, pins] of connectivityGroups) {
|
|
8202
|
+
if (pins.length >= 2) {
|
|
8203
|
+
const tracesWithThisKey = db.source_trace.list().filter(
|
|
8204
|
+
(trace) => trace.subcircuit_connectivity_map_key === connectivityKey
|
|
8205
|
+
);
|
|
8206
|
+
const hasNetConnections = tracesWithThisKey.some(
|
|
8207
|
+
(trace) => trace.connected_source_net_ids && trace.connected_source_net_ids.length > 0
|
|
8208
|
+
);
|
|
8209
|
+
const hasDirectConnections = tracesWithThisKey.some(
|
|
8210
|
+
(trace) => trace.connected_source_port_ids && trace.connected_source_port_ids.length >= 2
|
|
8211
|
+
);
|
|
8212
|
+
debug5(
|
|
8213
|
+
`[${group.name}] Connectivity ${connectivityKey}: hasNetConnections=${hasNetConnections}, hasDirectConnections=${hasDirectConnections}`
|
|
8214
|
+
);
|
|
8215
|
+
if (hasDirectConnections) {
|
|
8216
|
+
for (const trace of tracesWithThisKey) {
|
|
8217
|
+
if (trace.connected_source_port_ids && trace.connected_source_port_ids.length >= 2) {
|
|
8218
|
+
const directlyConnectedPins = [];
|
|
8219
|
+
for (const portId of trace.connected_source_port_ids) {
|
|
8220
|
+
for (const pinId of pins) {
|
|
8221
|
+
const pinNumber = pinId.split(".").pop();
|
|
8222
|
+
const sourcePort = db.source_port.get(portId);
|
|
8223
|
+
if (sourcePort && String(sourcePort.pin_number || sourcePort.name) === String(pinNumber)) {
|
|
8224
|
+
const chipId = pinId.split(".")[0];
|
|
8225
|
+
const treeNode = tree.childNodes.find((child) => {
|
|
8226
|
+
if (child.nodeType === "component" && child.sourceComponent) {
|
|
8227
|
+
return child.sourceComponent.name === chipId;
|
|
8228
|
+
}
|
|
8229
|
+
if (child.nodeType === "group" && child.sourceGroup) {
|
|
8230
|
+
const expectedChipId = `group_${tree.childNodes.indexOf(child)}`;
|
|
8231
|
+
return expectedChipId === chipId;
|
|
8232
|
+
}
|
|
8233
|
+
return false;
|
|
8234
|
+
});
|
|
8235
|
+
if (treeNode?.nodeType === "component" && treeNode.sourceComponent) {
|
|
8236
|
+
const portBelongsToComponent = db.source_port.list({
|
|
8237
|
+
source_component_id: treeNode.sourceComponent.source_component_id
|
|
8238
|
+
}).some((p) => p.source_port_id === portId);
|
|
8239
|
+
if (portBelongsToComponent) {
|
|
8240
|
+
directlyConnectedPins.push(pinId);
|
|
8241
|
+
}
|
|
8242
|
+
}
|
|
8243
|
+
}
|
|
8244
|
+
}
|
|
8245
|
+
}
|
|
8246
|
+
for (let i = 0; i < directlyConnectedPins.length; i++) {
|
|
8247
|
+
for (let j = i + 1; j < directlyConnectedPins.length; j++) {
|
|
8248
|
+
const pin1 = directlyConnectedPins[i];
|
|
8249
|
+
const pin2 = directlyConnectedPins[j];
|
|
8250
|
+
problem.pinStrongConnMap[`${pin1}-${pin2}`] = true;
|
|
8251
|
+
problem.pinStrongConnMap[`${pin2}-${pin1}`] = true;
|
|
8252
|
+
debug5(
|
|
8253
|
+
`[${group.name}] Created strong connection: ${pin1} <-> ${pin2}`
|
|
8254
|
+
);
|
|
8255
|
+
}
|
|
8256
|
+
}
|
|
8257
|
+
}
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
if (hasNetConnections) {
|
|
8261
|
+
problem.netMap[connectivityKey] = {
|
|
8262
|
+
netId: connectivityKey
|
|
8263
|
+
};
|
|
8264
|
+
for (const pinId of pins) {
|
|
8265
|
+
problem.netConnMap[`${pinId}-${connectivityKey}`] = true;
|
|
8266
|
+
}
|
|
8267
|
+
debug5(
|
|
8268
|
+
`[${group.name}] Created net ${connectivityKey} with ${pins.length} pins:`,
|
|
8269
|
+
pins
|
|
8270
|
+
);
|
|
8101
8271
|
}
|
|
8102
8272
|
}
|
|
8103
8273
|
}
|
|
@@ -8108,7 +8278,16 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
8108
8278
|
const tree = getCircuitJsonTree(db.toArray(), {
|
|
8109
8279
|
source_group_id: group.source_group_id
|
|
8110
8280
|
});
|
|
8111
|
-
|
|
8281
|
+
debug5(
|
|
8282
|
+
`[${group.name}] Starting matchpack layout with ${tree.childNodes.length} children`
|
|
8283
|
+
);
|
|
8284
|
+
debug5(`[${group.name}] Tree structure:`, JSON.stringify(tree, null, 2));
|
|
8285
|
+
if (tree.childNodes.length <= 1) {
|
|
8286
|
+
debug5(
|
|
8287
|
+
`[${group.name}] Only ${tree.childNodes.length} children, skipping layout`
|
|
8288
|
+
);
|
|
8289
|
+
return;
|
|
8290
|
+
}
|
|
8112
8291
|
debug5("Converting circuit tree to InputProblem...");
|
|
8113
8292
|
const inputProblem = convertTreeToInputProblem(tree, db, group);
|
|
8114
8293
|
debug5("InputProblem:", JSON.stringify(inputProblem, null, 2));
|
|
@@ -8130,6 +8309,7 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
8130
8309
|
}
|
|
8131
8310
|
const outputLayout = solver.getOutputLayout();
|
|
8132
8311
|
debug5("OutputLayout:", JSON.stringify(outputLayout, null, 2));
|
|
8312
|
+
debug5("Solver completed successfully:", !solver.failed);
|
|
8133
8313
|
if (debug5.enabled && global.debugGraphics) {
|
|
8134
8314
|
const finalViz = solver.visualize();
|
|
8135
8315
|
global.debugGraphics.push({
|
|
@@ -8148,20 +8328,44 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
8148
8328
|
}
|
|
8149
8329
|
const groupOffset = group._getGlobalSchematicPositionBeforeLayout();
|
|
8150
8330
|
debug5(`Group offset: x=${groupOffset.x}, y=${groupOffset.y}`);
|
|
8331
|
+
debug5(
|
|
8332
|
+
`Applying layout results for ${Object.keys(outputLayout.chipPlacements).length} chip placements`
|
|
8333
|
+
);
|
|
8151
8334
|
for (const [chipId, placement] of Object.entries(
|
|
8152
8335
|
outputLayout.chipPlacements
|
|
8153
8336
|
)) {
|
|
8337
|
+
debug5(
|
|
8338
|
+
`Processing placement for chip: ${chipId} at (${placement.x}, ${placement.y})`
|
|
8339
|
+
);
|
|
8154
8340
|
const treeNode = tree.childNodes.find((child) => {
|
|
8155
8341
|
if (child.nodeType === "component" && child.sourceComponent) {
|
|
8156
|
-
|
|
8342
|
+
const matches = child.sourceComponent.name === chipId;
|
|
8343
|
+
debug5(
|
|
8344
|
+
` Checking component ${child.sourceComponent.name}: matches=${matches}`
|
|
8345
|
+
);
|
|
8346
|
+
return matches;
|
|
8157
8347
|
}
|
|
8158
8348
|
if (child.nodeType === "group" && child.sourceGroup) {
|
|
8159
|
-
|
|
8349
|
+
const groupName = child.sourceGroup.name;
|
|
8350
|
+
const expectedChipId = `group_${tree.childNodes.indexOf(child)}`;
|
|
8351
|
+
const matches = expectedChipId === chipId;
|
|
8352
|
+
debug5(
|
|
8353
|
+
` Checking group ${groupName} (expected chipId: ${expectedChipId}): matches=${matches}`
|
|
8354
|
+
);
|
|
8355
|
+
return matches;
|
|
8160
8356
|
}
|
|
8161
8357
|
return false;
|
|
8162
8358
|
});
|
|
8163
8359
|
if (!treeNode) {
|
|
8164
8360
|
debug5(`Warning: No tree node found for chip: ${chipId}`);
|
|
8361
|
+
debug5(
|
|
8362
|
+
`Available tree nodes:`,
|
|
8363
|
+
tree.childNodes.map((child, idx) => ({
|
|
8364
|
+
type: child.nodeType,
|
|
8365
|
+
name: child.nodeType === "component" ? child.sourceComponent?.name : child.sourceGroup?.name,
|
|
8366
|
+
expectedChipId: child.nodeType === "group" ? `group_${idx}` : child.sourceComponent?.name
|
|
8367
|
+
}))
|
|
8368
|
+
);
|
|
8165
8369
|
continue;
|
|
8166
8370
|
}
|
|
8167
8371
|
const newCenter = {
|
|
@@ -8237,7 +8441,55 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
8237
8441
|
source_group_id: treeNode.sourceGroup.source_group_id
|
|
8238
8442
|
});
|
|
8239
8443
|
if (schematicGroup) {
|
|
8240
|
-
debug5(
|
|
8444
|
+
debug5(
|
|
8445
|
+
`Moving group ${chipId} to (${newCenter.x}, ${newCenter.y}) from (${schematicGroup.center?.x}, ${schematicGroup.center?.y})`
|
|
8446
|
+
);
|
|
8447
|
+
const groupComponents = db.schematic_component.list({
|
|
8448
|
+
schematic_group_id: schematicGroup.schematic_group_id
|
|
8449
|
+
});
|
|
8450
|
+
debug5(
|
|
8451
|
+
`Group ${chipId} has ${groupComponents.length} components to move`
|
|
8452
|
+
);
|
|
8453
|
+
const oldCenter = schematicGroup.center || { x: 0, y: 0 };
|
|
8454
|
+
const positionDelta = {
|
|
8455
|
+
x: newCenter.x - oldCenter.x,
|
|
8456
|
+
y: newCenter.y - oldCenter.y
|
|
8457
|
+
};
|
|
8458
|
+
debug5(
|
|
8459
|
+
`Position delta for group ${chipId}: (${positionDelta.x}, ${positionDelta.y})`
|
|
8460
|
+
);
|
|
8461
|
+
for (const component of groupComponents) {
|
|
8462
|
+
if (component.center) {
|
|
8463
|
+
const oldComponentCenter = { ...component.center };
|
|
8464
|
+
component.center.x += positionDelta.x;
|
|
8465
|
+
component.center.y += positionDelta.y;
|
|
8466
|
+
debug5(
|
|
8467
|
+
`Moved component ${component.source_component_id} from (${oldComponentCenter.x}, ${oldComponentCenter.y}) to (${component.center.x}, ${component.center.y})`
|
|
8468
|
+
);
|
|
8469
|
+
const ports = db.schematic_port.list({
|
|
8470
|
+
schematic_component_id: component.schematic_component_id
|
|
8471
|
+
});
|
|
8472
|
+
const texts = db.schematic_text.list({
|
|
8473
|
+
schematic_component_id: component.schematic_component_id
|
|
8474
|
+
});
|
|
8475
|
+
for (const port of ports) {
|
|
8476
|
+
if (port.center) {
|
|
8477
|
+
port.center.x += positionDelta.x;
|
|
8478
|
+
port.center.y += positionDelta.y;
|
|
8479
|
+
}
|
|
8480
|
+
}
|
|
8481
|
+
for (const text of texts) {
|
|
8482
|
+
if (text.position) {
|
|
8483
|
+
text.position.x += positionDelta.x;
|
|
8484
|
+
text.position.y += positionDelta.y;
|
|
8485
|
+
}
|
|
8486
|
+
}
|
|
8487
|
+
}
|
|
8488
|
+
}
|
|
8489
|
+
schematicGroup.center = newCenter;
|
|
8490
|
+
debug5(
|
|
8491
|
+
`Updated group ${chipId} center to (${newCenter.x}, ${newCenter.y})`
|
|
8492
|
+
);
|
|
8241
8493
|
}
|
|
8242
8494
|
}
|
|
8243
8495
|
}
|
|
@@ -9407,14 +9659,11 @@ var Group = class extends NormalComponent {
|
|
|
9407
9659
|
const cProps = child._parsedProps;
|
|
9408
9660
|
return cProps?.schX !== void 0 || cProps?.schY !== void 0;
|
|
9409
9661
|
});
|
|
9410
|
-
const anyChildIsGroup = this.children.some((child) => child.isGroup);
|
|
9411
9662
|
const hasManualEdits = (props.manualEdits?.schematic_placements?.length ?? 0) > 0;
|
|
9412
|
-
if (!anyChildHasSchCoords && !hasManualEdits
|
|
9413
|
-
return "match-adapt";
|
|
9663
|
+
if (!anyChildHasSchCoords && !hasManualEdits) return "match-adapt";
|
|
9414
9664
|
return "relative";
|
|
9415
9665
|
}
|
|
9416
9666
|
doInitialSchematicLayout() {
|
|
9417
|
-
const props = this._parsedProps;
|
|
9418
9667
|
const schematicLayoutMode = this._getSchematicLayoutMode();
|
|
9419
9668
|
if (schematicLayoutMode === "match-adapt") {
|
|
9420
9669
|
this._doInitialSchematicLayoutMatchpack();
|
|
@@ -9819,6 +10068,18 @@ var Capacitor = class extends NormalComponent {
|
|
|
9819
10068
|
sourceFtype: FTYPE.simple_capacitor
|
|
9820
10069
|
};
|
|
9821
10070
|
}
|
|
10071
|
+
initPorts() {
|
|
10072
|
+
if (typeof this.props.footprint === "string") {
|
|
10073
|
+
super.initPorts({
|
|
10074
|
+
additionalAliases: {
|
|
10075
|
+
pin1: ["anode", "pos"],
|
|
10076
|
+
pin2: ["cathode", "neg"]
|
|
10077
|
+
}
|
|
10078
|
+
});
|
|
10079
|
+
} else {
|
|
10080
|
+
super.initPorts();
|
|
10081
|
+
}
|
|
10082
|
+
}
|
|
9822
10083
|
_getSchematicSymbolDisplayValue() {
|
|
9823
10084
|
const capacitanceDisplay = `${formatSiUnit(this._parsedProps.capacitance)}F`;
|
|
9824
10085
|
if (this._parsedProps.schShowRatings && this._parsedProps.maxVoltageRating) {
|
|
@@ -12064,7 +12325,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
12064
12325
|
var package_default = {
|
|
12065
12326
|
name: "@tscircuit/core",
|
|
12066
12327
|
type: "module",
|
|
12067
|
-
version: "0.0.
|
|
12328
|
+
version: "0.0.625",
|
|
12068
12329
|
types: "dist/index.d.ts",
|
|
12069
12330
|
main: "dist/index.js",
|
|
12070
12331
|
module: "dist/index.js",
|