@tscircuit/core 0.0.1469 → 0.0.1471
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 -2
- package/dist/index.js +37 -86
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -35,11 +35,11 @@ declare const SOLVERS: {
|
|
|
35
35
|
};
|
|
36
36
|
type SolverName = keyof typeof SOLVERS;
|
|
37
37
|
|
|
38
|
-
type SimplifiedPcbTrace = Omit<SimplifiedPcbTrace$1, "connection_name" | "
|
|
38
|
+
type SimplifiedPcbTrace = Omit<SimplifiedPcbTrace$1, "connection_name" | "route"> & {
|
|
39
39
|
type: "pcb_trace";
|
|
40
40
|
pcb_trace_id: string;
|
|
41
41
|
connection_name?: string;
|
|
42
|
-
|
|
42
|
+
connectsTo?: string[];
|
|
43
43
|
route: Array<{
|
|
44
44
|
route_type: "wire";
|
|
45
45
|
x: number;
|
package/dist/index.js
CHANGED
|
@@ -9680,6 +9680,22 @@ function Port_tryRenderGroupPcbPort(port) {
|
|
|
9680
9680
|
return true;
|
|
9681
9681
|
}
|
|
9682
9682
|
|
|
9683
|
+
// lib/utils/schematic/getSourcePortNetLabelText.ts
|
|
9684
|
+
var getSourcePortNetLabelText = (db, sourcePortId) => {
|
|
9685
|
+
const sourcePort = db.source_port.get(sourcePortId);
|
|
9686
|
+
if (!sourcePort?.name) return void 0;
|
|
9687
|
+
const sourceComponent = sourcePort.source_component_id ? db.source_component.get(sourcePort.source_component_id) : void 0;
|
|
9688
|
+
const sourceGroup = !sourceComponent ? db.source_group.list().find((group) => group.subcircuit_id === sourcePort.subcircuit_id) : void 0;
|
|
9689
|
+
const ownerName = sourceComponent?.name ?? sourceGroup?.name;
|
|
9690
|
+
if (!ownerName) return void 0;
|
|
9691
|
+
return `${ownerName}_${sourcePort.name}`;
|
|
9692
|
+
};
|
|
9693
|
+
var getNetNameFromSourcePorts = (db, sourcePortIds) => {
|
|
9694
|
+
const portNames = sourcePortIds.map((sourcePortId) => getSourcePortNetLabelText(db, sourcePortId)).filter((name) => Boolean(name));
|
|
9695
|
+
if (portNames.length === 0) return void 0;
|
|
9696
|
+
return [...new Set(portNames)].join("/");
|
|
9697
|
+
};
|
|
9698
|
+
|
|
9683
9699
|
// lib/components/primitive-components/Port/Port.ts
|
|
9684
9700
|
var Port = class extends PrimitiveComponent2 {
|
|
9685
9701
|
source_port_id = null;
|
|
@@ -10267,7 +10283,8 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
10267
10283
|
* port, but appears at the port it connects to.
|
|
10268
10284
|
*/
|
|
10269
10285
|
_getNetLabelText() {
|
|
10270
|
-
|
|
10286
|
+
if (!this.root || !this.source_port_id) return void 0;
|
|
10287
|
+
return getSourcePortNetLabelText(this.root.db, this.source_port_id);
|
|
10271
10288
|
}
|
|
10272
10289
|
};
|
|
10273
10290
|
|
|
@@ -16477,54 +16494,23 @@ var getDifferentialPairsForSimpleRouteJson = ({
|
|
|
16477
16494
|
|
|
16478
16495
|
// lib/utils/autorouting/getPreservedRoutedSubcircuitTraces.ts
|
|
16479
16496
|
var getPreservedTraceConnectionName = (trace) => trace.source_trace_id ?? trace.connection_name ?? trace.pcb_trace_id;
|
|
16480
|
-
var
|
|
16481
|
-
trace
|
|
16482
|
-
connectionName,
|
|
16483
|
-
scopedDb,
|
|
16484
|
-
sharedConnMap
|
|
16485
|
-
}) => {
|
|
16486
|
-
const connectedToIds = /* @__PURE__ */ new Set();
|
|
16487
|
-
const addConnectedId = (id) => {
|
|
16488
|
-
if (!id) return;
|
|
16489
|
-
connectedToIds.add(id);
|
|
16490
|
-
const connectivityNetId = sharedConnMap.getNetConnectedToId(id);
|
|
16491
|
-
if (!connectivityNetId) return;
|
|
16492
|
-
connectedToIds.add(connectivityNetId);
|
|
16493
|
-
for (const connectedId of sharedConnMap.getIdsConnectedToNet(
|
|
16494
|
-
connectivityNetId
|
|
16495
|
-
)) {
|
|
16496
|
-
connectedToIds.add(connectedId);
|
|
16497
|
-
}
|
|
16498
|
-
};
|
|
16499
|
-
addConnectedId(connectionName);
|
|
16500
|
-
addConnectedId(trace.source_trace_id);
|
|
16501
|
-
const sourceTrace = trace.source_trace_id ? scopedDb.source_trace.get(trace.source_trace_id) : null;
|
|
16502
|
-
if (sourceTrace) {
|
|
16503
|
-
for (const id of sourceTrace.connected_source_net_ids ?? []) {
|
|
16504
|
-
addConnectedId(id);
|
|
16505
|
-
}
|
|
16506
|
-
for (const id of sourceTrace.connected_source_port_ids ?? []) {
|
|
16507
|
-
addConnectedId(id);
|
|
16508
|
-
}
|
|
16509
|
-
}
|
|
16497
|
+
var getPhysicalConnectionIdsForPreservedTrace = (trace) => {
|
|
16498
|
+
const physicallyConnectedIds = new Set(trace.connectsTo ?? []);
|
|
16510
16499
|
for (const routePoint of trace.route ?? []) {
|
|
16511
16500
|
if (routePoint.route_type !== "wire") continue;
|
|
16512
16501
|
for (const pcbPortId of [
|
|
16513
16502
|
routePoint.start_pcb_port_id,
|
|
16514
16503
|
routePoint.end_pcb_port_id
|
|
16515
16504
|
]) {
|
|
16516
|
-
|
|
16517
|
-
const pcbPort = pcbPortId ? scopedDb.pcb_port.get(pcbPortId) : null;
|
|
16518
|
-
addConnectedId(pcbPort?.source_port_id);
|
|
16505
|
+
if (pcbPortId) physicallyConnectedIds.add(pcbPortId);
|
|
16519
16506
|
}
|
|
16520
16507
|
}
|
|
16521
|
-
return Array.from(
|
|
16508
|
+
return Array.from(physicallyConnectedIds);
|
|
16522
16509
|
};
|
|
16523
16510
|
var getPreservedRoutedSubcircuitTraces = ({
|
|
16524
16511
|
scopedDb,
|
|
16525
16512
|
currentSubcircuitId,
|
|
16526
|
-
relevantSubcircuitIds
|
|
16527
|
-
sharedConnMap
|
|
16513
|
+
relevantSubcircuitIds
|
|
16528
16514
|
}) => scopedDb.pcb_trace.list().filter((trace) => {
|
|
16529
16515
|
if (!trace.subcircuit_id) return false;
|
|
16530
16516
|
if (!currentSubcircuitId) return true;
|
|
@@ -16537,12 +16523,7 @@ var getPreservedRoutedSubcircuitTraces = ({
|
|
|
16537
16523
|
pcb_trace_id: trace.pcb_trace_id,
|
|
16538
16524
|
source_trace_id: trace.source_trace_id,
|
|
16539
16525
|
connection_name: connectionName,
|
|
16540
|
-
|
|
16541
|
-
trace: preservedTrace,
|
|
16542
|
-
connectionName,
|
|
16543
|
-
scopedDb,
|
|
16544
|
-
sharedConnMap
|
|
16545
|
-
}),
|
|
16526
|
+
connectsTo: getPhysicalConnectionIdsForPreservedTrace(preservedTrace),
|
|
16546
16527
|
route: trace.route
|
|
16547
16528
|
};
|
|
16548
16529
|
}).filter((trace) => trace.route.length >= 2);
|
|
@@ -16748,8 +16729,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
16748
16729
|
const preservedRoutedSubcircuitTraces = getPreservedRoutedSubcircuitTraces({
|
|
16749
16730
|
scopedDb: db,
|
|
16750
16731
|
currentSubcircuitId: subcircuit_id,
|
|
16751
|
-
relevantSubcircuitIds
|
|
16752
|
-
sharedConnMap
|
|
16732
|
+
relevantSubcircuitIds
|
|
16753
16733
|
});
|
|
16754
16734
|
for (const obstacle of obstacles) {
|
|
16755
16735
|
const additionalIds = obstacle.connectedTo.flatMap(
|
|
@@ -21797,7 +21777,11 @@ function applyNetLabelPlacements(args) {
|
|
|
21797
21777
|
continue;
|
|
21798
21778
|
}
|
|
21799
21779
|
const ports = group.selectAll("port").filter((p) => p._getSubcircuitConnectivityKey() === placementConnKey);
|
|
21800
|
-
const { name:
|
|
21780
|
+
const { name: portInstanceText, wasAssignedDisplayLabel } = getNetNameFromPorts(ports);
|
|
21781
|
+
const sourcePortIdsForConnection = placementConnKey ? db.source_port.list().filter(
|
|
21782
|
+
(sourcePort) => sourcePort.subcircuit_connectivity_map_key === placementConnKey
|
|
21783
|
+
).map((sourcePort) => sourcePort.source_port_id) : [];
|
|
21784
|
+
const text = portInstanceText || getNetNameFromSourcePorts(db, sourcePortIdsForConnection) || "";
|
|
21801
21785
|
const isRoutedPairPlacement = (placement.pinIds?.length ?? 0) > 1;
|
|
21802
21786
|
const shouldKeepRoutedPairLabel = isRoutedPairPlacement && (globalNetIdsWithPortOnlyPlacements.has(placement.globalConnNetId) || (routedPairKeysByGlobalNetId.get(placement.globalConnNetId)?.size ?? 0) > 1);
|
|
21803
21787
|
if (!wasAssignedDisplayLabel && !shouldKeepRoutedPairLabel && schPortIds.some(
|
|
@@ -21838,16 +21822,6 @@ var doesSchematicNetLabelRepresentCurrentSourceConnection = (args) => {
|
|
|
21838
21822
|
}
|
|
21839
21823
|
return nl.text === text;
|
|
21840
21824
|
};
|
|
21841
|
-
var getSourcePortNetLabelText = (db, sourcePortId) => {
|
|
21842
|
-
const sourcePort = db.source_port.get(sourcePortId);
|
|
21843
|
-
if (!sourcePort) return void 0;
|
|
21844
|
-
let sourceComponent;
|
|
21845
|
-
if (sourcePort.source_component_id) {
|
|
21846
|
-
sourceComponent = db.source_component.get(sourcePort.source_component_id);
|
|
21847
|
-
}
|
|
21848
|
-
if (!sourceComponent?.name || !sourcePort.name) return void 0;
|
|
21849
|
-
return `${sourceComponent.name}_${sourcePort.name}`;
|
|
21850
|
-
};
|
|
21851
21825
|
var getDirectCrossSubcircuitConnectedSourcePortId = (db, sourcePortId) => {
|
|
21852
21826
|
const sourcePort = db.source_port.get(sourcePortId);
|
|
21853
21827
|
if (!sourcePort) return void 0;
|
|
@@ -21912,36 +21886,13 @@ var insertNetLabelsForPortsMissingTrace = ({
|
|
|
21912
21886
|
}
|
|
21913
21887
|
const implicitPortLabelText = connectedSourcePortIdsForKey.map((sourcePortId) => getSourcePortNetLabelText(db, sourcePortId)).filter((label) => Boolean(label)).join("/");
|
|
21914
21888
|
const directCrossSubcircuitConnectionLabelText = getDirectCrossSubcircuitConnectionLabelText(db, srcPortId);
|
|
21915
|
-
const isConnectivityKeyFallback = !sourceNet?.name && !sourceNet?.source_net_id && !assignedPortNetLabelText && !directCrossSubcircuitConnectionLabelText && !implicitPortLabelText;
|
|
21916
21889
|
const text = sourceNet?.name || sourceNet?.source_net_id || assignedPortNetLabelText || directCrossSubcircuitConnectionLabelText || implicitPortLabelText || connKey;
|
|
21917
|
-
|
|
21918
|
-
|
|
21919
|
-
|
|
21920
|
-
|
|
21921
|
-
|
|
21922
|
-
|
|
21923
|
-
const sourceTracesConnectedToPort = db.source_trace.list().filter(
|
|
21924
|
-
(trace) => trace.connected_source_port_ids?.includes(srcPortId)
|
|
21925
|
-
);
|
|
21926
|
-
const isPortInsideCollapsedGroup = (port) => {
|
|
21927
|
-
let parent = port.parent;
|
|
21928
|
-
while (parent) {
|
|
21929
|
-
if (parent === collapsedGroup) return true;
|
|
21930
|
-
parent = parent.parent;
|
|
21931
|
-
}
|
|
21932
|
-
return false;
|
|
21933
|
-
};
|
|
21934
|
-
const allConnectionsAreInternal = sourceTracesConnectedToPort.length > 0 && sourceTracesConnectedToPort.every(
|
|
21935
|
-
(trace) => (trace.connected_source_net_ids?.length ?? 0) === 0 && trace.connected_source_port_ids.filter((sourcePortId) => sourcePortId !== srcPortId).every((sourcePortId) => {
|
|
21936
|
-
const connectedPort = connectedPortsForKey.find(
|
|
21937
|
-
(port) => port.source_port_id === sourcePortId
|
|
21938
|
-
);
|
|
21939
|
-
return connectedPort ? isPortInsideCollapsedGroup(connectedPort) : false;
|
|
21940
|
-
})
|
|
21941
|
-
);
|
|
21942
|
-
if (allConnectionsAreInternal) continue;
|
|
21943
|
-
}
|
|
21944
|
-
}
|
|
21890
|
+
const isCollapsedBoxPort = schComponent?.is_box_with_pins && sourcePort && !sourcePort.source_component_id;
|
|
21891
|
+
const hasExternalTrace = db.source_trace.list().some(
|
|
21892
|
+
(trace) => trace.connected_source_port_ids.includes(srcPortId) && trace.subcircuit_id !== sourcePort?.subcircuit_id
|
|
21893
|
+
);
|
|
21894
|
+
const hasExplicitLabel = Boolean(sourceNet || assignedPortNetLabelText);
|
|
21895
|
+
if (isCollapsedBoxPort && !hasExternalTrace && !hasExplicitLabel) continue;
|
|
21945
21896
|
const connectedPortCountForKey = Array.from(
|
|
21946
21897
|
allSourceAndSchematicPortIdsInScope
|
|
21947
21898
|
).filter((portId) => {
|
|
@@ -22938,7 +22889,7 @@ function Group_getRoutingPhasePlans(group) {
|
|
|
22938
22889
|
var package_default = {
|
|
22939
22890
|
name: "@tscircuit/core",
|
|
22940
22891
|
type: "module",
|
|
22941
|
-
version: "0.0.
|
|
22892
|
+
version: "0.0.1470",
|
|
22942
22893
|
types: "dist/index.d.ts",
|
|
22943
22894
|
main: "dist/index.js",
|
|
22944
22895
|
module: "dist/index.js",
|