@tscircuit/core 0.0.224 → 0.0.226
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 +2 -1
- package/dist/index.js +48 -15
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { Matrix } from 'transformation-matrix';
|
|
|
9
9
|
import { SoupUtilObjects } from '@tscircuit/soup-util';
|
|
10
10
|
import * as _tscircuit_layout from '@tscircuit/layout';
|
|
11
11
|
|
|
12
|
-
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortDiscovery", "PortMatching", "SourceTraceRender", "SourceAddConnectivityMapKey", "SchematicComponentRender", "SchematicPortRender", "SchematicLayout", "SchematicTraceRender", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbLayout", "
|
|
12
|
+
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortDiscovery", "PortMatching", "SourceTraceRender", "SourceAddConnectivityMapKey", "SchematicComponentRender", "SchematicPortRender", "SchematicLayout", "SchematicTraceRender", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbLayout", "PcbComponentSizeCalculation", "PcbTraceRender", "PcbTraceHintRender", "PcbRouteNetIslands", "CadModelRender", "PartsEngineRender"];
|
|
13
13
|
type RenderPhase = (typeof orderedRenderPhases)[number];
|
|
14
14
|
type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
|
|
15
15
|
type RenderPhaseStates = Record<RenderPhase, {
|
|
@@ -614,6 +614,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
614
614
|
doInitialSourceTraceRender(): void;
|
|
615
615
|
doInitialPcbTraceRender(): void;
|
|
616
616
|
_doInitialSchematicTraceRenderWithDisplayLabel(): void;
|
|
617
|
+
private _isPassiveToChipConnection;
|
|
617
618
|
doInitialSchematicTraceRender(): void;
|
|
618
619
|
}
|
|
619
620
|
|
package/dist/index.js
CHANGED
|
@@ -77,10 +77,10 @@ var orderedRenderPhases = [
|
|
|
77
77
|
"PcbPortRender",
|
|
78
78
|
"PcbPortAttachment",
|
|
79
79
|
"PcbLayout",
|
|
80
|
+
"PcbComponentSizeCalculation",
|
|
80
81
|
"PcbTraceRender",
|
|
81
82
|
"PcbTraceHintRender",
|
|
82
83
|
"PcbRouteNetIslands",
|
|
83
|
-
"PcbComponentSizeCalculation",
|
|
84
84
|
"CadModelRender",
|
|
85
85
|
"PartsEngineRender"
|
|
86
86
|
];
|
|
@@ -4152,6 +4152,21 @@ var pushEdgesOfSchematicTraceToPreventOverlap = ({
|
|
|
4152
4152
|
}
|
|
4153
4153
|
};
|
|
4154
4154
|
|
|
4155
|
+
// lib/utils/schematic/countComplexElements.ts
|
|
4156
|
+
var countComplexElements = (junctions, edges) => {
|
|
4157
|
+
let count = 0;
|
|
4158
|
+
count += junctions.length ?? 0;
|
|
4159
|
+
count += edges.filter((edge) => edge.is_crossing).length;
|
|
4160
|
+
for (let i = 1; i < edges.length; i++) {
|
|
4161
|
+
const prev = edges[i - 1];
|
|
4162
|
+
const curr = edges[i];
|
|
4163
|
+
const prevVertical = Math.abs(prev.from.x - prev.to.x) < 0.01;
|
|
4164
|
+
const currVertical = Math.abs(curr.from.x - curr.to.x) < 0.01;
|
|
4165
|
+
if (prevVertical !== currVertical) count++;
|
|
4166
|
+
}
|
|
4167
|
+
return count;
|
|
4168
|
+
};
|
|
4169
|
+
|
|
4155
4170
|
// lib/components/primitive-components/Trace/Trace.ts
|
|
4156
4171
|
var portToObjective = (port) => {
|
|
4157
4172
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
@@ -4577,7 +4592,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4577
4592
|
const portsWithPosition = connectedPorts.map(({ port }) => ({
|
|
4578
4593
|
port,
|
|
4579
4594
|
position: port._getGlobalSchematicPositionAfterLayout(),
|
|
4580
|
-
schematic_port_id: port.schematic_port_id
|
|
4595
|
+
schematic_port_id: port.schematic_port_id,
|
|
4581
4596
|
facingDirection: port.facingDirection
|
|
4582
4597
|
}));
|
|
4583
4598
|
if (portsWithPosition.length < 2) {
|
|
@@ -4614,26 +4629,40 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4614
4629
|
}
|
|
4615
4630
|
const existingFromNetLabel = db.schematic_net_label.list().find((label) => label.source_net_id === fromPort.source_port_id);
|
|
4616
4631
|
const existingToNetLabel = db.schematic_net_label.list().find((label) => label.source_net_id === toPort.source_port_id);
|
|
4617
|
-
if (
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4632
|
+
if (this.props.schDisplayLabel) {
|
|
4633
|
+
if (existingFromNetLabel && existingFromNetLabel.text !== this.props.schDisplayLabel || existingToNetLabel && existingToNetLabel?.text !== this.props.schDisplayLabel) {
|
|
4634
|
+
throw new Error(
|
|
4635
|
+
`Cannot create net label for port ${existingFromNetLabel ? fromPortName : toPortName} because it already has a net label with text "${existingFromNetLabel ? existingFromNetLabel.text : existingToNetLabel?.text}".`
|
|
4636
|
+
);
|
|
4637
|
+
}
|
|
4621
4638
|
}
|
|
4639
|
+
const [firstPort, secondPort] = connectedPorts.map(({ port }) => port);
|
|
4640
|
+
const isFirstPortSchematicBox = firstPort.parent?.config.shouldRenderAsSchematicBox;
|
|
4641
|
+
const pinFullName = isFirstPortSchematicBox ? `${firstPort?.parent?.props.name}_${firstPort?.props.name}` : `${secondPort?.parent?.props.name}_${secondPort?.props.name}`;
|
|
4622
4642
|
db.schematic_net_label.insert({
|
|
4623
|
-
text: this.props.schDisplayLabel,
|
|
4643
|
+
text: this.props.schDisplayLabel ?? pinFullName,
|
|
4624
4644
|
source_net_id: fromPort.source_port_id,
|
|
4625
4645
|
anchor_position: fromAnchorPos,
|
|
4626
4646
|
center: fromAnchorPos,
|
|
4627
4647
|
anchor_side: getEnteringEdgeFromDirection(fromPort.facingDirection) ?? "bottom"
|
|
4628
4648
|
});
|
|
4629
4649
|
db.schematic_net_label.insert({
|
|
4630
|
-
text: this.props.schDisplayLabel,
|
|
4650
|
+
text: this.props.schDisplayLabel ?? pinFullName,
|
|
4631
4651
|
source_net_id: toPort.source_port_id,
|
|
4632
4652
|
anchor_position: toAnchorPos,
|
|
4633
4653
|
center: toAnchorPos,
|
|
4634
4654
|
anchor_side: getEnteringEdgeFromDirection(toPort.facingDirection) ?? "bottom"
|
|
4635
4655
|
});
|
|
4636
4656
|
}
|
|
4657
|
+
_isPassiveToChipConnection() {
|
|
4658
|
+
const { allPortsFound, ports } = this._findConnectedPorts();
|
|
4659
|
+
if (!allPortsFound || ports.length !== 2) return false;
|
|
4660
|
+
const [port1, port2] = ports;
|
|
4661
|
+
if (!port1?.parent || !port2?.parent) return false;
|
|
4662
|
+
const isPort1Chip = port1.parent.config.shouldRenderAsSchematicBox;
|
|
4663
|
+
const isPort2Chip = port2.parent.config.shouldRenderAsSchematicBox;
|
|
4664
|
+
return isPort1Chip && !isPort2Chip || !isPort1Chip && isPort2Chip;
|
|
4665
|
+
}
|
|
4637
4666
|
doInitialSchematicTraceRender() {
|
|
4638
4667
|
if (this.root?.schematicDisabled) return;
|
|
4639
4668
|
const { db } = this.root;
|
|
@@ -4677,7 +4706,6 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4677
4706
|
type: "rect",
|
|
4678
4707
|
layers: ["top"],
|
|
4679
4708
|
center: elm.position,
|
|
4680
|
-
// Approximate text bounds based on text length
|
|
4681
4709
|
width: (elm.text?.length ?? 0) * 0.1,
|
|
4682
4710
|
height: 0.2,
|
|
4683
4711
|
connectedTo: []
|
|
@@ -4775,12 +4803,17 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4775
4803
|
if (!this.source_trace_id) {
|
|
4776
4804
|
throw new Error("Missing source_trace_id for schematic trace insertion.");
|
|
4777
4805
|
}
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4806
|
+
if (countComplexElements(junctions, edges) >= 5 && this._isPassiveToChipConnection()) {
|
|
4807
|
+
this._doInitialSchematicTraceRenderWithDisplayLabel();
|
|
4808
|
+
db.schematic_trace.delete(this.schematic_trace_id);
|
|
4809
|
+
} else {
|
|
4810
|
+
const trace = db.schematic_trace.insert({
|
|
4811
|
+
source_trace_id: this.source_trace_id,
|
|
4812
|
+
edges,
|
|
4813
|
+
junctions
|
|
4814
|
+
});
|
|
4815
|
+
this.schematic_trace_id = trace.schematic_trace_id;
|
|
4816
|
+
}
|
|
4784
4817
|
}
|
|
4785
4818
|
};
|
|
4786
4819
|
|