@tscircuit/cli 0.1.1904 → 0.1.1905
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 +111 -233
- package/dist/lib/index.js +2 -2
- package/package.json +2 -2
package/dist/cli/main.js
CHANGED
|
@@ -135442,7 +135442,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
135442
135442
|
// lib/getVersion.ts
|
|
135443
135443
|
import { createRequire as createRequire2 } from "node:module";
|
|
135444
135444
|
// package.json
|
|
135445
|
-
var version = "0.1.
|
|
135445
|
+
var version = "0.1.1904";
|
|
135446
135446
|
var package_default = {
|
|
135447
135447
|
name: "@tscircuit/cli",
|
|
135448
135448
|
version,
|
|
@@ -135456,7 +135456,7 @@ var package_default = {
|
|
|
135456
135456
|
"@biomejs/biome": "^1.9.4",
|
|
135457
135457
|
"@tscircuit/check-shorts": "https://jscdn.tscircuit.com/@tscircuit/check-shorts/0.0.19.tgz",
|
|
135458
135458
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.9",
|
|
135459
|
-
"@tscircuit/circuit-json-routing-analysis": "^0.0.
|
|
135459
|
+
"@tscircuit/circuit-json-routing-analysis": "^0.0.8",
|
|
135460
135460
|
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#bb0b41d80c9714695b498e182c2a558f1e0ceb2d",
|
|
135461
135461
|
"@tscircuit/circuit-json-util": "^0.0.105",
|
|
135462
135462
|
"@tscircuit/eval": "^0.0.1016",
|
|
@@ -178518,6 +178518,29 @@ var getBoundsFromNode = (node) => ({
|
|
|
178518
178518
|
var getBoundsWidth = (bounds) => bounds.maxX - bounds.minX;
|
|
178519
178519
|
var getBoundsHeight = (bounds) => bounds.maxY - bounds.minY;
|
|
178520
178520
|
var doBoundsIntersect = (a2, b22) => !(a2.maxX < b22.minX || a2.minX > b22.maxX || a2.maxY < b22.minY || a2.minY > b22.maxY);
|
|
178521
|
+
var getEdgeDistanceBetweenBounds = (a2, b22) => {
|
|
178522
|
+
const dx2 = Math.max(a2.minX - b22.maxX, b22.minX - a2.maxX, 0);
|
|
178523
|
+
const dy2 = Math.max(a2.minY - b22.maxY, b22.minY - a2.maxY, 0);
|
|
178524
|
+
return Math.hypot(dx2, dy2);
|
|
178525
|
+
};
|
|
178526
|
+
var getBoundsComparisonTolerance = (...bounds) => {
|
|
178527
|
+
const coordinateScale = Math.max(1, ...bounds.flatMap((bound) => [
|
|
178528
|
+
Math.abs(bound.minX),
|
|
178529
|
+
Math.abs(bound.maxX),
|
|
178530
|
+
Math.abs(bound.minY),
|
|
178531
|
+
Math.abs(bound.maxY)
|
|
178532
|
+
]));
|
|
178533
|
+
return Number.EPSILON * coordinateScale * 16;
|
|
178534
|
+
};
|
|
178535
|
+
var getOverlapDepthBetweenBounds = (a2, b22) => {
|
|
178536
|
+
const overlapWidth = Math.min(a2.maxX, b22.maxX) - Math.max(a2.minX, b22.minX);
|
|
178537
|
+
const overlapHeight = Math.min(a2.maxY, b22.maxY) - Math.max(a2.minY, b22.minY);
|
|
178538
|
+
const comparisonTolerance = getBoundsComparisonTolerance(a2, b22);
|
|
178539
|
+
if (overlapWidth <= comparisonTolerance || overlapHeight <= comparisonTolerance) {
|
|
178540
|
+
return 0;
|
|
178541
|
+
}
|
|
178542
|
+
return Math.min(overlapWidth, overlapHeight);
|
|
178543
|
+
};
|
|
178521
178544
|
var isContainedWithinBounds = (componentBounds, regionBounds) => componentBounds.minX >= regionBounds.minX && componentBounds.maxX <= regionBounds.maxX && componentBounds.minY >= regionBounds.minY && componentBounds.maxY <= regionBounds.maxY;
|
|
178522
178545
|
var doesRegionFitWithinComponent = (componentBounds, regionBounds) => regionBounds.minX >= componentBounds.minX && regionBounds.maxX <= componentBounds.maxX && regionBounds.minY >= componentBounds.minY && regionBounds.maxY <= componentBounds.maxY;
|
|
178523
178546
|
var translateBounds = (bounds, direction2, distance50) => {
|
|
@@ -179005,10 +179028,10 @@ var hasCollisionAtDistance = (spatialIndex, componentIndex, direction2, distance
|
|
|
179005
179028
|
};
|
|
179006
179029
|
var getFreeSpaceForDirection = (spatialIndex, componentIndex, direction2) => {
|
|
179007
179030
|
if (hasCollisionAtDistance(spatialIndex, componentIndex, direction2, 0)) {
|
|
179008
|
-
return
|
|
179031
|
+
return { distanceMm: 0, isAtLeast: false };
|
|
179009
179032
|
}
|
|
179010
179033
|
if (!hasCollisionAtDistance(spatialIndex, componentIndex, direction2, MAX_FREE_SPACE_MM)) {
|
|
179011
|
-
return
|
|
179034
|
+
return { distanceMm: MAX_FREE_SPACE_MM, isAtLeast: true };
|
|
179012
179035
|
}
|
|
179013
179036
|
let low = 0;
|
|
179014
179037
|
let high = MAX_FREE_SPACE_MM;
|
|
@@ -179020,7 +179043,7 @@ var getFreeSpaceForDirection = (spatialIndex, componentIndex, direction2) => {
|
|
|
179020
179043
|
low = mid;
|
|
179021
179044
|
}
|
|
179022
179045
|
}
|
|
179023
|
-
return
|
|
179046
|
+
return { distanceMm: low, isAtLeast: false };
|
|
179024
179047
|
};
|
|
179025
179048
|
var getDirectionalFreeSpace = (spatialIndex, componentIndex, directions) => {
|
|
179026
179049
|
const freeSpaceByDirection = {};
|
|
@@ -179029,8 +179052,7 @@ var getDirectionalFreeSpace = (spatialIndex, componentIndex, directions) => {
|
|
|
179029
179052
|
}
|
|
179030
179053
|
return freeSpaceByDirection;
|
|
179031
179054
|
};
|
|
179032
|
-
var
|
|
179033
|
-
var roundsToZeroMm = (value) => Math.abs(value) < 0.05;
|
|
179055
|
+
var DEFAULT_MAX_NEARBY_COMPONENT_DISTANCE_MM = 5;
|
|
179034
179056
|
var toNumber3 = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
179035
179057
|
var getPcbComponentBounds = (element) => {
|
|
179036
179058
|
const center2 = typeof element.center === "object" && element.center ? element.center : null;
|
|
@@ -179073,44 +179095,48 @@ var getPlacedComponents = (circuitJson) => {
|
|
|
179073
179095
|
}
|
|
179074
179096
|
return placedComponents;
|
|
179075
179097
|
};
|
|
179076
|
-
var
|
|
179077
|
-
var getOffsetFromBottomOfRegion = (componentBounds, regionBounds) => fmtMm3(componentBounds.minY - regionBounds.minY);
|
|
179078
|
-
var getOffsetFromLeftOfRegion = (componentBounds, regionBounds) => fmtMm3(componentBounds.minX - regionBounds.minX);
|
|
179079
|
-
var getOffsetFromRightOfRegion = (componentBounds, regionBounds) => fmtMm3(regionBounds.maxX - componentBounds.maxX);
|
|
179080
|
-
var addEdgeAlignedOffsets = (nearbyComponent, componentBounds, regionBounds) => {
|
|
179081
|
-
if (nearbyComponent.onLeftEdgeOfRegion || nearbyComponent.onRightEdgeOfRegion) {
|
|
179082
|
-
nearbyComponent.distToTopOfRegion = getOffsetFromTopOfRegion(componentBounds, regionBounds);
|
|
179083
|
-
nearbyComponent.distToBottomOfRegion = getOffsetFromBottomOfRegion(componentBounds, regionBounds);
|
|
179084
|
-
}
|
|
179085
|
-
if (nearbyComponent.onTopEdgeOfRegion || nearbyComponent.onBottomEdgeOfRegion) {
|
|
179086
|
-
nearbyComponent.distToLeftEdgeOfRegion = getOffsetFromLeftOfRegion(componentBounds, regionBounds);
|
|
179087
|
-
nearbyComponent.distToRightEdgeOfRegion = getOffsetFromRightOfRegion(componentBounds, regionBounds);
|
|
179088
|
-
}
|
|
179089
|
-
return nearbyComponent;
|
|
179090
|
-
};
|
|
179091
|
-
var getDirectionsToExclude = (component) => {
|
|
179098
|
+
var getOutsideDirections = (componentBounds, regionBounds) => {
|
|
179092
179099
|
const directions = [];
|
|
179093
|
-
const
|
|
179094
|
-
|
|
179095
|
-
|
|
179100
|
+
const tolerance = getBoundsComparisonTolerance(componentBounds, regionBounds);
|
|
179101
|
+
if (componentBounds.maxX <= regionBounds.minX + tolerance)
|
|
179102
|
+
directions.push("left");
|
|
179103
|
+
if (componentBounds.minX >= regionBounds.maxX - tolerance)
|
|
179096
179104
|
directions.push("right");
|
|
179097
|
-
|
|
179105
|
+
if (componentBounds.maxY <= regionBounds.minY + tolerance)
|
|
179106
|
+
directions.push("bottom");
|
|
179107
|
+
if (componentBounds.minY >= regionBounds.maxY - tolerance)
|
|
179108
|
+
directions.push("top");
|
|
179109
|
+
return directions;
|
|
179110
|
+
};
|
|
179111
|
+
var getOverlapDirections = (componentBounds, regionBounds) => {
|
|
179112
|
+
const directions = [];
|
|
179113
|
+
if (componentBounds.minX <= regionBounds.minX)
|
|
179098
179114
|
directions.push("left");
|
|
179099
|
-
|
|
179100
|
-
|
|
179101
|
-
|
|
179102
|
-
if (component.distToRightEdgeOfRegion)
|
|
179103
|
-
directions.push("left");
|
|
179104
|
-
}
|
|
179105
|
-
if (component.onTopEdgeOfRegion) {
|
|
179115
|
+
if (componentBounds.maxX >= regionBounds.maxX)
|
|
179116
|
+
directions.push("right");
|
|
179117
|
+
if (componentBounds.minY <= regionBounds.minY)
|
|
179106
179118
|
directions.push("bottom");
|
|
179107
|
-
|
|
179119
|
+
if (componentBounds.maxY >= regionBounds.maxY)
|
|
179108
179120
|
directions.push("top");
|
|
179109
|
-
|
|
179110
|
-
|
|
179111
|
-
|
|
179112
|
-
|
|
179113
|
-
|
|
179121
|
+
return directions;
|
|
179122
|
+
};
|
|
179123
|
+
var getDirectionsToExclude = (component) => {
|
|
179124
|
+
const directions = [];
|
|
179125
|
+
for (const direction2 of component.directions) {
|
|
179126
|
+
switch (direction2) {
|
|
179127
|
+
case "left":
|
|
179128
|
+
directions.push("right");
|
|
179129
|
+
break;
|
|
179130
|
+
case "right":
|
|
179131
|
+
directions.push("left");
|
|
179132
|
+
break;
|
|
179133
|
+
case "top":
|
|
179134
|
+
directions.push("bottom");
|
|
179135
|
+
break;
|
|
179136
|
+
case "bottom":
|
|
179137
|
+
directions.push("top");
|
|
179138
|
+
break;
|
|
179139
|
+
}
|
|
179114
179140
|
}
|
|
179115
179141
|
return directions;
|
|
179116
179142
|
};
|
|
@@ -179122,174 +179148,37 @@ var addFreeSpace = (nearbyComponent, componentIndex, spatialIndex) => {
|
|
|
179122
179148
|
continue;
|
|
179123
179149
|
directionsToCheck.push(direction2);
|
|
179124
179150
|
}
|
|
179125
|
-
|
|
179126
|
-
|
|
179127
|
-
|
|
179128
|
-
|
|
179129
|
-
|
|
179130
|
-
|
|
179131
|
-
|
|
179132
|
-
|
|
179133
|
-
|
|
179134
|
-
return nearbyComponent;
|
|
179135
|
-
};
|
|
179136
|
-
var createOverlappingNearbyComponent = (component, componentIndex, regionBounds, spatialIndex) => {
|
|
179151
|
+
return {
|
|
179152
|
+
...nearbyComponent,
|
|
179153
|
+
freeSpaceByDirection: getDirectionalFreeSpace(spatialIndex, componentIndex, directionsToCheck)
|
|
179154
|
+
};
|
|
179155
|
+
};
|
|
179156
|
+
var createNearbyComponent = (component, componentIndex, regionBounds, spatialIndex) => {
|
|
179157
|
+
const edgeDistanceMm = getEdgeDistanceBetweenBounds(component.bounds, regionBounds);
|
|
179158
|
+
const overlapDepthMm = getOverlapDepthBetweenBounds(component.bounds, regionBounds);
|
|
179159
|
+
const overlapsRegion = overlapDepthMm > 0;
|
|
179137
179160
|
const nearbyComponent = {
|
|
179138
179161
|
name: component.name,
|
|
179139
|
-
|
|
179140
|
-
|
|
179141
|
-
|
|
179142
|
-
|
|
179162
|
+
bounds: component.bounds,
|
|
179163
|
+
edgeDistanceMm,
|
|
179164
|
+
directions: overlapsRegion ? getOverlapDirections(component.bounds, regionBounds) : getOutsideDirections(component.bounds, regionBounds),
|
|
179165
|
+
...overlapsRegion ? { overlapDepthMm } : {}
|
|
179143
179166
|
};
|
|
179144
|
-
if (isContainedWithinBounds(component.bounds, regionBounds)) {
|
|
179167
|
+
if (overlapsRegion && isContainedWithinBounds(component.bounds, regionBounds)) {
|
|
179145
179168
|
nearbyComponent.containedWithinBounds = true;
|
|
179146
|
-
} else if (doesRegionFitWithinComponent(component.bounds, regionBounds)) {
|
|
179169
|
+
} else if (overlapsRegion && doesRegionFitWithinComponent(component.bounds, regionBounds)) {
|
|
179147
179170
|
nearbyComponent.regionWithinComponent = true;
|
|
179148
|
-
} else {
|
|
179149
|
-
if (component.bounds.minX <= regionBounds.minX) {
|
|
179150
|
-
nearbyComponent.onLeftEdgeOfRegion = true;
|
|
179151
|
-
}
|
|
179152
|
-
if (component.bounds.maxX >= regionBounds.maxX) {
|
|
179153
|
-
nearbyComponent.onRightEdgeOfRegion = true;
|
|
179154
|
-
}
|
|
179155
|
-
if (component.bounds.maxY >= regionBounds.maxY) {
|
|
179156
|
-
nearbyComponent.onTopEdgeOfRegion = true;
|
|
179157
|
-
}
|
|
179158
|
-
if (component.bounds.minY <= regionBounds.minY) {
|
|
179159
|
-
nearbyComponent.onBottomEdgeOfRegion = true;
|
|
179160
|
-
}
|
|
179161
|
-
addEdgeAlignedOffsets(nearbyComponent, component.bounds, regionBounds);
|
|
179162
179171
|
}
|
|
179163
179172
|
return addFreeSpace(nearbyComponent, componentIndex, spatialIndex);
|
|
179164
179173
|
};
|
|
179165
|
-
var
|
|
179166
|
-
|
|
179167
|
-
|
|
179168
|
-
|
|
179169
|
-
if (component.bounds.maxX < regionBounds.minX) {
|
|
179170
|
-
candidates.push({
|
|
179171
|
-
direction: "left",
|
|
179172
|
-
distance: regionBounds.minX - component.bounds.maxX
|
|
179173
|
-
});
|
|
179174
|
-
}
|
|
179175
|
-
if (component.bounds.minX > regionBounds.maxX) {
|
|
179176
|
-
candidates.push({
|
|
179177
|
-
direction: "right",
|
|
179178
|
-
distance: component.bounds.minX - regionBounds.maxX
|
|
179179
|
-
});
|
|
179180
|
-
}
|
|
179181
|
-
if (component.bounds.maxY < regionBounds.minY) {
|
|
179182
|
-
candidates.push({
|
|
179183
|
-
direction: "bottom",
|
|
179184
|
-
distance: regionBounds.minY - component.bounds.maxY
|
|
179185
|
-
});
|
|
179174
|
+
var getNearbyComponents = (circuitJson, regionBounds, options = {}) => {
|
|
179175
|
+
const maxDistanceMm = options.maxDistanceMm ?? DEFAULT_MAX_NEARBY_COMPONENT_DISTANCE_MM;
|
|
179176
|
+
if (!Number.isFinite(maxDistanceMm) || maxDistanceMm < 0) {
|
|
179177
|
+
throw new RangeError("maxDistanceMm must be a non-negative finite number");
|
|
179186
179178
|
}
|
|
179187
|
-
if (component.bounds.minY > regionBounds.maxY) {
|
|
179188
|
-
candidates.push({
|
|
179189
|
-
direction: "top",
|
|
179190
|
-
distance: component.bounds.minY - regionBounds.maxY
|
|
179191
|
-
});
|
|
179192
|
-
}
|
|
179193
|
-
if (candidates.length === 0)
|
|
179194
|
-
return null;
|
|
179195
|
-
const closestCandidates = candidates.sort((a2, b22) => a2.distance - b22.distance).slice(0, 2);
|
|
179196
|
-
const nearbyComponentCandidate = {
|
|
179197
|
-
componentIndex,
|
|
179198
|
-
name: component.name,
|
|
179199
|
-
score: closestCandidates.reduce((smallestDistance, candidate) => Math.min(smallestDistance, candidate.distance), Number.POSITIVE_INFINITY),
|
|
179200
|
-
minX: component.bounds.minX,
|
|
179201
|
-
maxX: component.bounds.maxX,
|
|
179202
|
-
minY: component.bounds.minY,
|
|
179203
|
-
maxY: component.bounds.maxY
|
|
179204
|
-
};
|
|
179205
|
-
for (const candidate of closestCandidates) {
|
|
179206
|
-
switch (candidate.direction) {
|
|
179207
|
-
case "left":
|
|
179208
|
-
if (roundsToZeroMm(candidate.distance)) {
|
|
179209
|
-
nearbyComponentCandidate.onLeftEdgeOfRegion = true;
|
|
179210
|
-
} else {
|
|
179211
|
-
nearbyComponentCandidate.distToLeftEdgeOfRegion = fmtMm3(candidate.distance);
|
|
179212
|
-
}
|
|
179213
|
-
break;
|
|
179214
|
-
case "right":
|
|
179215
|
-
if (roundsToZeroMm(candidate.distance)) {
|
|
179216
|
-
nearbyComponentCandidate.onRightEdgeOfRegion = true;
|
|
179217
|
-
} else {
|
|
179218
|
-
nearbyComponentCandidate.distToRightEdgeOfRegion = fmtMm3(candidate.distance);
|
|
179219
|
-
}
|
|
179220
|
-
break;
|
|
179221
|
-
case "top":
|
|
179222
|
-
if (roundsToZeroMm(candidate.distance)) {
|
|
179223
|
-
nearbyComponentCandidate.onTopEdgeOfRegion = true;
|
|
179224
|
-
} else {
|
|
179225
|
-
nearbyComponentCandidate.distToTopOfRegion = fmtMm3(candidate.distance);
|
|
179226
|
-
}
|
|
179227
|
-
break;
|
|
179228
|
-
case "bottom":
|
|
179229
|
-
if (roundsToZeroMm(candidate.distance)) {
|
|
179230
|
-
nearbyComponentCandidate.onBottomEdgeOfRegion = true;
|
|
179231
|
-
} else {
|
|
179232
|
-
nearbyComponentCandidate.distToBottomOfRegion = fmtMm3(candidate.distance);
|
|
179233
|
-
}
|
|
179234
|
-
break;
|
|
179235
|
-
}
|
|
179236
|
-
}
|
|
179237
|
-
const nearbyComponent = addEdgeAlignedOffsets({
|
|
179238
|
-
name: nearbyComponentCandidate.name,
|
|
179239
|
-
minX: nearbyComponentCandidate.minX,
|
|
179240
|
-
maxX: nearbyComponentCandidate.maxX,
|
|
179241
|
-
minY: nearbyComponentCandidate.minY,
|
|
179242
|
-
maxY: nearbyComponentCandidate.maxY,
|
|
179243
|
-
...nearbyComponentCandidate.onLeftEdgeOfRegion ? { onLeftEdgeOfRegion: true } : {},
|
|
179244
|
-
...nearbyComponentCandidate.onRightEdgeOfRegion ? { onRightEdgeOfRegion: true } : {},
|
|
179245
|
-
...nearbyComponentCandidate.onTopEdgeOfRegion ? { onTopEdgeOfRegion: true } : {},
|
|
179246
|
-
...nearbyComponentCandidate.onBottomEdgeOfRegion ? { onBottomEdgeOfRegion: true } : {},
|
|
179247
|
-
...nearbyComponentCandidate.distToLeftEdgeOfRegion ? {
|
|
179248
|
-
distToLeftEdgeOfRegion: nearbyComponentCandidate.distToLeftEdgeOfRegion
|
|
179249
|
-
} : {},
|
|
179250
|
-
...nearbyComponentCandidate.distToRightEdgeOfRegion ? {
|
|
179251
|
-
distToRightEdgeOfRegion: nearbyComponentCandidate.distToRightEdgeOfRegion
|
|
179252
|
-
} : {},
|
|
179253
|
-
...nearbyComponentCandidate.distToTopOfRegion ? {
|
|
179254
|
-
distToTopOfRegion: nearbyComponentCandidate.distToTopOfRegion
|
|
179255
|
-
} : {},
|
|
179256
|
-
...nearbyComponentCandidate.distToBottomOfRegion ? {
|
|
179257
|
-
distToBottomOfRegion: nearbyComponentCandidate.distToBottomOfRegion
|
|
179258
|
-
} : {}
|
|
179259
|
-
}, component.bounds, regionBounds);
|
|
179260
|
-
return {
|
|
179261
|
-
...nearbyComponentCandidate,
|
|
179262
|
-
...nearbyComponent
|
|
179263
|
-
};
|
|
179264
|
-
};
|
|
179265
|
-
var getNearbyComponents = (circuitJson, regionBounds) => {
|
|
179266
179179
|
const placedComponents = getPlacedComponents(circuitJson);
|
|
179267
179180
|
const spatialIndex = buildComponentSpatialIndex(placedComponents);
|
|
179268
|
-
|
|
179269
|
-
if (!doBoundsIntersect(component.bounds, regionBounds))
|
|
179270
|
-
return null;
|
|
179271
|
-
return createOverlappingNearbyComponent(component, componentIndex, regionBounds, spatialIndex);
|
|
179272
|
-
}).filter((component) => component !== null).sort((a2, b22) => a2.name.localeCompare(b22.name));
|
|
179273
|
-
const outsideComponents = placedComponents.map((component, componentIndex) => getOutsideComponentCandidate(component, componentIndex, regionBounds)).filter((component) => component !== null).sort((a2, b22) => a2.score - b22.score || a2.name.localeCompare(b22.name)).slice(0, 3).map((component) => addFreeSpace({
|
|
179274
|
-
name: component.name,
|
|
179275
|
-
minX: component.minX,
|
|
179276
|
-
maxX: component.maxX,
|
|
179277
|
-
minY: component.minY,
|
|
179278
|
-
maxY: component.maxY,
|
|
179279
|
-
...component.onLeftEdgeOfRegion ? { onLeftEdgeOfRegion: true } : {},
|
|
179280
|
-
...component.onRightEdgeOfRegion ? { onRightEdgeOfRegion: true } : {},
|
|
179281
|
-
...component.onTopEdgeOfRegion ? { onTopEdgeOfRegion: true } : {},
|
|
179282
|
-
...component.onBottomEdgeOfRegion ? { onBottomEdgeOfRegion: true } : {},
|
|
179283
|
-
...component.distToLeftEdgeOfRegion ? {
|
|
179284
|
-
distToLeftEdgeOfRegion: component.distToLeftEdgeOfRegion
|
|
179285
|
-
} : {},
|
|
179286
|
-
...component.distToRightEdgeOfRegion ? {
|
|
179287
|
-
distToRightEdgeOfRegion: component.distToRightEdgeOfRegion
|
|
179288
|
-
} : {},
|
|
179289
|
-
...component.distToTopOfRegion ? { distToTopOfRegion: component.distToTopOfRegion } : {},
|
|
179290
|
-
...component.distToBottomOfRegion ? { distToBottomOfRegion: component.distToBottomOfRegion } : {}
|
|
179291
|
-
}, component.componentIndex, spatialIndex));
|
|
179292
|
-
return [...overlappingComponents, ...outsideComponents];
|
|
179181
|
+
return placedComponents.map((component, componentIndex) => createNearbyComponent(component, componentIndex, regionBounds, spatialIndex)).filter((component) => component.overlapDepthMm !== undefined || component.edgeDistanceMm <= maxDistanceMm).sort((a2, b22) => a2.edgeDistanceMm - b22.edgeDistanceMm || (b22.overlapDepthMm ?? 0) - (a2.overlapDepthMm ?? 0) || a2.name.localeCompare(b22.name));
|
|
179293
179182
|
};
|
|
179294
179183
|
var getBoundsArea = (bounds) => Math.max(0, bounds.maxX - bounds.minX) * Math.max(0, bounds.maxY - bounds.minY);
|
|
179295
179184
|
var getIntersectionArea = (a2, b22) => {
|
|
@@ -300825,8 +300714,10 @@ var fmtNumber3 = (value) => {
|
|
|
300825
300714
|
return String(value);
|
|
300826
300715
|
return value.toFixed(3).replace(/\.0+$/, "").replace(/(\.\d*?)0+$/, "$1");
|
|
300827
300716
|
};
|
|
300828
|
-
var
|
|
300717
|
+
var fmtMm3 = (value) => `${value.toFixed(1)}mm`;
|
|
300718
|
+
var fmtMeasurementMm = (value) => `${fmtNumber3(value)}mm`;
|
|
300829
300719
|
var fmtPercent2 = (value) => `${fmtNumber3(value * 100)}%`;
|
|
300720
|
+
var xmlEscape = (value) => value.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">");
|
|
300830
300721
|
var isCrampedPortPoint = (portPointId) => portPointId?.includes("_cramped") ?? false;
|
|
300831
300722
|
var clamp012 = (value) => Math.max(0, Math.min(1, value));
|
|
300832
300723
|
var roundProbability = (value) => Number.parseFloat(value.toFixed(3));
|
|
@@ -300843,51 +300734,38 @@ var getProbabilityOfFailure = (node, maxDensity, maxPortPointCount) => {
|
|
|
300843
300734
|
return roundProbability(clamp012((crampedRatio * 0.7 + densityScore * 0.3) * trafficScore));
|
|
300844
300735
|
};
|
|
300845
300736
|
var nearbyComponentToString = (component) => {
|
|
300846
|
-
const attrs = [
|
|
300737
|
+
const attrs = [
|
|
300738
|
+
`name="${xmlEscape(component.name)}"`,
|
|
300739
|
+
`edgeDistance="${fmtMeasurementMm(component.edgeDistanceMm)}"`
|
|
300740
|
+
];
|
|
300741
|
+
if (component.overlapDepthMm !== undefined) {
|
|
300742
|
+
attrs.push(`overlapDepth="${fmtMeasurementMm(component.overlapDepthMm)}"`);
|
|
300743
|
+
}
|
|
300744
|
+
if (component.directions.length > 0) {
|
|
300745
|
+
attrs.push(`directions="${component.directions.join(",")}"`);
|
|
300746
|
+
}
|
|
300847
300747
|
if (component.containedWithinBounds)
|
|
300848
300748
|
attrs.push("containedWithinBounds");
|
|
300849
300749
|
if (component.regionWithinComponent)
|
|
300850
300750
|
attrs.push("regionWithinComponent");
|
|
300851
|
-
|
|
300852
|
-
|
|
300853
|
-
|
|
300854
|
-
|
|
300855
|
-
|
|
300856
|
-
|
|
300857
|
-
|
|
300858
|
-
|
|
300859
|
-
|
|
300860
|
-
|
|
300861
|
-
}
|
|
300862
|
-
if (component.distToRightEdgeOfRegion) {
|
|
300863
|
-
attrs.push(`distToRightEdgeOfRegion="${component.distToRightEdgeOfRegion}"`);
|
|
300864
|
-
}
|
|
300865
|
-
if (component.distToTopOfRegion) {
|
|
300866
|
-
attrs.push(`distToTopOfRegion="${component.distToTopOfRegion}"`);
|
|
300867
|
-
}
|
|
300868
|
-
if (component.distToBottomOfRegion) {
|
|
300869
|
-
attrs.push(`distToBottomOfRegion="${component.distToBottomOfRegion}"`);
|
|
300870
|
-
}
|
|
300871
|
-
if (component.freeSpaceOnLeft) {
|
|
300872
|
-
attrs.push(`freeSpaceOnLeft="${component.freeSpaceOnLeft}"`);
|
|
300873
|
-
}
|
|
300874
|
-
if (component.freeSpaceOnRight) {
|
|
300875
|
-
attrs.push(`freeSpaceOnRight="${component.freeSpaceOnRight}"`);
|
|
300876
|
-
}
|
|
300877
|
-
if (component.freeSpaceAbove) {
|
|
300878
|
-
attrs.push(`freeSpaceAbove="${component.freeSpaceAbove}"`);
|
|
300879
|
-
}
|
|
300880
|
-
if (component.freeSpaceBelow) {
|
|
300881
|
-
attrs.push(`freeSpaceBelow="${component.freeSpaceBelow}"`);
|
|
300882
|
-
}
|
|
300883
|
-
attrs.push(`left="${fmtMm22(component.minX)}"`, `right="${fmtMm22(component.maxX)}"`, `bottom="${fmtMm22(component.minY)}"`, `top="${fmtMm22(component.maxY)}"`);
|
|
300751
|
+
const addFreeSpaceAttribute = (direction2, attributeName) => {
|
|
300752
|
+
const freeSpace = component.freeSpaceByDirection[direction2];
|
|
300753
|
+
if (!freeSpace)
|
|
300754
|
+
return;
|
|
300755
|
+
attrs.push(`${attributeName}="${freeSpace.isAtLeast ? ">" : ""}${fmtMm3(freeSpace.distanceMm)}"`);
|
|
300756
|
+
};
|
|
300757
|
+
addFreeSpaceAttribute("left", "freeSpaceOnLeft");
|
|
300758
|
+
addFreeSpaceAttribute("right", "freeSpaceOnRight");
|
|
300759
|
+
addFreeSpaceAttribute("top", "freeSpaceAbove");
|
|
300760
|
+
addFreeSpaceAttribute("bottom", "freeSpaceBelow");
|
|
300761
|
+
attrs.push(`left="${fmtMm3(component.bounds.minX)}"`, `right="${fmtMm3(component.bounds.maxX)}"`, `bottom="${fmtMm3(component.bounds.minY)}"`, `top="${fmtMm3(component.bounds.maxY)}"`);
|
|
300884
300762
|
return ` <NearbyComponent ${attrs.join(" ")} />`;
|
|
300885
300763
|
};
|
|
300886
300764
|
var lineItemToString2 = (lineItem) => {
|
|
300887
300765
|
switch (lineItem.lineItemType) {
|
|
300888
300766
|
case "CongestedRegion":
|
|
300889
300767
|
return [
|
|
300890
|
-
`<CongestedRegion probabilityOfFailure="${lineItem.probabilityOfFailure}" left="${
|
|
300768
|
+
`<CongestedRegion probabilityOfFailure="${lineItem.probabilityOfFailure}" left="${fmtMm3(lineItem.bounds.minX)}" right="${fmtMm3(lineItem.bounds.maxX)}" bottom="${fmtMm3(lineItem.bounds.minY)}" top="${fmtMm3(lineItem.bounds.maxY)}" width="${fmtMm3(lineItem.width)}" height="${fmtMm3(lineItem.height)}">`,
|
|
300891
300769
|
...lineItem.nearbyComponents.map(nearbyComponentToString),
|
|
300892
300770
|
"</CongestedRegion>"
|
|
300893
300771
|
].join(`
|
package/dist/lib/index.js
CHANGED
|
@@ -65757,7 +65757,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
65757
65757
|
}));
|
|
65758
65758
|
};
|
|
65759
65759
|
// package.json
|
|
65760
|
-
var version = "0.1.
|
|
65760
|
+
var version = "0.1.1904";
|
|
65761
65761
|
var package_default = {
|
|
65762
65762
|
name: "@tscircuit/cli",
|
|
65763
65763
|
version,
|
|
@@ -65771,7 +65771,7 @@ var package_default = {
|
|
|
65771
65771
|
"@biomejs/biome": "^1.9.4",
|
|
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
|
-
"@tscircuit/circuit-json-routing-analysis": "^0.0.
|
|
65774
|
+
"@tscircuit/circuit-json-routing-analysis": "^0.0.8",
|
|
65775
65775
|
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#bb0b41d80c9714695b498e182c2a558f1e0ceb2d",
|
|
65776
65776
|
"@tscircuit/circuit-json-util": "^0.0.105",
|
|
65777
65777
|
"@tscircuit/eval": "^0.0.1016",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1905",
|
|
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/check-shorts": "https://jscdn.tscircuit.com/@tscircuit/check-shorts/0.0.19.tgz",
|
|
13
13
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.9",
|
|
14
|
-
"@tscircuit/circuit-json-routing-analysis": "^0.0.
|
|
14
|
+
"@tscircuit/circuit-json-routing-analysis": "^0.0.8",
|
|
15
15
|
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#bb0b41d80c9714695b498e182c2a558f1e0ceb2d",
|
|
16
16
|
"@tscircuit/circuit-json-util": "^0.0.105",
|
|
17
17
|
"@tscircuit/eval": "^0.0.1016",
|