@tscircuit/cli 0.1.1434 → 0.1.1436
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 +358 -4
- package/dist/lib/index.js +4 -3
- package/package.json +2 -2
package/dist/cli/main.js
CHANGED
|
@@ -100688,7 +100688,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
100688
100688
|
// lib/getVersion.ts
|
|
100689
100689
|
import { createRequire as createRequire2 } from "node:module";
|
|
100690
100690
|
// package.json
|
|
100691
|
-
var version = "0.1.
|
|
100691
|
+
var version = "0.1.1435";
|
|
100692
100692
|
var package_default = {
|
|
100693
100693
|
name: "@tscircuit/cli",
|
|
100694
100694
|
version,
|
|
@@ -100702,7 +100702,7 @@ var package_default = {
|
|
|
100702
100702
|
"@biomejs/biome": "^1.9.4",
|
|
100703
100703
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.6",
|
|
100704
100704
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.1",
|
|
100705
|
-
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#
|
|
100705
|
+
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#40f49bb8ae9dabedb19b47ec0a621c713b40615c",
|
|
100706
100706
|
"@tscircuit/eval": "^0.0.835",
|
|
100707
100707
|
"@tscircuit/fake-snippets": "^0.0.182",
|
|
100708
100708
|
"@tscircuit/file-server": "^0.0.32",
|
|
@@ -104200,8 +104200,9 @@ var prettyResponseErrorHook = async (request, _options, response) => {
|
|
|
104200
104200
|
const apiError = errorData?.error;
|
|
104201
104201
|
const errorString = apiError ? `
|
|
104202
104202
|
${apiError.error_code}: ${apiError.message}` : "";
|
|
104203
|
+
const sessionExpiredAdvice = request.headers.has("Authorization") && /session_expired|token_expired|expired_session/i.test(apiError?.error_code ?? "") ? "\n\nYour tscircuit session has expired. Run `tsci logout`, then `tsci login` to log back in." : "";
|
|
104203
104204
|
const bodyDisplay = errorData ? JSON.stringify(errorData, null, 2) : responseText.slice(0, 20);
|
|
104204
|
-
throw new PrettyHttpError(`FAIL [${response.status}]: ${request.method} ${new URL(request.url).pathname}${errorString}${requestBody ? `
|
|
104205
|
+
throw new PrettyHttpError(`FAIL [${response.status}]: ${request.method} ${new URL(request.url).pathname}${errorString}${sessionExpiredAdvice}${requestBody ? `
|
|
104205
104206
|
|
|
104206
104207
|
Request Body:
|
|
104207
104208
|
${requestBody}` : ""}
|
|
@@ -244585,6 +244586,7 @@ var addAttr = (attrs, key, value, options) => {
|
|
|
244585
244586
|
|
|
244586
244587
|
// node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/solvers/CapacitorOrientationSolver/CapacitorOrientationSolver.ts
|
|
244587
244588
|
class CapacitorOrientationSolver extends BaseSolver6 {
|
|
244589
|
+
static ORIENTATION_MESSAGE = 'Use schOrientation="vertical" on this capacitor to fix the symbol orientation';
|
|
244588
244590
|
ctx;
|
|
244589
244591
|
out;
|
|
244590
244592
|
schematicComponentById;
|
|
@@ -244681,7 +244683,8 @@ class CapacitorOrientationSolver extends BaseSolver6 {
|
|
|
244681
244683
|
return;
|
|
244682
244684
|
return {
|
|
244683
244685
|
lineItemType: "CapacitorSymbolHorizontal",
|
|
244684
|
-
schematicBox: this.createIssuePlacement(placement)
|
|
244686
|
+
schematicBox: this.createIssuePlacement(placement),
|
|
244687
|
+
message: CapacitorOrientationSolver.ORIENTATION_MESSAGE
|
|
244685
244688
|
};
|
|
244686
244689
|
}
|
|
244687
244690
|
static issueToString(issue) {
|
|
@@ -244691,6 +244694,7 @@ class CapacitorOrientationSolver extends BaseSolver6 {
|
|
|
244691
244694
|
addAttr(attrs, "schY", issue.schematicBox.schY);
|
|
244692
244695
|
addAttr(attrs, "width", issue.schematicBox.width);
|
|
244693
244696
|
addAttr(attrs, "height", issue.schematicBox.height);
|
|
244697
|
+
addAttr(attrs, "message", issue.message, { escape: false });
|
|
244694
244698
|
return `<CapacitorSymbolHorizontal ${attrs.join(" ")} />`;
|
|
244695
244699
|
}
|
|
244696
244700
|
}
|
|
@@ -244835,6 +244839,8 @@ class SchematicBoxInnerLabelCollisionSolver extends BaseSolver9 {
|
|
|
244835
244839
|
this.placementById = this.getPlacementBySchematicComponentId(componentPlacements);
|
|
244836
244840
|
this.sourcePortById = this.getSourcePortById(circuitJson);
|
|
244837
244841
|
this.entries = Array.from(this.getPortsBySchematicComponentId(circuitJson));
|
|
244842
|
+
const passiveComponentIds = new Set(circuitJson.filter((el3) => el3.type === "schematic_component").filter((el3) => el3.symbol_name).map((el3) => el3.schematic_component_id));
|
|
244843
|
+
this.entries = this.entries.filter(([id2]) => !passiveComponentIds.has(id2));
|
|
244838
244844
|
this.solved = this.entries.length === 0;
|
|
244839
244845
|
}
|
|
244840
244846
|
_step() {
|
|
@@ -245676,6 +245682,349 @@ class DiodeResistorAlignmentSolver extends BaseSolver13 {
|
|
|
245676
245682
|
}
|
|
245677
245683
|
}
|
|
245678
245684
|
|
|
245685
|
+
// node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/solvers/ComponentNetLabelCollisionSolver/ComponentNetLabelCollisionSolver.ts
|
|
245686
|
+
import { BaseSolver as BaseSolver14 } from "@tscircuit/solver-utils";
|
|
245687
|
+
|
|
245688
|
+
// node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/utils/geometry.ts
|
|
245689
|
+
function centeredRect(cx2, cy2, w4, h4) {
|
|
245690
|
+
return {
|
|
245691
|
+
left: cx2 - w4 / 2,
|
|
245692
|
+
right: cx2 + w4 / 2,
|
|
245693
|
+
top: cy2 + h4 / 2,
|
|
245694
|
+
bottom: cy2 - h4 / 2
|
|
245695
|
+
};
|
|
245696
|
+
}
|
|
245697
|
+
function rectOverlap(a2, b) {
|
|
245698
|
+
const ow = Math.min(a2.right, b.right) - Math.max(a2.left, b.left);
|
|
245699
|
+
const oh2 = Math.min(a2.top, b.top) - Math.max(a2.bottom, b.bottom);
|
|
245700
|
+
return ow > 0 && oh2 > 0 ? { ow, oh: oh2 } : null;
|
|
245701
|
+
}
|
|
245702
|
+
|
|
245703
|
+
// node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/solvers/ComponentNetLabelCollisionSolver/ComponentNetLabelCollisionSolver.ts
|
|
245704
|
+
class ComponentNetLabelCollisionSolver extends BaseSolver14 {
|
|
245705
|
+
params;
|
|
245706
|
+
LABEL_HALF_HEIGHT = 0.1;
|
|
245707
|
+
LABEL_BOUNDS_SLACK = 0.1;
|
|
245708
|
+
SCH_CHAR_WIDTH = 0.13;
|
|
245709
|
+
placements;
|
|
245710
|
+
netLabelsByComponentId;
|
|
245711
|
+
rawCollisions = [];
|
|
245712
|
+
firstIndex = 0;
|
|
245713
|
+
secondIndex = 1;
|
|
245714
|
+
constructor(params2) {
|
|
245715
|
+
super();
|
|
245716
|
+
this.params = params2;
|
|
245717
|
+
this.placements = params2.ctx.componentPlacements;
|
|
245718
|
+
this.netLabelsByComponentId = this.buildNetLabelsByComponentId(params2.ctx.circuitJson);
|
|
245719
|
+
this.solved = this.placements.length < 2;
|
|
245720
|
+
}
|
|
245721
|
+
_step() {
|
|
245722
|
+
if (this.firstIndex >= this.placements.length - 1) {
|
|
245723
|
+
this.buildAndPushIssues();
|
|
245724
|
+
this.solved = true;
|
|
245725
|
+
return;
|
|
245726
|
+
}
|
|
245727
|
+
const compA = this.placements[this.firstIndex];
|
|
245728
|
+
const compB = this.placements[this.secondIndex];
|
|
245729
|
+
this.detectPair(compA, compB);
|
|
245730
|
+
this.secondIndex++;
|
|
245731
|
+
if (this.secondIndex >= this.placements.length) {
|
|
245732
|
+
this.firstIndex++;
|
|
245733
|
+
this.secondIndex = this.firstIndex + 1;
|
|
245734
|
+
}
|
|
245735
|
+
}
|
|
245736
|
+
detectPair(compA, compB) {
|
|
245737
|
+
this.rawCollisions.push(...this.detectLabelLabel(compA, compB));
|
|
245738
|
+
this.rawCollisions.push(...this.detectBoxLabel(compA, compB));
|
|
245739
|
+
this.rawCollisions.push(...this.detectBoxLabel(compB, compA));
|
|
245740
|
+
}
|
|
245741
|
+
detectLabelLabel(firstComponent, secondComponent) {
|
|
245742
|
+
let leftComp = firstComponent;
|
|
245743
|
+
let rightComp = secondComponent;
|
|
245744
|
+
if (firstComponent.schX > secondComponent.schX) {
|
|
245745
|
+
leftComp = secondComponent;
|
|
245746
|
+
rightComp = firstComponent;
|
|
245747
|
+
}
|
|
245748
|
+
const leftId = leftComp.schematicComponentId;
|
|
245749
|
+
const rightId = rightComp.schematicComponentId;
|
|
245750
|
+
if (!leftId || !rightId)
|
|
245751
|
+
return [];
|
|
245752
|
+
const leftLabels = this.netLabelsByComponentId.get(leftId) ?? [];
|
|
245753
|
+
const rightLabels = this.netLabelsByComponentId.get(rightId) ?? [];
|
|
245754
|
+
if (leftLabels.length === 0 || rightLabels.length === 0)
|
|
245755
|
+
return [];
|
|
245756
|
+
const hits = [];
|
|
245757
|
+
for (const leftLabel of leftLabels) {
|
|
245758
|
+
for (const rightLabel of rightLabels) {
|
|
245759
|
+
const leftBounds = this.getNetLabelBounds(leftLabel);
|
|
245760
|
+
const rightBounds = this.getNetLabelBounds(rightLabel);
|
|
245761
|
+
if (rectOverlap(leftBounds, rightBounds)) {
|
|
245762
|
+
hits.push({
|
|
245763
|
+
type: "label-label",
|
|
245764
|
+
leftComp,
|
|
245765
|
+
rightComp,
|
|
245766
|
+
leftId,
|
|
245767
|
+
rightId,
|
|
245768
|
+
xSeparation: leftBounds.right - rightBounds.left + 0.1
|
|
245769
|
+
});
|
|
245770
|
+
}
|
|
245771
|
+
}
|
|
245772
|
+
}
|
|
245773
|
+
return hits;
|
|
245774
|
+
}
|
|
245775
|
+
detectBoxLabel(boxComp, labelComp) {
|
|
245776
|
+
const boxId = boxComp.schematicComponentId;
|
|
245777
|
+
const labelId = labelComp.schematicComponentId;
|
|
245778
|
+
if (!boxId || !labelId)
|
|
245779
|
+
return [];
|
|
245780
|
+
const labels = this.netLabelsByComponentId.get(labelId) ?? [];
|
|
245781
|
+
if (labels.length === 0)
|
|
245782
|
+
return [];
|
|
245783
|
+
const boxBounds = centeredRect(boxComp.schX, boxComp.schY, boxComp.width, boxComp.height);
|
|
245784
|
+
const boxIsLeft = boxComp.schX <= labelComp.schX;
|
|
245785
|
+
const hits = [];
|
|
245786
|
+
for (const label of labels) {
|
|
245787
|
+
const labelBounds = this.getNetLabelBounds(label);
|
|
245788
|
+
if (!rectOverlap(boxBounds, labelBounds))
|
|
245789
|
+
continue;
|
|
245790
|
+
let xSeparation;
|
|
245791
|
+
if (boxIsLeft) {
|
|
245792
|
+
xSeparation = boxBounds.right - labelBounds.left + 0.1;
|
|
245793
|
+
} else {
|
|
245794
|
+
xSeparation = labelBounds.right - boxBounds.left + 0.1;
|
|
245795
|
+
}
|
|
245796
|
+
hits.push({
|
|
245797
|
+
type: "box-label",
|
|
245798
|
+
boxComp,
|
|
245799
|
+
labelComp,
|
|
245800
|
+
boxId,
|
|
245801
|
+
labelId,
|
|
245802
|
+
xSeparation
|
|
245803
|
+
});
|
|
245804
|
+
}
|
|
245805
|
+
return hits;
|
|
245806
|
+
}
|
|
245807
|
+
buildAndPushIssues() {
|
|
245808
|
+
if (this.rawCollisions.length === 0)
|
|
245809
|
+
return;
|
|
245810
|
+
const globalFixes = this.computeGlobalFixes();
|
|
245811
|
+
if (globalFixes.size === 0)
|
|
245812
|
+
return;
|
|
245813
|
+
const seenPairs = new Set;
|
|
245814
|
+
const pairs3 = [];
|
|
245815
|
+
for (const collision of this.rawCollisions) {
|
|
245816
|
+
let comp1Name;
|
|
245817
|
+
let comp2Name;
|
|
245818
|
+
if (collision.type === "label-label") {
|
|
245819
|
+
comp1Name = collision.leftComp.sourceComponentName ?? "";
|
|
245820
|
+
comp2Name = collision.rightComp.sourceComponentName ?? "";
|
|
245821
|
+
} else {
|
|
245822
|
+
comp1Name = collision.boxComp.sourceComponentName ?? "";
|
|
245823
|
+
comp2Name = collision.labelComp.sourceComponentName ?? "";
|
|
245824
|
+
}
|
|
245825
|
+
const key = `${comp1Name}/${comp2Name}`;
|
|
245826
|
+
if (!seenPairs.has(key)) {
|
|
245827
|
+
seenPairs.add(key);
|
|
245828
|
+
pairs3.push({ comp1Name, comp2Name });
|
|
245829
|
+
}
|
|
245830
|
+
}
|
|
245831
|
+
this.params.issues.push({
|
|
245832
|
+
lineItemType: "NetLabelCollision",
|
|
245833
|
+
pairs: pairs3,
|
|
245834
|
+
moves: Array.from(globalFixes.values())
|
|
245835
|
+
});
|
|
245836
|
+
}
|
|
245837
|
+
computeGlobalFixes() {
|
|
245838
|
+
const compById = new Map;
|
|
245839
|
+
for (const placement of this.placements) {
|
|
245840
|
+
if (placement.schematicComponentId)
|
|
245841
|
+
compById.set(placement.schematicComponentId, placement);
|
|
245842
|
+
}
|
|
245843
|
+
const constraintMap = new Map;
|
|
245844
|
+
const addConstraint = (leftId, rightId, xSeparation) => {
|
|
245845
|
+
const leftComp = compById.get(leftId);
|
|
245846
|
+
const rightComp = compById.get(rightId);
|
|
245847
|
+
if (!leftComp || !rightComp)
|
|
245848
|
+
return;
|
|
245849
|
+
const minSep = rightComp.schX - leftComp.schX + xSeparation;
|
|
245850
|
+
const key = `${leftId}|${rightId}`;
|
|
245851
|
+
constraintMap.set(key, Math.max(constraintMap.get(key) ?? 0, minSep));
|
|
245852
|
+
};
|
|
245853
|
+
for (const collision of this.rawCollisions) {
|
|
245854
|
+
if (collision.type === "label-label") {
|
|
245855
|
+
addConstraint(collision.leftId, collision.rightId, collision.xSeparation);
|
|
245856
|
+
} else if (collision.boxComp.schX <= collision.labelComp.schX) {
|
|
245857
|
+
addConstraint(collision.boxId, collision.labelId, collision.xSeparation);
|
|
245858
|
+
} else {
|
|
245859
|
+
addConstraint(collision.labelId, collision.boxId, collision.xSeparation);
|
|
245860
|
+
}
|
|
245861
|
+
}
|
|
245862
|
+
const constraints = [...constraintMap.entries()].map(([key, minSep]) => {
|
|
245863
|
+
const pipeIndex = key.indexOf("|");
|
|
245864
|
+
return {
|
|
245865
|
+
leftId: key.slice(0, pipeIndex),
|
|
245866
|
+
rightId: key.slice(pipeIndex + 1),
|
|
245867
|
+
minSep
|
|
245868
|
+
};
|
|
245869
|
+
});
|
|
245870
|
+
const allIds = new Set;
|
|
245871
|
+
const adjacency = new Map;
|
|
245872
|
+
for (const { leftId, rightId } of constraints) {
|
|
245873
|
+
allIds.add(leftId);
|
|
245874
|
+
allIds.add(rightId);
|
|
245875
|
+
if (!adjacency.has(leftId))
|
|
245876
|
+
adjacency.set(leftId, new Set);
|
|
245877
|
+
if (!adjacency.has(rightId))
|
|
245878
|
+
adjacency.set(rightId, new Set);
|
|
245879
|
+
adjacency.get(leftId).add(rightId);
|
|
245880
|
+
adjacency.get(rightId).add(leftId);
|
|
245881
|
+
}
|
|
245882
|
+
const visited = new Set;
|
|
245883
|
+
const result = new Map;
|
|
245884
|
+
for (const startId of allIds) {
|
|
245885
|
+
if (visited.has(startId))
|
|
245886
|
+
continue;
|
|
245887
|
+
const group = [];
|
|
245888
|
+
const queue = [startId];
|
|
245889
|
+
visited.add(startId);
|
|
245890
|
+
while (queue.length) {
|
|
245891
|
+
const compId = queue.shift();
|
|
245892
|
+
group.push(compId);
|
|
245893
|
+
for (const neighbor of adjacency.get(compId) ?? []) {
|
|
245894
|
+
if (!visited.has(neighbor)) {
|
|
245895
|
+
visited.add(neighbor);
|
|
245896
|
+
queue.push(neighbor);
|
|
245897
|
+
}
|
|
245898
|
+
}
|
|
245899
|
+
}
|
|
245900
|
+
group.sort((idA, idB) => (compById.get(idA)?.schX ?? 0) - (compById.get(idB)?.schX ?? 0));
|
|
245901
|
+
const groupIds = new Set(group);
|
|
245902
|
+
const groupConstraints = constraints.filter((c3) => groupIds.has(c3.leftId) && groupIds.has(c3.rightId));
|
|
245903
|
+
const assigned = new Map;
|
|
245904
|
+
for (const compId of group) {
|
|
245905
|
+
let newX = compById.get(compId)?.schX ?? 0;
|
|
245906
|
+
for (const { leftId, rightId, minSep } of groupConstraints) {
|
|
245907
|
+
if (rightId === compId && assigned.has(leftId)) {
|
|
245908
|
+
newX = Math.max(newX, assigned.get(leftId) + minSep);
|
|
245909
|
+
}
|
|
245910
|
+
}
|
|
245911
|
+
assigned.set(compId, newX);
|
|
245912
|
+
}
|
|
245913
|
+
const totalPush = [...assigned.entries()].reduce((sum, [compId, newX]) => sum + (newX - (compById.get(compId)?.schX ?? 0)), 0);
|
|
245914
|
+
if (totalPush > 0.000000001) {
|
|
245915
|
+
const pullBack = totalPush / group.length;
|
|
245916
|
+
const shifted = new Map;
|
|
245917
|
+
for (const compId of group) {
|
|
245918
|
+
let newX = (compById.get(compId)?.schX ?? 0) - pullBack;
|
|
245919
|
+
for (const { leftId, rightId, minSep } of groupConstraints) {
|
|
245920
|
+
if (rightId === compId && shifted.has(leftId)) {
|
|
245921
|
+
newX = Math.max(newX, shifted.get(leftId) + minSep);
|
|
245922
|
+
}
|
|
245923
|
+
}
|
|
245924
|
+
shifted.set(compId, newX);
|
|
245925
|
+
}
|
|
245926
|
+
const maxDisplacement = (positions) => [...positions.entries()].reduce((currentMax, [compId, newX]) => Math.max(currentMax, Math.abs(newX - (compById.get(compId)?.schX ?? 0))), 0);
|
|
245927
|
+
if (maxDisplacement(shifted) < maxDisplacement(assigned)) {
|
|
245928
|
+
for (const [compId, newX] of shifted)
|
|
245929
|
+
assigned.set(compId, newX);
|
|
245930
|
+
}
|
|
245931
|
+
}
|
|
245932
|
+
for (const [compId, newX] of assigned) {
|
|
245933
|
+
const comp = compById.get(compId);
|
|
245934
|
+
if (!comp || Math.abs(newX - comp.schX) < 0.000000001)
|
|
245935
|
+
continue;
|
|
245936
|
+
result.set(compId, {
|
|
245937
|
+
componentName: comp.sourceComponentName ?? compId,
|
|
245938
|
+
newSchX: Math.round(newX * 100) / 100,
|
|
245939
|
+
newSchY: Math.round(comp.schY * 100) / 100
|
|
245940
|
+
});
|
|
245941
|
+
}
|
|
245942
|
+
}
|
|
245943
|
+
return result;
|
|
245944
|
+
}
|
|
245945
|
+
buildNetLabelsByComponentId(circuitJson) {
|
|
245946
|
+
const MATCH_EPSILON = 0.0001;
|
|
245947
|
+
const portPositions = [];
|
|
245948
|
+
for (const element of circuitJson) {
|
|
245949
|
+
if (element.type !== "schematic_port")
|
|
245950
|
+
continue;
|
|
245951
|
+
const port = element;
|
|
245952
|
+
if (!port.schematic_component_id)
|
|
245953
|
+
continue;
|
|
245954
|
+
portPositions.push({
|
|
245955
|
+
componentId: port.schematic_component_id,
|
|
245956
|
+
cx: port.center.x,
|
|
245957
|
+
cy: port.center.y
|
|
245958
|
+
});
|
|
245959
|
+
}
|
|
245960
|
+
const result = new Map;
|
|
245961
|
+
for (const element of circuitJson) {
|
|
245962
|
+
if (element.type !== "schematic_net_label")
|
|
245963
|
+
continue;
|
|
245964
|
+
const label = element;
|
|
245965
|
+
if (!label.anchor_position)
|
|
245966
|
+
continue;
|
|
245967
|
+
const { x: anchorX, y: anchorY } = label.anchor_position;
|
|
245968
|
+
const matches = portPositions.filter((port) => Math.hypot(port.cx - anchorX, port.cy - anchorY) < MATCH_EPSILON);
|
|
245969
|
+
if (matches.length === 0)
|
|
245970
|
+
continue;
|
|
245971
|
+
const componentIds = new Set(matches.map((match) => match.componentId));
|
|
245972
|
+
if (componentIds.size !== 1)
|
|
245973
|
+
continue;
|
|
245974
|
+
const componentId = matches[0].componentId;
|
|
245975
|
+
const labels = result.get(componentId) ?? [];
|
|
245976
|
+
labels.push(label);
|
|
245977
|
+
result.set(componentId, labels);
|
|
245978
|
+
}
|
|
245979
|
+
return result;
|
|
245980
|
+
}
|
|
245981
|
+
getNetLabelBounds(label) {
|
|
245982
|
+
const anchorSide = label.anchor_side;
|
|
245983
|
+
const isVertical3 = anchorSide === "top" || anchorSide === "bottom";
|
|
245984
|
+
if (isVertical3) {
|
|
245985
|
+
const anchorY = label.anchor_position?.y ?? label.center.y;
|
|
245986
|
+
const textHalfExtent = (label.text?.length ?? 8) * this.SCH_CHAR_WIDTH / 2 + this.LABEL_BOUNDS_SLACK;
|
|
245987
|
+
const left = label.center.x - this.LABEL_HALF_HEIGHT;
|
|
245988
|
+
const right = label.center.x + this.LABEL_HALF_HEIGHT;
|
|
245989
|
+
if (anchorSide === "top") {
|
|
245990
|
+
return {
|
|
245991
|
+
left,
|
|
245992
|
+
right,
|
|
245993
|
+
top: anchorY,
|
|
245994
|
+
bottom: anchorY - textHalfExtent * 2
|
|
245995
|
+
};
|
|
245996
|
+
}
|
|
245997
|
+
return { left, right, top: anchorY + textHalfExtent * 2, bottom: anchorY };
|
|
245998
|
+
}
|
|
245999
|
+
const anchorX = label.anchor_position?.x ?? label.center.x;
|
|
246000
|
+
const halfWidth = Math.abs(label.center.x - anchorX);
|
|
246001
|
+
const farHalfWidth = halfWidth + this.LABEL_BOUNDS_SLACK;
|
|
246002
|
+
const top = label.center.y + this.LABEL_HALF_HEIGHT;
|
|
246003
|
+
const bottom = label.center.y - this.LABEL_HALF_HEIGHT;
|
|
246004
|
+
if (label.center.x >= anchorX) {
|
|
246005
|
+
return {
|
|
246006
|
+
left: anchorX,
|
|
246007
|
+
right: label.center.x + farHalfWidth,
|
|
246008
|
+
top,
|
|
246009
|
+
bottom
|
|
246010
|
+
};
|
|
246011
|
+
}
|
|
246012
|
+
return { left: label.center.x - farHalfWidth, right: anchorX, top, bottom };
|
|
246013
|
+
}
|
|
246014
|
+
static netLabelCollisionToString(issue) {
|
|
246015
|
+
const pairAttrs = issue.pairs.map((pair, i2) => `pair${i2 + 1}="${pair.comp1Name}/${pair.comp2Name}"`).join(" ");
|
|
246016
|
+
const moves = issue.moves.map((move) => ` <Move componentName="${move.componentName}" newSchX="${move.newSchX}" newSchY="${move.newSchY}" />`);
|
|
246017
|
+
return [
|
|
246018
|
+
`<ComponentNetLabelCollision ${pairAttrs}>`,
|
|
246019
|
+
` <SuggestedFix note="Apply all moves simultaneously. Set schAutoLayoutEnabled on your circuit.">`,
|
|
246020
|
+
...moves,
|
|
246021
|
+
` </SuggestedFix>`,
|
|
246022
|
+
`</ComponentNetLabelCollision>`
|
|
246023
|
+
].join(`
|
|
246024
|
+
`);
|
|
246025
|
+
}
|
|
246026
|
+
}
|
|
246027
|
+
|
|
245679
246028
|
// node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/solvers/SchematicPlacementPipeline/SchematicPlacementPipeline.ts
|
|
245680
246029
|
class SchematicPlacementPipeline extends BasePipelineSolver2 {
|
|
245681
246030
|
ctx;
|
|
@@ -245701,6 +246050,9 @@ class SchematicPlacementPipeline extends BasePipelineSolver2 {
|
|
|
245701
246050
|
]),
|
|
245702
246051
|
definePipelineStep3("DiodeResistorAlignmentSolver", DiodeResistorAlignmentSolver, (p3) => [
|
|
245703
246052
|
{ ctx: p3.ctx, issues: p3.issues }
|
|
246053
|
+
]),
|
|
246054
|
+
definePipelineStep3("ComponentNetLabelCollisionSolver", ComponentNetLabelCollisionSolver, (p3) => [
|
|
246055
|
+
{ ctx: p3.ctx, issues: p3.issues }
|
|
245704
246056
|
])
|
|
245705
246057
|
];
|
|
245706
246058
|
_setup() {
|
|
@@ -245753,6 +246105,8 @@ class SchematicPlacementAnalysis {
|
|
|
245753
246105
|
return SchematicPinPaddingToEdgeSolver.issueToString(issue);
|
|
245754
246106
|
case "DiodeResistorNotAligned":
|
|
245755
246107
|
return DiodeResistorAlignmentSolver.issueToString(issue);
|
|
246108
|
+
case "NetLabelCollision":
|
|
246109
|
+
return ComponentNetLabelCollisionSolver.netLabelCollisionToString(issue);
|
|
245756
246110
|
default:
|
|
245757
246111
|
return "";
|
|
245758
246112
|
}
|
package/dist/lib/index.js
CHANGED
|
@@ -65733,7 +65733,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
65733
65733
|
}));
|
|
65734
65734
|
};
|
|
65735
65735
|
// package.json
|
|
65736
|
-
var version = "0.1.
|
|
65736
|
+
var version = "0.1.1435";
|
|
65737
65737
|
var package_default = {
|
|
65738
65738
|
name: "@tscircuit/cli",
|
|
65739
65739
|
version,
|
|
@@ -65747,7 +65747,7 @@ var package_default = {
|
|
|
65747
65747
|
"@biomejs/biome": "^1.9.4",
|
|
65748
65748
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.6",
|
|
65749
65749
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.1",
|
|
65750
|
-
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#
|
|
65750
|
+
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#40f49bb8ae9dabedb19b47ec0a621c713b40615c",
|
|
65751
65751
|
"@tscircuit/eval": "^0.0.835",
|
|
65752
65752
|
"@tscircuit/fake-snippets": "^0.0.182",
|
|
65753
65753
|
"@tscircuit/file-server": "^0.0.32",
|
|
@@ -78193,8 +78193,9 @@ var prettyResponseErrorHook = async (request, _options, response) => {
|
|
|
78193
78193
|
const apiError = errorData?.error;
|
|
78194
78194
|
const errorString = apiError ? `
|
|
78195
78195
|
${apiError.error_code}: ${apiError.message}` : "";
|
|
78196
|
+
const sessionExpiredAdvice = request.headers.has("Authorization") && /session_expired|token_expired|expired_session/i.test(apiError?.error_code ?? "") ? "\n\nYour tscircuit session has expired. Run `tsci logout`, then `tsci login` to log back in." : "";
|
|
78196
78197
|
const bodyDisplay = errorData ? JSON.stringify(errorData, null, 2) : responseText.slice(0, 20);
|
|
78197
|
-
throw new PrettyHttpError(`FAIL [${response.status}]: ${request.method} ${new URL(request.url).pathname}${errorString}${requestBody ? `
|
|
78198
|
+
throw new PrettyHttpError(`FAIL [${response.status}]: ${request.method} ${new URL(request.url).pathname}${errorString}${sessionExpiredAdvice}${requestBody ? `
|
|
78198
78199
|
|
|
78199
78200
|
Request Body:
|
|
78200
78201
|
${requestBody}` : ""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1436",
|
|
4
4
|
"main": "dist/cli/main.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/cli/main.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@biomejs/biome": "^1.9.4",
|
|
12
12
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.6",
|
|
13
13
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.1",
|
|
14
|
-
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#
|
|
14
|
+
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#40f49bb8ae9dabedb19b47ec0a621c713b40615c",
|
|
15
15
|
"@tscircuit/eval": "^0.0.835",
|
|
16
16
|
"@tscircuit/fake-snippets": "^0.0.182",
|
|
17
17
|
"@tscircuit/file-server": "^0.0.32",
|