@tscircuit/core 0.0.147 → 0.0.149
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 -15
- package/dist/index.js +187 -185
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -115,24 +115,10 @@ type SchematicBoxPortPositionWithMetadata = {
|
|
|
115
115
|
trueIndex: number;
|
|
116
116
|
pinNumber: number;
|
|
117
117
|
side: "left" | "right" | "top" | "bottom";
|
|
118
|
-
|
|
118
|
+
distanceFromOrthogonalEdge: number;
|
|
119
119
|
x: number;
|
|
120
120
|
y: number;
|
|
121
121
|
};
|
|
122
|
-
/**
|
|
123
|
-
* Get the dimensions of a schematic box based on the provided parameters.
|
|
124
|
-
*
|
|
125
|
-
* A schematic box is a rectangular box with a set of pins on the sides.
|
|
126
|
-
*
|
|
127
|
-
* The user can customize the position of the pins and the spacing between them,
|
|
128
|
-
* this makes computing the box fairly complicated.
|
|
129
|
-
*
|
|
130
|
-
* A note on the internals:
|
|
131
|
-
* * A "true port" refers to a pin/port before it's remapped by the user to a
|
|
132
|
-
* different position. True Pin 1 is guaranteed to be in the top-left corner
|
|
133
|
-
* * We basically iterate over each side and compute how far we are from the
|
|
134
|
-
* edge for that side by adding margins together
|
|
135
|
-
*/
|
|
136
122
|
interface SchematicBoxDimensions {
|
|
137
123
|
pinCount: number;
|
|
138
124
|
getPortPositionByPinNumber(pinNumber: number): SchematicBoxPortPositionWithMetadata | null;
|
package/dist/index.js
CHANGED
|
@@ -1791,7 +1791,7 @@ var Port = class extends PrimitiveComponent {
|
|
|
1791
1791
|
center: portCenter,
|
|
1792
1792
|
source_port_id: this.source_port_id,
|
|
1793
1793
|
facing_direction: this.facingDirection,
|
|
1794
|
-
distance_from_component_edge:
|
|
1794
|
+
distance_from_component_edge: 0.4,
|
|
1795
1795
|
side_of_component: localPortInfo?.side,
|
|
1796
1796
|
pin_number: props.pinNumber,
|
|
1797
1797
|
true_ccw_index: localPortInfo?.trueIndex
|
|
@@ -2072,7 +2072,7 @@ function isExplicitPinMappingArrangement(arrangement) {
|
|
|
2072
2072
|
return arrangement.leftSide !== void 0;
|
|
2073
2073
|
}
|
|
2074
2074
|
var getAllDimensionsForSchematicBox = (params) => {
|
|
2075
|
-
const
|
|
2075
|
+
const portDistanceFromEdge = params.portDistanceFromEdge ?? 0.4;
|
|
2076
2076
|
let sidePinCounts = params.schPortArrangement ? getSizeOfSidesFromPortArrangement(params.schPortArrangement) : null;
|
|
2077
2077
|
const sideLengths = {
|
|
2078
2078
|
left: 0,
|
|
@@ -2083,7 +2083,7 @@ var getAllDimensionsForSchematicBox = (params) => {
|
|
|
2083
2083
|
let pinCount = params.pinCount ?? null;
|
|
2084
2084
|
if (pinCount === null) {
|
|
2085
2085
|
if (sidePinCounts) {
|
|
2086
|
-
pinCount = sidePinCounts.leftSize + sidePinCounts.rightSize + sidePinCounts.topSize
|
|
2086
|
+
pinCount = sidePinCounts.leftSize + sidePinCounts.rightSize + sidePinCounts.topSize;
|
|
2087
2087
|
} else {
|
|
2088
2088
|
throw new Error("Could not determine pin count for the schematic box");
|
|
2089
2089
|
}
|
|
@@ -2105,137 +2105,139 @@ var getAllDimensionsForSchematicBox = (params) => {
|
|
|
2105
2105
|
bottomSize: 0
|
|
2106
2106
|
};
|
|
2107
2107
|
}
|
|
2108
|
-
const schWidth = params.schWidth ?? Math.max(sidePinCounts.topSize, sidePinCounts.bottomSize) * params.schPinSpacing + 2 * componentMargin;
|
|
2109
|
-
const schHeight = params.schHeight ?? Math.max(sidePinCounts.leftSize, sidePinCounts.rightSize) * params.schPinSpacing + 2 * componentMargin;
|
|
2110
|
-
const distributePorts = (sideSize, sideLength, totalMargin) => {
|
|
2111
|
-
if (sideSize <= 1) return 0;
|
|
2112
|
-
return (sideLength - totalMargin) / (sideSize - 1);
|
|
2113
|
-
};
|
|
2114
2108
|
const orderedTruePorts = [];
|
|
2109
|
+
let currentDistanceFromEdge = 0;
|
|
2115
2110
|
let truePinIndex = 0;
|
|
2116
|
-
|
|
2117
|
-
const
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2111
|
+
for (let sideIndex = 0; sideIndex < sidePinCounts.leftSize; sideIndex++) {
|
|
2112
|
+
const pinNumber = params.schPortArrangement && isExplicitPinMappingArrangement(params.schPortArrangement) ? params.schPortArrangement?.leftSide?.pins[sideIndex] : truePinIndex + 1;
|
|
2113
|
+
const pinStyle = params.schPinStyle?.[`pin${pinNumber}`] ?? params.schPinStyle?.[pinNumber];
|
|
2114
|
+
if (pinStyle?.topMargin) {
|
|
2115
|
+
currentDistanceFromEdge += pinStyle.topMargin;
|
|
2116
|
+
}
|
|
2117
|
+
orderedTruePorts.push({
|
|
2118
|
+
trueIndex: truePinIndex,
|
|
2119
|
+
pinNumber,
|
|
2120
|
+
side: "left",
|
|
2121
|
+
distanceFromOrthogonalEdge: currentDistanceFromEdge
|
|
2122
|
+
});
|
|
2123
|
+
if (pinStyle?.bottomMargin) {
|
|
2124
|
+
currentDistanceFromEdge += pinStyle.bottomMargin;
|
|
2129
2125
|
}
|
|
2130
|
-
const
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
orderedTruePorts.push({
|
|
2154
|
-
trueIndex: truePinIndex,
|
|
2155
|
-
pinNumber,
|
|
2156
|
-
side,
|
|
2157
|
-
distanceFromEdge: currentDistanceFromEdge,
|
|
2158
|
-
x: 0,
|
|
2159
|
-
y: 0
|
|
2160
|
-
});
|
|
2161
|
-
if (pinStyle) {
|
|
2162
|
-
if (isVertical) {
|
|
2163
|
-
if (side === "left") {
|
|
2164
|
-
currentDistanceFromEdge += direction === "top-to-bottom" ? pinStyle.bottomMargin ?? 0 : pinStyle.topMargin ?? 0;
|
|
2165
|
-
} else {
|
|
2166
|
-
currentDistanceFromEdge += direction === "top-to-bottom" ? pinStyle.topMargin ?? 0 : pinStyle.bottomMargin ?? 0;
|
|
2167
|
-
}
|
|
2168
|
-
} else {
|
|
2169
|
-
if (side === "top") {
|
|
2170
|
-
currentDistanceFromEdge += direction === "left-to-right" ? pinStyle.rightMargin ?? 0 : pinStyle.leftMargin ?? 0;
|
|
2171
|
-
} else {
|
|
2172
|
-
currentDistanceFromEdge += direction === "left-to-right" ? pinStyle.leftMargin ?? 0 : pinStyle.rightMargin ?? 0;
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
currentDistanceFromEdge += spacing;
|
|
2177
|
-
truePinIndex++;
|
|
2126
|
+
const isLastPinOnSide = sideIndex === sidePinCounts.leftSize - 1;
|
|
2127
|
+
if (!isLastPinOnSide) {
|
|
2128
|
+
currentDistanceFromEdge += params.schPinSpacing;
|
|
2129
|
+
} else {
|
|
2130
|
+
sideLengths.left = currentDistanceFromEdge;
|
|
2131
|
+
}
|
|
2132
|
+
truePinIndex++;
|
|
2133
|
+
}
|
|
2134
|
+
currentDistanceFromEdge = 0;
|
|
2135
|
+
for (let sideIndex = 0; sideIndex < sidePinCounts.bottomSize; sideIndex++) {
|
|
2136
|
+
const pinNumber = params.schPortArrangement && isExplicitPinMappingArrangement(params.schPortArrangement) ? params.schPortArrangement.bottomSide?.pins[sideIndex] : truePinIndex + 1;
|
|
2137
|
+
const pinStyle = params.schPinStyle?.[`pin${pinNumber}`] ?? params.schPinStyle?.[pinNumber];
|
|
2138
|
+
if (pinStyle?.leftMargin) {
|
|
2139
|
+
currentDistanceFromEdge += pinStyle.leftMargin;
|
|
2140
|
+
}
|
|
2141
|
+
orderedTruePorts.push({
|
|
2142
|
+
trueIndex: truePinIndex,
|
|
2143
|
+
pinNumber,
|
|
2144
|
+
side: "bottom",
|
|
2145
|
+
distanceFromOrthogonalEdge: currentDistanceFromEdge
|
|
2178
2146
|
});
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
if (params.schPortArrangement && isExplicitPinMappingArrangement(params.schPortArrangement)) {
|
|
2182
|
-
if (params.schPortArrangement.leftSide) {
|
|
2183
|
-
processSide(
|
|
2184
|
-
"left",
|
|
2185
|
-
params.schPortArrangement.leftSide.pins,
|
|
2186
|
-
params.schPortArrangement.leftSide.direction ?? "top-to-bottom"
|
|
2187
|
-
);
|
|
2147
|
+
if (pinStyle?.rightMargin) {
|
|
2148
|
+
currentDistanceFromEdge += pinStyle.rightMargin;
|
|
2188
2149
|
}
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2150
|
+
const isLastPinOnSide = sideIndex === sidePinCounts.bottomSize - 1;
|
|
2151
|
+
if (!isLastPinOnSide) {
|
|
2152
|
+
currentDistanceFromEdge += params.schPinSpacing;
|
|
2153
|
+
} else {
|
|
2154
|
+
sideLengths.bottom = currentDistanceFromEdge;
|
|
2155
|
+
}
|
|
2156
|
+
truePinIndex++;
|
|
2157
|
+
}
|
|
2158
|
+
currentDistanceFromEdge = 0;
|
|
2159
|
+
for (let sideIndex = 0; sideIndex < sidePinCounts.rightSize; sideIndex++) {
|
|
2160
|
+
const pinNumber = params.schPortArrangement && isExplicitPinMappingArrangement(params.schPortArrangement) ? params.schPortArrangement.rightSide?.pins[sideIndex] : truePinIndex + 1;
|
|
2161
|
+
const pinStyle = params.schPinStyle?.[`pin${pinNumber}`] ?? params.schPinStyle?.[pinNumber];
|
|
2162
|
+
if (pinStyle?.bottomMargin) {
|
|
2163
|
+
currentDistanceFromEdge += pinStyle.bottomMargin;
|
|
2164
|
+
}
|
|
2165
|
+
orderedTruePorts.push({
|
|
2166
|
+
trueIndex: truePinIndex,
|
|
2167
|
+
pinNumber,
|
|
2168
|
+
side: "right",
|
|
2169
|
+
distanceFromOrthogonalEdge: currentDistanceFromEdge
|
|
2170
|
+
});
|
|
2171
|
+
if (pinStyle?.topMargin) {
|
|
2172
|
+
currentDistanceFromEdge += pinStyle.topMargin;
|
|
2195
2173
|
}
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2174
|
+
const isLastPinOnSide = sideIndex === sidePinCounts.rightSize - 1;
|
|
2175
|
+
if (!isLastPinOnSide) {
|
|
2176
|
+
currentDistanceFromEdge += params.schPinSpacing;
|
|
2177
|
+
} else {
|
|
2178
|
+
sideLengths.right = currentDistanceFromEdge;
|
|
2179
|
+
}
|
|
2180
|
+
truePinIndex++;
|
|
2181
|
+
}
|
|
2182
|
+
currentDistanceFromEdge = 0;
|
|
2183
|
+
for (let sideIndex = 0; sideIndex < sidePinCounts.topSize; sideIndex++) {
|
|
2184
|
+
const pinNumber = params.schPortArrangement && isExplicitPinMappingArrangement(params.schPortArrangement) ? params.schPortArrangement.topSide?.pins[sideIndex] : truePinIndex + 1;
|
|
2185
|
+
const pinStyle = params.schPinStyle?.[`pin${pinNumber}`] ?? params.schPinStyle?.[pinNumber];
|
|
2186
|
+
if (pinStyle?.rightMargin) {
|
|
2187
|
+
currentDistanceFromEdge += pinStyle.rightMargin;
|
|
2188
|
+
}
|
|
2189
|
+
orderedTruePorts.push({
|
|
2190
|
+
trueIndex: truePinIndex,
|
|
2191
|
+
pinNumber,
|
|
2192
|
+
side: "top",
|
|
2193
|
+
distanceFromOrthogonalEdge: currentDistanceFromEdge
|
|
2194
|
+
});
|
|
2195
|
+
if (pinStyle?.leftMargin) {
|
|
2196
|
+
currentDistanceFromEdge += pinStyle.leftMargin;
|
|
2202
2197
|
}
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
);
|
|
2198
|
+
const isLastPinOnSide = sideIndex === sidePinCounts.topSize - 1;
|
|
2199
|
+
if (!isLastPinOnSide) {
|
|
2200
|
+
currentDistanceFromEdge += params.schPinSpacing;
|
|
2201
|
+
} else {
|
|
2202
|
+
sideLengths.top = currentDistanceFromEdge;
|
|
2209
2203
|
}
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
(_, i) => i + sidePinCounts.leftSize + 1
|
|
2218
|
-
);
|
|
2219
|
-
const topSide = Array.from(
|
|
2220
|
-
{ length: sidePinCounts.topSize },
|
|
2221
|
-
(_, i) => i + sidePinCounts.leftSize + sidePinCounts.rightSize + 1
|
|
2204
|
+
truePinIndex++;
|
|
2205
|
+
}
|
|
2206
|
+
let schWidth = params.schWidth;
|
|
2207
|
+
if (!schWidth) {
|
|
2208
|
+
schWidth = Math.max(
|
|
2209
|
+
sideLengths.top + params.schPinSpacing * 2,
|
|
2210
|
+
sideLengths.bottom + params.schPinSpacing * 2
|
|
2222
2211
|
);
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2212
|
+
}
|
|
2213
|
+
let schHeight = params.schHeight;
|
|
2214
|
+
if (!schHeight) {
|
|
2215
|
+
schHeight = Math.max(
|
|
2216
|
+
sideLengths.left + params.schPinSpacing * 2,
|
|
2217
|
+
sideLengths.right + params.schPinSpacing * 2
|
|
2228
2218
|
);
|
|
2229
|
-
processSide("left", leftSide, "top-to-bottom");
|
|
2230
|
-
processSide("right", rightSide, "top-to-bottom");
|
|
2231
|
-
processSide("top", topSide, "left-to-right");
|
|
2232
|
-
processSide("bottom", bottomSide, "left-to-right");
|
|
2233
2219
|
}
|
|
2234
2220
|
const trueEdgePositions = {
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2221
|
+
// Top left corner
|
|
2222
|
+
left: {
|
|
2223
|
+
x: -schWidth / 2 - portDistanceFromEdge,
|
|
2224
|
+
y: sideLengths.left / 2
|
|
2225
|
+
},
|
|
2226
|
+
// bottom left corner
|
|
2227
|
+
bottom: {
|
|
2228
|
+
x: -sideLengths.bottom / 2,
|
|
2229
|
+
y: -schHeight / 2 - portDistanceFromEdge
|
|
2230
|
+
},
|
|
2231
|
+
// bottom right corner
|
|
2232
|
+
right: {
|
|
2233
|
+
x: schWidth / 2 + portDistanceFromEdge,
|
|
2234
|
+
y: -sideLengths.right / 2
|
|
2235
|
+
},
|
|
2236
|
+
// top right corner
|
|
2237
|
+
top: {
|
|
2238
|
+
x: sideLengths.top / 2,
|
|
2239
|
+
y: schHeight / 2 + portDistanceFromEdge
|
|
2240
|
+
}
|
|
2239
2241
|
};
|
|
2240
2242
|
const trueEdgeTraversalDirections = {
|
|
2241
2243
|
left: { x: 0, y: -1 },
|
|
@@ -2244,13 +2246,13 @@ var getAllDimensionsForSchematicBox = (params) => {
|
|
|
2244
2246
|
bottom: { x: 1, y: 0 }
|
|
2245
2247
|
};
|
|
2246
2248
|
const truePortsWithPositions = orderedTruePorts.map((p) => {
|
|
2247
|
-
const {
|
|
2249
|
+
const { distanceFromOrthogonalEdge, side } = p;
|
|
2248
2250
|
const edgePos = trueEdgePositions[side];
|
|
2249
2251
|
const edgeDir = trueEdgeTraversalDirections[side];
|
|
2250
2252
|
return {
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2253
|
+
x: edgePos.x + distanceFromOrthogonalEdge * edgeDir.x,
|
|
2254
|
+
y: edgePos.y + distanceFromOrthogonalEdge * edgeDir.y,
|
|
2255
|
+
...p
|
|
2254
2256
|
};
|
|
2255
2257
|
});
|
|
2256
2258
|
return {
|
|
@@ -3300,38 +3302,6 @@ function getClosest(point, candidates) {
|
|
|
3300
3302
|
return closest;
|
|
3301
3303
|
}
|
|
3302
3304
|
|
|
3303
|
-
// lib/utils/projectPointInDirection.ts
|
|
3304
|
-
var projectPointInDirection = (point, direction, distance) => {
|
|
3305
|
-
switch (direction) {
|
|
3306
|
-
case "up":
|
|
3307
|
-
return { x: point.x, y: point.y + distance };
|
|
3308
|
-
case "down":
|
|
3309
|
-
return { x: point.x, y: point.y - distance };
|
|
3310
|
-
case "left":
|
|
3311
|
-
return { x: point.x + distance, y: point.y };
|
|
3312
|
-
case "right":
|
|
3313
|
-
return { x: point.x - distance, y: point.y };
|
|
3314
|
-
default:
|
|
3315
|
-
throw new Error(`Unknown direction "${direction}"`);
|
|
3316
|
-
}
|
|
3317
|
-
};
|
|
3318
|
-
|
|
3319
|
-
// lib/utils/projectPointInOppositeDirection.ts
|
|
3320
|
-
var projectPointInOppositeDirection = (point, direction, distance) => {
|
|
3321
|
-
switch (direction) {
|
|
3322
|
-
case "up":
|
|
3323
|
-
return { x: point.x, y: point.y + distance };
|
|
3324
|
-
case "down":
|
|
3325
|
-
return { x: point.x, y: point.y - distance };
|
|
3326
|
-
case "left":
|
|
3327
|
-
return { x: point.x + distance, y: point.y };
|
|
3328
|
-
case "right":
|
|
3329
|
-
return { x: point.x - distance, y: point.y };
|
|
3330
|
-
default:
|
|
3331
|
-
throw new Error(`Unknown direction "${direction}"`);
|
|
3332
|
-
}
|
|
3333
|
-
};
|
|
3334
|
-
|
|
3335
3305
|
// lib/utils/try-now.ts
|
|
3336
3306
|
function tryNow(fn) {
|
|
3337
3307
|
try {
|
|
@@ -3343,6 +3313,56 @@ function tryNow(fn) {
|
|
|
3343
3313
|
|
|
3344
3314
|
// lib/components/primitive-components/Trace.ts
|
|
3345
3315
|
import "zod";
|
|
3316
|
+
|
|
3317
|
+
// lib/utils/autorouting/getDominantDirection.ts
|
|
3318
|
+
function getDominantDirection(edge) {
|
|
3319
|
+
const delta = {
|
|
3320
|
+
x: edge.to.x - edge.from.x,
|
|
3321
|
+
y: edge.to.y - edge.from.y
|
|
3322
|
+
};
|
|
3323
|
+
const absX = Math.abs(delta.x);
|
|
3324
|
+
const absY = Math.abs(delta.y);
|
|
3325
|
+
if (absX > absY) {
|
|
3326
|
+
return delta.x > 0 ? "right" : "left";
|
|
3327
|
+
}
|
|
3328
|
+
return delta.y > 0 ? "down" : "up";
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
// lib/utils/schematic/getStubEdges.ts
|
|
3332
|
+
var getStubEdges = ({
|
|
3333
|
+
lastEdge,
|
|
3334
|
+
lastEdgePort,
|
|
3335
|
+
lastDominantDirection
|
|
3336
|
+
}) => {
|
|
3337
|
+
const edges = [];
|
|
3338
|
+
if (lastEdge && lastEdgePort) {
|
|
3339
|
+
const intermediatePoint = { x: lastEdge.to.x, y: lastEdge.to.y };
|
|
3340
|
+
if (lastDominantDirection === "left" || lastDominantDirection === "right") {
|
|
3341
|
+
intermediatePoint.x = lastEdgePort.position.x;
|
|
3342
|
+
edges.push({
|
|
3343
|
+
from: lastEdge.to,
|
|
3344
|
+
to: { ...intermediatePoint }
|
|
3345
|
+
});
|
|
3346
|
+
edges.push({
|
|
3347
|
+
from: intermediatePoint,
|
|
3348
|
+
to: { ...lastEdgePort.position }
|
|
3349
|
+
});
|
|
3350
|
+
} else {
|
|
3351
|
+
intermediatePoint.y = lastEdgePort.position.y;
|
|
3352
|
+
edges.push({
|
|
3353
|
+
from: lastEdge.to,
|
|
3354
|
+
to: { ...intermediatePoint }
|
|
3355
|
+
});
|
|
3356
|
+
edges.push({
|
|
3357
|
+
from: intermediatePoint,
|
|
3358
|
+
to: { ...lastEdgePort.position }
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
return edges;
|
|
3363
|
+
};
|
|
3364
|
+
|
|
3365
|
+
// lib/components/primitive-components/Trace.ts
|
|
3346
3366
|
var portToObjective = (port) => {
|
|
3347
3367
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
3348
3368
|
return {
|
|
@@ -3750,7 +3770,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3750
3770
|
const { db } = this.root;
|
|
3751
3771
|
const { _parsedProps: props, parent } = this;
|
|
3752
3772
|
if (!parent) throw new Error("Trace has no parent");
|
|
3753
|
-
const { allPortsFound, portsWithSelectors:
|
|
3773
|
+
const { allPortsFound, portsWithSelectors: connectedPorts } = this._findConnectedPorts();
|
|
3754
3774
|
if (!allPortsFound) return;
|
|
3755
3775
|
const obstacles = [];
|
|
3756
3776
|
const connection = {
|
|
@@ -3779,7 +3799,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3779
3799
|
});
|
|
3780
3800
|
}
|
|
3781
3801
|
}
|
|
3782
|
-
const portsWithPosition =
|
|
3802
|
+
const portsWithPosition = connectedPorts.map(({ port }) => ({
|
|
3783
3803
|
port,
|
|
3784
3804
|
position: port._getGlobalSchematicPositionAfterLayout(),
|
|
3785
3805
|
schematic_port_id: port.schematic_port_id ?? void 0,
|
|
@@ -3811,8 +3831,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3811
3831
|
});
|
|
3812
3832
|
const results = autorouter.solveAndMapToTraces();
|
|
3813
3833
|
if (results.length === 0) return;
|
|
3814
|
-
const [
|
|
3815
|
-
const { route } = result;
|
|
3834
|
+
const [{ route }] = results;
|
|
3816
3835
|
const edges = [];
|
|
3817
3836
|
for (let i = 0; i < route.length - 1; i++) {
|
|
3818
3837
|
edges.push({
|
|
@@ -3820,29 +3839,12 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3820
3839
|
to: route[i + 1]
|
|
3821
3840
|
});
|
|
3822
3841
|
}
|
|
3823
|
-
const
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
STUB_LENGTH
|
|
3830
|
-
)
|
|
3831
|
-
},
|
|
3832
|
-
to: route[0],
|
|
3833
|
-
from_schematic_port_id: portsWithPosition[0].schematic_port_id
|
|
3834
|
-
});
|
|
3835
|
-
edges.push({
|
|
3836
|
-
from: route[route.length - 1],
|
|
3837
|
-
to: {
|
|
3838
|
-
...projectPointInOppositeDirection(
|
|
3839
|
-
route[route.length - 1],
|
|
3840
|
-
portsWithPosition[1].facingDirection,
|
|
3841
|
-
STUB_LENGTH
|
|
3842
|
-
)
|
|
3843
|
-
},
|
|
3844
|
-
from_schematic_port_id: portsWithPosition[1].schematic_port_id
|
|
3845
|
-
});
|
|
3842
|
+
const lastEdge = edges[edges.length - 1];
|
|
3843
|
+
const lastEdgePort = portsWithPosition[portsWithPosition.length - 1];
|
|
3844
|
+
const lastDominantDirection = getDominantDirection(lastEdge);
|
|
3845
|
+
edges.push(
|
|
3846
|
+
...getStubEdges({ lastEdge, lastEdgePort, lastDominantDirection })
|
|
3847
|
+
);
|
|
3846
3848
|
const trace = db.schematic_trace.insert({
|
|
3847
3849
|
source_trace_id: this.source_trace_id,
|
|
3848
3850
|
edges
|
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.149",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@tscircuit/soup-util": "^0.0.33",
|
|
46
46
|
"circuit-json": "^0.0.93",
|
|
47
47
|
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
48
|
-
"circuit-to-svg": "^0.0.
|
|
48
|
+
"circuit-to-svg": "^0.0.58",
|
|
49
49
|
"nanoid": "^5.0.7",
|
|
50
50
|
"performance-now": "^2.1.0",
|
|
51
51
|
"react": "^18.3.1",
|