@tscircuit/core 0.0.2305 → 0.0.2307
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.js +122 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22770,7 +22770,8 @@ function routeSystemBlocks(tree, bounds, initialRoutes) {
|
|
|
22770
22770
|
const labels = /* @__PURE__ */ new Map();
|
|
22771
22771
|
const labelCenters = /* @__PURE__ */ new Map();
|
|
22772
22772
|
const labelAttachments = /* @__PURE__ */ new Map();
|
|
22773
|
-
const portObstacles = [...portsByConnection.values()].flat().map(({ escape }) => ({
|
|
22773
|
+
const portObstacles = [...portsByConnection.values()].flat().map(({ escape, connection }) => ({
|
|
22774
|
+
connection,
|
|
22774
22775
|
left: escape.x - 1,
|
|
22775
22776
|
right: escape.x + 1,
|
|
22776
22777
|
bottom: escape.y - 1,
|
|
@@ -22781,13 +22782,16 @@ function routeSystemBlocks(tree, bounds, initialRoutes) {
|
|
|
22781
22782
|
const center = initialRoutes.get(connection).label_anchor_center;
|
|
22782
22783
|
if (label !== void 0 && center) {
|
|
22783
22784
|
const halfWidth = getSystemConnectionLabelWidth(label) / 2;
|
|
22784
|
-
const occupied = [...obstacles, ...labels.values(), ...portObstacles];
|
|
22785
|
-
const fits = (rectangle) => !occupied.some(
|
|
22786
|
-
(r2) => rectangle.left < r2.right + 1 && rectangle.right > r2.left - 1 && rectangle.bottom < r2.top + 1 && rectangle.top > r2.bottom - 1
|
|
22787
|
-
);
|
|
22788
22785
|
const [start, end] = portsByConnection.get(connection);
|
|
22789
22786
|
const endpoints = tree.endpoints.get(connection);
|
|
22790
22787
|
const selfLoop = endpoints.from === endpoints.to;
|
|
22788
|
+
const occupied = [...obstacles, ...labels.values(), ...portObstacles];
|
|
22789
|
+
const fits = (rectangle, besideOwnLoop = false) => !occupied.some((r2) => {
|
|
22790
|
+
if (besideOwnLoop && "connection" in r2 && r2.connection === connection)
|
|
22791
|
+
return false;
|
|
22792
|
+
const margin = besideOwnLoop && "connection" in r2 ? 0 : 1;
|
|
22793
|
+
return rectangle.left < r2.right + margin && rectangle.right > r2.left - margin && rectangle.bottom < r2.top + margin && rectangle.top > r2.bottom - margin;
|
|
22794
|
+
});
|
|
22791
22795
|
const vertical = start.escape.x === end.escape.x;
|
|
22792
22796
|
const horizontal = start.escape.y === end.escape.y;
|
|
22793
22797
|
const oppositeFaces = (start.side + 2) % 4 === end.side;
|
|
@@ -22804,14 +22808,20 @@ function routeSystemBlocks(tree, bounds, initialRoutes) {
|
|
|
22804
22808
|
};
|
|
22805
22809
|
const signs = selfLoop ? [start.side < 2 ? 1 : -1] : [1, -1];
|
|
22806
22810
|
for (const sign of signs) {
|
|
22807
|
-
const candidate = vertical ? {
|
|
22811
|
+
const candidate = vertical ? {
|
|
22812
|
+
x: attachment.x + sign * (halfWidth + (selfLoop ? 0 : 2)),
|
|
22813
|
+
y: attachment.y
|
|
22814
|
+
} : {
|
|
22815
|
+
x: attachment.x,
|
|
22816
|
+
y: attachment.y + sign * (selfLoop ? 3.5 : 4.5)
|
|
22817
|
+
};
|
|
22808
22818
|
const rectangle = {
|
|
22809
22819
|
left: candidate.x - halfWidth,
|
|
22810
22820
|
right: candidate.x + halfWidth,
|
|
22811
22821
|
bottom: candidate.y - 2.5,
|
|
22812
22822
|
top: candidate.y + 2.5
|
|
22813
22823
|
};
|
|
22814
|
-
if (!fits(rectangle)) continue;
|
|
22824
|
+
if (!fits(rectangle, sameFaceReturn)) continue;
|
|
22815
22825
|
labels.set(connection, rectangle);
|
|
22816
22826
|
labelCenters.set(connection, candidate);
|
|
22817
22827
|
labelAttachments.set(connection, attachment);
|
|
@@ -149707,6 +149717,71 @@ var getDifferentialPairsForSimpleRouteJson = ({
|
|
|
149707
149717
|
return srjDifferentialPairs.length > 0 ? srjDifferentialPairs : void 0;
|
|
149708
149718
|
};
|
|
149709
149719
|
|
|
149720
|
+
// lib/utils/autorouting/getDifferentialPairSourceTraceIds.ts
|
|
149721
|
+
var getDifferentialPairSourceTraceIds = ({
|
|
149722
|
+
differentialPairs,
|
|
149723
|
+
sourceTraces,
|
|
149724
|
+
subcircuitId
|
|
149725
|
+
}) => {
|
|
149726
|
+
const sourceTraceIds = /* @__PURE__ */ new Set();
|
|
149727
|
+
for (const differentialPair of differentialPairs) {
|
|
149728
|
+
const pairSubcircuitId = differentialPair.getSubcircuit().subcircuit_id;
|
|
149729
|
+
if (subcircuitId && pairSubcircuitId !== subcircuitId) continue;
|
|
149730
|
+
const differentialPairSourceTraces = sourceTraces.filter(
|
|
149731
|
+
(trace) => trace.subcircuit_id === pairSubcircuitId
|
|
149732
|
+
);
|
|
149733
|
+
for (const traceNameOrPortSelector of [
|
|
149734
|
+
differentialPair._parsedProps.positiveConnection,
|
|
149735
|
+
differentialPair._parsedProps.negativeConnection
|
|
149736
|
+
]) {
|
|
149737
|
+
sourceTraceIds.add(
|
|
149738
|
+
getDifferentialPairSourceTraceOrThrow({
|
|
149739
|
+
differentialPair,
|
|
149740
|
+
differentialPairSourceTraces,
|
|
149741
|
+
traceNameOrPortSelector
|
|
149742
|
+
}).sourceTraceId
|
|
149743
|
+
);
|
|
149744
|
+
}
|
|
149745
|
+
}
|
|
149746
|
+
return sourceTraceIds;
|
|
149747
|
+
};
|
|
149748
|
+
|
|
149749
|
+
// lib/utils/autorouting/reduceNetConnectionPointsForDifferentialPairPaths.ts
|
|
149750
|
+
var reduceNetConnectionPointsForDifferentialPairPaths = ({
|
|
149751
|
+
netConnections,
|
|
149752
|
+
differentialPairConnections
|
|
149753
|
+
}) => {
|
|
149754
|
+
if (differentialPairConnections.length === 0) return;
|
|
149755
|
+
const parentPointId = /* @__PURE__ */ new Map();
|
|
149756
|
+
const root = (pointId) => {
|
|
149757
|
+
const parent = parentPointId.get(pointId);
|
|
149758
|
+
if (parent === void 0 || parent === pointId) return pointId;
|
|
149759
|
+
const representative = root(parent);
|
|
149760
|
+
parentPointId.set(pointId, representative);
|
|
149761
|
+
return representative;
|
|
149762
|
+
};
|
|
149763
|
+
for (const connection of differentialPairConnections) {
|
|
149764
|
+
const pointIds = connection.pointsToConnect.flatMap(
|
|
149765
|
+
(point8) => point8.pointId ? [point8.pointId] : []
|
|
149766
|
+
);
|
|
149767
|
+
for (const pointId of pointIds.slice(1)) {
|
|
149768
|
+
parentPointId.set(root(pointId), root(pointIds[0]));
|
|
149769
|
+
}
|
|
149770
|
+
}
|
|
149771
|
+
for (const netConnection of netConnections) {
|
|
149772
|
+
const representedPointIds = /* @__PURE__ */ new Set();
|
|
149773
|
+
netConnection.pointsToConnect = netConnection.pointsToConnect.filter(
|
|
149774
|
+
(point8) => {
|
|
149775
|
+
if (!point8.pointId) return true;
|
|
149776
|
+
const representative = root(point8.pointId);
|
|
149777
|
+
if (representedPointIds.has(representative)) return false;
|
|
149778
|
+
representedPointIds.add(representative);
|
|
149779
|
+
return true;
|
|
149780
|
+
}
|
|
149781
|
+
);
|
|
149782
|
+
}
|
|
149783
|
+
};
|
|
149784
|
+
|
|
149710
149785
|
// lib/utils/autorouting/getPreservedRoutedSubcircuitTraces.ts
|
|
149711
149786
|
var getLayerName = (layer) => typeof layer === "string" ? layer : layer.name;
|
|
149712
149787
|
var getPreservedTraceConnectionName = (trace) => trace.source_trace_id ?? trace.connection_name ?? trace.pcb_trace_id;
|
|
@@ -150222,6 +150297,17 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
150222
150297
|
};
|
|
150223
150298
|
};
|
|
150224
150299
|
const sourceTraces = db2.source_trace.list();
|
|
150300
|
+
const differentialPairs = subcircuitComponent?.selectAll("differentialpair") ?? [];
|
|
150301
|
+
const differentialPairSourceTraceIds = getDifferentialPairSourceTraceIds({
|
|
150302
|
+
differentialPairs,
|
|
150303
|
+
sourceTraces,
|
|
150304
|
+
subcircuitId: subcircuit_id
|
|
150305
|
+
});
|
|
150306
|
+
const differentialPairPathSourceTraceIds = new Set(
|
|
150307
|
+
sourceTraces.filter(
|
|
150308
|
+
(trace) => differentialPairSourceTraceIds.has(trace.source_trace_id) && trace.connected_source_port_ids.length === 2
|
|
150309
|
+
).map((trace) => trace.source_trace_id)
|
|
150310
|
+
);
|
|
150225
150311
|
const planeTerminatedSourceTraceLayers = getPlaneTerminatedSourceTraceLayers({
|
|
150226
150312
|
fanoutPourNetMap,
|
|
150227
150313
|
sourceNets: db2.source_net.list(),
|
|
@@ -150239,7 +150325,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
150239
150325
|
).filter(
|
|
150240
150326
|
(trace) => !subcircuit_id || trace.subcircuit_id === subcircuit_id
|
|
150241
150327
|
).filter(
|
|
150242
|
-
(sourceTrace) => sourceTrace.connected_source_net_ids.length === 0 || planeTerminatedSourceTraceLayers.has(sourceTrace.source_trace_id)
|
|
150328
|
+
(sourceTrace) => sourceTrace.connected_source_net_ids.length === 0 || differentialPairPathSourceTraceIds.has(sourceTrace.source_trace_id) || planeTerminatedSourceTraceLayers.has(sourceTrace.source_trace_id)
|
|
150243
150329
|
).map((trace) => {
|
|
150244
150330
|
const connectedPcbPorts = trace.connected_source_port_ids.map(
|
|
150245
150331
|
(sourcePortId) => db2.pcb_port.getWhere({ source_port_id: sourcePortId })
|
|
@@ -150277,6 +150363,14 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
150277
150363
|
]
|
|
150278
150364
|
};
|
|
150279
150365
|
}).filter((c2) => c2 !== null);
|
|
150366
|
+
const differentialPairPathConnections = directTraceConnections.filter(
|
|
150367
|
+
(connection) => connection.source_trace_id !== void 0 && differentialPairPathSourceTraceIds.has(connection.source_trace_id)
|
|
150368
|
+
);
|
|
150369
|
+
const differentialPairPathSourcePortIds = new Set(
|
|
150370
|
+
differentialPairPathConnections.flatMap(
|
|
150371
|
+
(connection) => sourceTraceById.get(connection.source_trace_id).connected_source_port_ids
|
|
150372
|
+
)
|
|
150373
|
+
);
|
|
150280
150374
|
const source_nets = db2.source_net.list().filter((e2) => !subcircuit_id || e2.subcircuit_id === subcircuit_id);
|
|
150281
150375
|
const connectionsFromNets = [];
|
|
150282
150376
|
const connectionFromNetId = /* @__PURE__ */ new Map();
|
|
@@ -150353,6 +150447,15 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
150353
150447
|
sourceTrace.min_trace_thickness
|
|
150354
150448
|
);
|
|
150355
150449
|
}
|
|
150450
|
+
const connectedSourceTraceIds = new Set(
|
|
150451
|
+
connectedSourceTraces.map((trace) => trace.source_trace_id)
|
|
150452
|
+
);
|
|
150453
|
+
for (const connection2 of differentialPairPathConnections) {
|
|
150454
|
+
if (!connectedSourceTraceIds.has(connection2.source_trace_id)) continue;
|
|
150455
|
+
connection2.netConnectionName = net.source_net_id;
|
|
150456
|
+
connection2.nominalTraceWidth = nominalTraceWidthForConnection;
|
|
150457
|
+
connection2.width = nominalTraceWidthForConnection;
|
|
150458
|
+
}
|
|
150356
150459
|
const pointsToConnect = [];
|
|
150357
150460
|
const addedPointIds = /* @__PURE__ */ new Set();
|
|
150358
150461
|
const connectedPcbPorts = [];
|
|
@@ -150367,7 +150470,12 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
150367
150470
|
}
|
|
150368
150471
|
}
|
|
150369
150472
|
pointsToConnect.push(
|
|
150370
|
-
...getSrjConnectionPointsFromPcbTraceHints(
|
|
150473
|
+
...getSrjConnectionPointsFromPcbTraceHints(
|
|
150474
|
+
connectedPcbPorts.filter(
|
|
150475
|
+
(port) => !differentialPairPathSourcePortIds.has(port.source_port_id)
|
|
150476
|
+
),
|
|
150477
|
+
traceHints
|
|
150478
|
+
)
|
|
150371
150479
|
);
|
|
150372
150480
|
const connection = {
|
|
150373
150481
|
name: net.source_net_id ?? sharedConnMap.getNetConnectedToId(net.source_net_id),
|
|
@@ -150436,6 +150544,10 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
150436
150544
|
}
|
|
150437
150545
|
}
|
|
150438
150546
|
}
|
|
150547
|
+
reduceNetConnectionPointsForDifferentialPairPaths({
|
|
150548
|
+
netConnections: connectionsFromNets,
|
|
150549
|
+
differentialPairConnections: differentialPairPathConnections
|
|
150550
|
+
});
|
|
150439
150551
|
const routableConnectionsFromNets = connectionsFromNets.filter(
|
|
150440
150552
|
(connection) => connection.pointsToConnect.length >= 2
|
|
150441
150553
|
);
|
|
@@ -150480,7 +150592,6 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
150480
150592
|
bounds,
|
|
150481
150593
|
connections: allConns
|
|
150482
150594
|
});
|
|
150483
|
-
const differentialPairs = subcircuitComponent?.selectAll("differentialpair") ?? [];
|
|
150484
150595
|
const buses = subcircuitComponent?.selectAll("bus") ?? [];
|
|
150485
150596
|
const srjDifferentialPairs = getDifferentialPairsForSimpleRouteJson({
|
|
150486
150597
|
srjConnections: allConns,
|
|
@@ -159360,7 +159471,7 @@ var RoutingPhasePreparationError = class extends Error {
|
|
|
159360
159471
|
var package_default = {
|
|
159361
159472
|
name: "@tscircuit/core",
|
|
159362
159473
|
type: "module",
|
|
159363
|
-
version: "0.0.
|
|
159474
|
+
version: "0.0.2306",
|
|
159364
159475
|
types: "dist/index.d.ts",
|
|
159365
159476
|
main: "dist/index.js",
|
|
159366
159477
|
module: "dist/index.js",
|