@tscircuit/core 0.0.1470 → 0.0.1472

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.
Files changed (2) hide show
  1. package/dist/index.js +31 -43
  2. package/package.json +2 -2
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
- return `${this.parent?.props.name}_${this.props.name}`;
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
 
@@ -21760,7 +21777,11 @@ function applyNetLabelPlacements(args) {
21760
21777
  continue;
21761
21778
  }
21762
21779
  const ports = group.selectAll("port").filter((p) => p._getSubcircuitConnectivityKey() === placementConnKey);
21763
- const { name: text, wasAssignedDisplayLabel } = getNetNameFromPorts(ports);
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) || "";
21764
21785
  const isRoutedPairPlacement = (placement.pinIds?.length ?? 0) > 1;
21765
21786
  const shouldKeepRoutedPairLabel = isRoutedPairPlacement && (globalNetIdsWithPortOnlyPlacements.has(placement.globalConnNetId) || (routedPairKeysByGlobalNetId.get(placement.globalConnNetId)?.size ?? 0) > 1);
21766
21787
  if (!wasAssignedDisplayLabel && !shouldKeepRoutedPairLabel && schPortIds.some(
@@ -21801,16 +21822,6 @@ var doesSchematicNetLabelRepresentCurrentSourceConnection = (args) => {
21801
21822
  }
21802
21823
  return nl.text === text;
21803
21824
  };
21804
- var getSourcePortNetLabelText = (db, sourcePortId) => {
21805
- const sourcePort = db.source_port.get(sourcePortId);
21806
- if (!sourcePort) return void 0;
21807
- let sourceComponent;
21808
- if (sourcePort.source_component_id) {
21809
- sourceComponent = db.source_component.get(sourcePort.source_component_id);
21810
- }
21811
- if (!sourceComponent?.name || !sourcePort.name) return void 0;
21812
- return `${sourceComponent.name}_${sourcePort.name}`;
21813
- };
21814
21825
  var getDirectCrossSubcircuitConnectedSourcePortId = (db, sourcePortId) => {
21815
21826
  const sourcePort = db.source_port.get(sourcePortId);
21816
21827
  if (!sourcePort) return void 0;
@@ -21875,36 +21886,13 @@ var insertNetLabelsForPortsMissingTrace = ({
21875
21886
  }
21876
21887
  const implicitPortLabelText = connectedSourcePortIdsForKey.map((sourcePortId) => getSourcePortNetLabelText(db, sourcePortId)).filter((label) => Boolean(label)).join("/");
21877
21888
  const directCrossSubcircuitConnectionLabelText = getDirectCrossSubcircuitConnectionLabelText(db, srcPortId);
21878
- const isConnectivityKeyFallback = !sourceNet?.name && !sourceNet?.source_net_id && !assignedPortNetLabelText && !directCrossSubcircuitConnectionLabelText && !implicitPortLabelText;
21879
21889
  const text = sourceNet?.name || sourceNet?.source_net_id || assignedPortNetLabelText || directCrossSubcircuitConnectionLabelText || implicitPortLabelText || connKey;
21880
- if (isConnectivityKeyFallback) {
21881
- const sourcePortComponent = connectedPortsForKey.find(
21882
- (port) => port.source_port_id === srcPortId
21883
- );
21884
- const collapsedGroup = sourcePortComponent?.parent;
21885
- if (sourcePortComponent?.isGroupPort() && collapsedGroup?._parsedProps?.showAsSchematicBox) {
21886
- const sourceTracesConnectedToPort = db.source_trace.list().filter(
21887
- (trace) => trace.connected_source_port_ids?.includes(srcPortId)
21888
- );
21889
- const isPortInsideCollapsedGroup = (port) => {
21890
- let parent = port.parent;
21891
- while (parent) {
21892
- if (parent === collapsedGroup) return true;
21893
- parent = parent.parent;
21894
- }
21895
- return false;
21896
- };
21897
- const allConnectionsAreInternal = sourceTracesConnectedToPort.length > 0 && sourceTracesConnectedToPort.every(
21898
- (trace) => (trace.connected_source_net_ids?.length ?? 0) === 0 && trace.connected_source_port_ids.filter((sourcePortId) => sourcePortId !== srcPortId).every((sourcePortId) => {
21899
- const connectedPort = connectedPortsForKey.find(
21900
- (port) => port.source_port_id === sourcePortId
21901
- );
21902
- return connectedPort ? isPortInsideCollapsedGroup(connectedPort) : false;
21903
- })
21904
- );
21905
- if (allConnectionsAreInternal) continue;
21906
- }
21907
- }
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;
21908
21896
  const connectedPortCountForKey = Array.from(
21909
21897
  allSourceAndSchematicPortIdsInScope
21910
21898
  ).filter((portId) => {
@@ -22901,7 +22889,7 @@ function Group_getRoutingPhasePlans(group) {
22901
22889
  var package_default = {
22902
22890
  name: "@tscircuit/core",
22903
22891
  type: "module",
22904
- version: "0.0.1469",
22892
+ version: "0.0.1471",
22905
22893
  types: "dist/index.d.ts",
22906
22894
  main: "dist/index.js",
22907
22895
  module: "dist/index.js",
@@ -23013,7 +23001,7 @@ var package_default = {
23013
23001
  "@flatten-js/core": "^1.6.2",
23014
23002
  "@lume/kiwi": "^0.4.3",
23015
23003
  "calculate-cell-boundaries": "^0.0.13",
23016
- "calculate-packing": "^0.0.78",
23004
+ "calculate-packing": "^0.0.79",
23017
23005
  "css-select": "5.1.0",
23018
23006
  "format-si-unit": "^0.0.7",
23019
23007
  nanoid: "^5.0.7",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1470",
4
+ "version": "0.0.1472",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -113,7 +113,7 @@
113
113
  "@flatten-js/core": "^1.6.2",
114
114
  "@lume/kiwi": "^0.4.3",
115
115
  "calculate-cell-boundaries": "^0.0.13",
116
- "calculate-packing": "^0.0.78",
116
+ "calculate-packing": "^0.0.79",
117
117
  "css-select": "5.1.0",
118
118
  "format-si-unit": "^0.0.7",
119
119
  "nanoid": "^5.0.7",