# placePorts

Canonical: https://docs.shumoku.dev/en/library/api/placePorts
Language: en

@shumoku/core · 0.4.0 · function

# placePorts

[Source](https://github.com/konoe-akitoshi/shumoku/blob/main/libs/@shumoku/core/src/layout/auto-placement/flat-tree/port-placement.ts#L405)

Compose the three phases: decide sides → order each side → compute absolute coordinates → emit \`ResolvedPort\`s keyed by \`nodeId:portId\`. Port sides are re-seated from final geometry (see reseatPortsByGeometry) so wires exit toward their peer regardless of how the upstream/downstream tree was inferred. Ports are positioned along each side by distributePortsAlongSide (peer-aligned), with computePortPosition's even spread as the fallback.

```
placePorts(nodes: Map<string, Node>, links: Link[], direction?: Direction): Map<string, ResolvedPort>
```

## Parameters

| Parameter | Type | Description | Default |
| --- | --- | --- | --- |
| `nodes` | `Map<string, Node>` | No additional description. | `—` |
| `links` | `Link[]` | No additional description. | `—` |
| `direction` | `Direction` | No additional description. | `'TB'` |

## Returns

```
Map<string, ResolvedPort>
```

[`libs/@shumoku/core/src/layout/auto-placement/flat-tree/port-placement.ts:405`](https://github.com/konoe-akitoshi/shumoku/blob/main/libs/@shumoku/core/src/layout/auto-placement/flat-tree/port-placement.ts#L405)
