@tscircuit/core 0.0.487 → 0.0.489
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 -0
- package/dist/index.js +50 -13
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -760,6 +760,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
760
760
|
ports?: undefined;
|
|
761
761
|
portsWithSelectors?: undefined;
|
|
762
762
|
};
|
|
763
|
+
_resolveNet(selector: string): Net | null;
|
|
763
764
|
_findConnectedNets(): {
|
|
764
765
|
nets: Net[];
|
|
765
766
|
netsWithSelectors: Array<{
|
package/dist/index.js
CHANGED
|
@@ -4668,11 +4668,24 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4668
4668
|
ports: portsWithSelectors.map(({ port }) => port)
|
|
4669
4669
|
};
|
|
4670
4670
|
}
|
|
4671
|
+
_resolveNet(selector) {
|
|
4672
|
+
const direct = this.getSubcircuit().selectOne(selector, {
|
|
4673
|
+
type: "net"
|
|
4674
|
+
});
|
|
4675
|
+
if (direct) return direct;
|
|
4676
|
+
const match = selector.match(/^net\.(.+)$/);
|
|
4677
|
+
const netName = match ? match[1] : null;
|
|
4678
|
+
if (!netName) return null;
|
|
4679
|
+
const allDescendants = this.root._getBoard().getDescendants();
|
|
4680
|
+
return allDescendants.find(
|
|
4681
|
+
(d) => d.componentName === "Net" && d._parsedProps.name === netName
|
|
4682
|
+
) || null;
|
|
4683
|
+
}
|
|
4671
4684
|
_findConnectedNets() {
|
|
4672
4685
|
const netsWithSelectors = this.getTracePathNetSelectors().map(
|
|
4673
4686
|
(selector) => ({
|
|
4674
4687
|
selector,
|
|
4675
|
-
net: this.
|
|
4688
|
+
net: this._resolveNet(selector)
|
|
4676
4689
|
})
|
|
4677
4690
|
);
|
|
4678
4691
|
const undefinedNets = netsWithSelectors.filter((n) => !n.net);
|
|
@@ -5179,10 +5192,35 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
5179
5192
|
facingDirection: port.facingDirection
|
|
5180
5193
|
}));
|
|
5181
5194
|
const isPortAndNetConnection = portsWithPosition.length === 1 && netsWithSelectors.length === 1;
|
|
5182
|
-
if (
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5195
|
+
if (isPortAndNetConnection) {
|
|
5196
|
+
const net = netsWithSelectors[0].net;
|
|
5197
|
+
const { port, position: anchorPos } = portsWithPosition[0];
|
|
5198
|
+
const connectedNetLabel = this.getSubcircuit().selectAll("netlabel").find((nl) => {
|
|
5199
|
+
const conn = nl._parsedProps.connection ?? nl._parsedProps.connectsTo;
|
|
5200
|
+
if (!conn) return false;
|
|
5201
|
+
const targetPort = this.getSubcircuit().selectOne(conn, {
|
|
5202
|
+
port: true
|
|
5203
|
+
});
|
|
5204
|
+
return targetPort === port;
|
|
5205
|
+
});
|
|
5206
|
+
if (connectedNetLabel) {
|
|
5207
|
+
const labelPos = connectedNetLabel._getGlobalSchematicPositionBeforeLayout();
|
|
5208
|
+
const edges2 = [];
|
|
5209
|
+
if (anchorPos.x === labelPos.x || anchorPos.y === labelPos.y) {
|
|
5210
|
+
edges2.push({ from: anchorPos, to: labelPos });
|
|
5211
|
+
} else {
|
|
5212
|
+
edges2.push({ from: anchorPos, to: { x: labelPos.x, y: anchorPos.y } });
|
|
5213
|
+
edges2.push({ from: { x: labelPos.x, y: anchorPos.y }, to: labelPos });
|
|
5214
|
+
}
|
|
5215
|
+
const trace2 = db.schematic_trace.insert({
|
|
5216
|
+
source_trace_id: this.source_trace_id,
|
|
5217
|
+
edges: edges2,
|
|
5218
|
+
junctions: []
|
|
5219
|
+
});
|
|
5220
|
+
this.schematic_trace_id = trace2.schematic_trace_id;
|
|
5221
|
+
return;
|
|
5222
|
+
}
|
|
5223
|
+
if (this.props.schDisplayLabel) {
|
|
5186
5224
|
db.schematic_net_label.insert({
|
|
5187
5225
|
text: this.props.schDisplayLabel,
|
|
5188
5226
|
source_net_id: net.source_net_id,
|
|
@@ -5191,14 +5229,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
5191
5229
|
anchor_side: getEnteringEdgeFromDirection(port.facingDirection) ?? "bottom"
|
|
5192
5230
|
});
|
|
5193
5231
|
return;
|
|
5194
|
-
} else if ("from" in this.props && "to" in this.props || "path" in this.props) {
|
|
5195
|
-
this._doInitialSchematicTraceRenderWithDisplayLabel();
|
|
5196
|
-
return;
|
|
5197
5232
|
}
|
|
5198
|
-
}
|
|
5199
|
-
if (isPortAndNetConnection) {
|
|
5200
|
-
const net = netsWithSelectors[0].net;
|
|
5201
|
-
const { port, position: anchorPos } = portsWithPosition[0];
|
|
5202
5233
|
const netLabel = db.schematic_net_label.insert({
|
|
5203
5234
|
text: net._parsedProps.name,
|
|
5204
5235
|
source_net_id: net.source_net_id,
|
|
@@ -5209,6 +5240,12 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
5209
5240
|
});
|
|
5210
5241
|
return;
|
|
5211
5242
|
}
|
|
5243
|
+
if (this.props.schDisplayLabel) {
|
|
5244
|
+
if ("from" in this.props && "to" in this.props || "path" in this.props) {
|
|
5245
|
+
this._doInitialSchematicTraceRenderWithDisplayLabel();
|
|
5246
|
+
return;
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5212
5249
|
if (portsWithPosition.length < 2) {
|
|
5213
5250
|
return;
|
|
5214
5251
|
}
|
|
@@ -10228,7 +10265,7 @@ import { identity as identity4 } from "transformation-matrix";
|
|
|
10228
10265
|
var package_default = {
|
|
10229
10266
|
name: "@tscircuit/core",
|
|
10230
10267
|
type: "module",
|
|
10231
|
-
version: "0.0.
|
|
10268
|
+
version: "0.0.487",
|
|
10232
10269
|
types: "dist/index.d.ts",
|
|
10233
10270
|
main: "dist/index.js",
|
|
10234
10271
|
module: "dist/index.js",
|