@tscircuit/cli 0.1.1930 → 0.1.1931
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/cli/main.js +141 -1
- package/dist/lib/index.js +1 -1
- package/package.json +2 -2
package/dist/cli/main.js
CHANGED
|
@@ -136059,7 +136059,7 @@ var package_default = {
|
|
|
136059
136059
|
"@tscircuit/check-shorts": "https://jscdn.tscircuit.com/@tscircuit/check-shorts/0.0.19.tgz",
|
|
136060
136060
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.9",
|
|
136061
136061
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.8",
|
|
136062
|
-
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#
|
|
136062
|
+
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#2bfa85c47dd0bd0d360b85083980170c01d3afca",
|
|
136063
136063
|
"@tscircuit/circuit-json-util": "^0.0.105",
|
|
136064
136064
|
"@tscircuit/eval": "^0.0.1016",
|
|
136065
136065
|
"@tscircuit/fake-snippets": "^0.0.182",
|
|
@@ -303287,6 +303287,141 @@ class ComponentNetLabelCollisionSolver extends BaseSolver13 {
|
|
|
303287
303287
|
}
|
|
303288
303288
|
}
|
|
303289
303289
|
|
|
303290
|
+
// node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/solvers/ComponentPinAlignmentSolver/ComponentPinAlignmentSolver.ts
|
|
303291
|
+
import { BaseSolver as BaseSolver14 } from "@tscircuit/solver-utils";
|
|
303292
|
+
class ComponentPinAlignmentSolver extends BaseSolver14 {
|
|
303293
|
+
static ALIGNMENT_EPSILON = 0.01;
|
|
303294
|
+
ctx;
|
|
303295
|
+
out;
|
|
303296
|
+
constructor({
|
|
303297
|
+
ctx,
|
|
303298
|
+
issues
|
|
303299
|
+
}) {
|
|
303300
|
+
super();
|
|
303301
|
+
this.ctx = ctx;
|
|
303302
|
+
this.out = issues;
|
|
303303
|
+
}
|
|
303304
|
+
_step() {
|
|
303305
|
+
const portsById = new Map(this.ctx.circuitJson.filter((el3) => el3.type === "schematic_port").map((port) => [port.schematic_port_id, port]));
|
|
303306
|
+
const placementBySchematicComponentId = new Map(this.ctx.componentPlacements.flatMap((placement) => placement.schematicComponentId ? [[placement.schematicComponentId, placement]] : []));
|
|
303307
|
+
const pinPairsByComponentPair = new Map;
|
|
303308
|
+
for (const trace of this.ctx.circuitJson.filter((el3) => el3.type === "schematic_trace")) {
|
|
303309
|
+
const pinPair = this.getTracePinPair(trace, portsById);
|
|
303310
|
+
if (!pinPair)
|
|
303311
|
+
continue;
|
|
303312
|
+
const firstComponentId = pinPair.firstPort.schematic_component_id;
|
|
303313
|
+
const secondComponentId = pinPair.secondPort.schematic_component_id;
|
|
303314
|
+
if (!firstComponentId || !secondComponentId || firstComponentId === secondComponentId) {
|
|
303315
|
+
continue;
|
|
303316
|
+
}
|
|
303317
|
+
const orderedPair = firstComponentId < secondComponentId ? pinPair : {
|
|
303318
|
+
firstPort: pinPair.secondPort,
|
|
303319
|
+
secondPort: pinPair.firstPort
|
|
303320
|
+
};
|
|
303321
|
+
const key = [firstComponentId, secondComponentId].sort().join("\x00");
|
|
303322
|
+
const pairs3 = pinPairsByComponentPair.get(key) ?? [];
|
|
303323
|
+
const isDuplicate = pairs3.some((pair) => pair.firstPort.schematic_port_id === orderedPair.firstPort.schematic_port_id && pair.secondPort.schematic_port_id === orderedPair.secondPort.schematic_port_id);
|
|
303324
|
+
if (!isDuplicate)
|
|
303325
|
+
pairs3.push(orderedPair);
|
|
303326
|
+
pinPairsByComponentPair.set(key, pairs3);
|
|
303327
|
+
}
|
|
303328
|
+
for (const pinPairs of pinPairsByComponentPair.values()) {
|
|
303329
|
+
const issue = this.findVerticalShiftIssue(pinPairs, placementBySchematicComponentId);
|
|
303330
|
+
if (issue)
|
|
303331
|
+
this.out.push(issue);
|
|
303332
|
+
}
|
|
303333
|
+
this.solved = true;
|
|
303334
|
+
}
|
|
303335
|
+
getTracePinPair(trace, portsById) {
|
|
303336
|
+
const firstEdge = trace.edges?.[0];
|
|
303337
|
+
const lastEdge = trace.edges?.at(-1);
|
|
303338
|
+
if (!firstEdge || !lastEdge)
|
|
303339
|
+
return;
|
|
303340
|
+
const firstPortId = firstEdge.from_schematic_port_id ?? firstEdge.to_schematic_port_id;
|
|
303341
|
+
const secondPortId = lastEdge.to_schematic_port_id ?? lastEdge.from_schematic_port_id;
|
|
303342
|
+
const ports = [...portsById.values()];
|
|
303343
|
+
const firstPort = firstPortId ? portsById.get(firstPortId) : this.findPortAtPoint(ports, firstEdge.from, trace.schematic_sheet_id);
|
|
303344
|
+
const secondPort = secondPortId ? portsById.get(secondPortId) : this.findPortAtPoint(ports, lastEdge.to, trace.schematic_sheet_id);
|
|
303345
|
+
if (!firstPort || !secondPort)
|
|
303346
|
+
return;
|
|
303347
|
+
if (firstPort.schematic_port_id === secondPort.schematic_port_id)
|
|
303348
|
+
return;
|
|
303349
|
+
if (firstPort.schematic_sheet_id !== secondPort.schematic_sheet_id)
|
|
303350
|
+
return;
|
|
303351
|
+
return { firstPort, secondPort };
|
|
303352
|
+
}
|
|
303353
|
+
findPortAtPoint(ports, point9, schematicSheetId) {
|
|
303354
|
+
const { ALIGNMENT_EPSILON } = ComponentPinAlignmentSolver;
|
|
303355
|
+
return ports.find((port) => port.schematic_sheet_id === schematicSheetId && Math.abs(port.center.x - point9.x) <= ALIGNMENT_EPSILON && Math.abs(port.center.y - point9.y) <= ALIGNMENT_EPSILON);
|
|
303356
|
+
}
|
|
303357
|
+
findVerticalShiftIssue(pinPairs, placementBySchematicComponentId) {
|
|
303358
|
+
const firstPair = pinPairs[0];
|
|
303359
|
+
if (!firstPair)
|
|
303360
|
+
return;
|
|
303361
|
+
const firstPlacement = placementBySchematicComponentId.get(firstPair.firstPort.schematic_component_id);
|
|
303362
|
+
const secondPlacement = placementBySchematicComponentId.get(firstPair.secondPort.schematic_component_id);
|
|
303363
|
+
if (!firstPlacement || !secondPlacement)
|
|
303364
|
+
return;
|
|
303365
|
+
const [leftPlacement, rightPlacement] = firstPlacement.schX <= secondPlacement.schX ? [firstPlacement, secondPlacement] : [secondPlacement, firstPlacement];
|
|
303366
|
+
const horizontalPairs = pinPairs.flatMap((pair) => {
|
|
303367
|
+
const [leftPort, rightPort] = pair.firstPort.center.x <= pair.secondPort.center.x ? [pair.firstPort, pair.secondPort] : [pair.secondPort, pair.firstPort];
|
|
303368
|
+
return leftPort.facing_direction === "right" && rightPort.facing_direction === "left" ? [{ leftPort, rightPort }] : [];
|
|
303369
|
+
});
|
|
303370
|
+
if (horizontalPairs.length < 2)
|
|
303371
|
+
return;
|
|
303372
|
+
const { ALIGNMENT_EPSILON } = ComponentPinAlignmentSolver;
|
|
303373
|
+
const currentlyAlignedPinCount = horizontalPairs.filter(({ leftPort, rightPort }) => Math.abs(leftPort.center.y - rightPort.center.y) <= ALIGNMENT_EPSILON).length;
|
|
303374
|
+
const candidateGroups = [];
|
|
303375
|
+
for (const pair of horizontalPairs) {
|
|
303376
|
+
const deltaSchY2 = pair.leftPort.center.y - pair.rightPort.center.y;
|
|
303377
|
+
if (Math.abs(deltaSchY2) <= ALIGNMENT_EPSILON)
|
|
303378
|
+
continue;
|
|
303379
|
+
const group = candidateGroups.find((candidate) => Math.abs(candidate.deltaSchY - deltaSchY2) <= ALIGNMENT_EPSILON);
|
|
303380
|
+
if (group)
|
|
303381
|
+
group.pairs.push(pair);
|
|
303382
|
+
else
|
|
303383
|
+
candidateGroups.push({ deltaSchY: deltaSchY2, pairs: [pair] });
|
|
303384
|
+
}
|
|
303385
|
+
const bestCandidate = candidateGroups.sort((a2, b3) => b3.pairs.length - a2.pairs.length || Math.abs(a2.deltaSchY) - Math.abs(b3.deltaSchY))[0];
|
|
303386
|
+
if (!bestCandidate || bestCandidate.pairs.length < 2 || bestCandidate.pairs.length <= currentlyAlignedPinCount) {
|
|
303387
|
+
return;
|
|
303388
|
+
}
|
|
303389
|
+
const targetName = rightPlacement.sourceComponentName ?? rightPlacement.schematicComponentId ?? "component";
|
|
303390
|
+
const deltaSchY = bestCandidate.deltaSchY;
|
|
303391
|
+
const newSchY = rightPlacement.schY + deltaSchY;
|
|
303392
|
+
return {
|
|
303393
|
+
lineItemType: "ComponentPinsWouldAlignWithVerticalShift",
|
|
303394
|
+
firstComponent: leftPlacement,
|
|
303395
|
+
secondComponent: rightPlacement,
|
|
303396
|
+
targetComponent: rightPlacement,
|
|
303397
|
+
deltaSchY,
|
|
303398
|
+
newSchY,
|
|
303399
|
+
currentlyAlignedPinCount,
|
|
303400
|
+
alignedPinCount: bestCandidate.pairs.length,
|
|
303401
|
+
alignedPinPairs: bestCandidate.pairs.map(({ leftPort, rightPort }) => ({
|
|
303402
|
+
firstPin: this.getPinLabel(leftPort),
|
|
303403
|
+
secondPin: this.getPinLabel(rightPort)
|
|
303404
|
+
})),
|
|
303405
|
+
message: `shift ${targetName} vertically by ${fmtDelta(deltaSchY)} to align ${bestCandidate.pairs.length} connected pin pairs`
|
|
303406
|
+
};
|
|
303407
|
+
}
|
|
303408
|
+
getPinLabel(port) {
|
|
303409
|
+
return port.display_pin_label ?? port.pin_number?.toString();
|
|
303410
|
+
}
|
|
303411
|
+
static issueToString(issue) {
|
|
303412
|
+
const attrs = [];
|
|
303413
|
+
addAttr(attrs, "firstComponentName", issue.firstComponent.sourceComponentName);
|
|
303414
|
+
addAttr(attrs, "secondComponentName", issue.secondComponent.sourceComponentName);
|
|
303415
|
+
addAttr(attrs, "targetComponentName", issue.targetComponent.sourceComponentName);
|
|
303416
|
+
addAttr(attrs, "deltaSchY", issue.deltaSchY);
|
|
303417
|
+
addAttr(attrs, "newSchY", issue.newSchY);
|
|
303418
|
+
addAttr(attrs, "currentlyAlignedPinCount", issue.currentlyAlignedPinCount);
|
|
303419
|
+
addAttr(attrs, "alignedPinCount", issue.alignedPinCount);
|
|
303420
|
+
addAttr(attrs, "message", issue.message);
|
|
303421
|
+
return `<ComponentPinsWouldAlignWithVerticalShift ${attrs.join(" ")} />`;
|
|
303422
|
+
}
|
|
303423
|
+
}
|
|
303424
|
+
|
|
303290
303425
|
// node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/solvers/SchematicPlacementPipeline/SchematicPlacementPipeline.ts
|
|
303291
303426
|
class SchematicPlacementPipeline extends BasePipelineSolver2 {
|
|
303292
303427
|
ctx;
|
|
@@ -303313,6 +303448,9 @@ class SchematicPlacementPipeline extends BasePipelineSolver2 {
|
|
|
303313
303448
|
definePipelineStep3("DiodeResistorAlignmentSolver", DiodeResistorAlignmentSolver, (p3) => [
|
|
303314
303449
|
{ ctx: p3.ctx, issues: p3.issues }
|
|
303315
303450
|
]),
|
|
303451
|
+
definePipelineStep3("ComponentPinAlignmentSolver", ComponentPinAlignmentSolver, (p3) => [
|
|
303452
|
+
{ ctx: p3.ctx, issues: p3.issues }
|
|
303453
|
+
]),
|
|
303316
303454
|
definePipelineStep3("ComponentNetLabelCollisionSolver", ComponentNetLabelCollisionSolver, (p3) => [
|
|
303317
303455
|
{ ctx: p3.ctx, issues: p3.issues }
|
|
303318
303456
|
])
|
|
@@ -303368,6 +303506,8 @@ class SchematicPlacementAnalysis {
|
|
|
303368
303506
|
return SchematicPinPaddingToEdgeSolver.issueToString(issue);
|
|
303369
303507
|
case "DiodeResistorNotAligned":
|
|
303370
303508
|
return DiodeResistorAlignmentSolver.issueToString(issue);
|
|
303509
|
+
case "ComponentPinsWouldAlignWithVerticalShift":
|
|
303510
|
+
return ComponentPinAlignmentSolver.issueToString(issue);
|
|
303371
303511
|
case "NetLabelCollision":
|
|
303372
303512
|
return ComponentNetLabelCollisionSolver.netLabelCollisionToString(issue);
|
|
303373
303513
|
default:
|
package/dist/lib/index.js
CHANGED
|
@@ -65772,7 +65772,7 @@ var package_default = {
|
|
|
65772
65772
|
"@tscircuit/check-shorts": "https://jscdn.tscircuit.com/@tscircuit/check-shorts/0.0.19.tgz",
|
|
65773
65773
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.9",
|
|
65774
65774
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.8",
|
|
65775
|
-
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#
|
|
65775
|
+
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#2bfa85c47dd0bd0d360b85083980170c01d3afca",
|
|
65776
65776
|
"@tscircuit/circuit-json-util": "^0.0.105",
|
|
65777
65777
|
"@tscircuit/eval": "^0.0.1016",
|
|
65778
65778
|
"@tscircuit/fake-snippets": "^0.0.182",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1931",
|
|
4
4
|
"main": "dist/cli/main.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/cli/main.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@tscircuit/check-shorts": "https://jscdn.tscircuit.com/@tscircuit/check-shorts/0.0.19.tgz",
|
|
13
13
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.9",
|
|
14
14
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.8",
|
|
15
|
-
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#
|
|
15
|
+
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#2bfa85c47dd0bd0d360b85083980170c01d3afca",
|
|
16
16
|
"@tscircuit/circuit-json-util": "^0.0.105",
|
|
17
17
|
"@tscircuit/eval": "^0.0.1016",
|
|
18
18
|
"@tscircuit/fake-snippets": "^0.0.182",
|