# Iframe integration

Use an isolated calculator and the existing message protocol.

Source: https://warcraftforever.com/developers/reference/iframe/

The existing `/embed/talents/v1.js` script and `WarcraftForeverTalents.mount()` remain available for iframe isolation. You can also use [the iframe route](https://warcraftforever.com/embed/talents/?class=paladin&editable=false) without our script. Pass `class`, `editable`, and optional build and display settings as query parameters. For state changes and automatic height, use the [message protocol](#direct-iframe-message-protocol).

## Direct iframe message protocol

Set `parentOrigin` to your exact origin and `token` to a random 8–128 character value in the iframe URL. Send a request to `iframe.contentWindow` with `postMessage(request, 'https://warcraftforever.com')`.

```js
{
  protocol: 'warcraft-forever-talents',
  version: 1,
  kind: 'request',
  token,
  requestId: '1',
  action: 'update',
  options: { class: 'paladin', editable: false }
}
```

The `options` object is the complete mount options. Responses carry the same request ID and either `{ ok: true, state }` or `{ ok: false, error }`. Events use `kind: 'event'` with `event` set to `ready`, `change`, `complete`, `error`, or `height`. A change event includes the committed `build` when available; edits clear its Point Order path. Every message carries the protocol name, version, and token. Check both `event.source === iframe.contentWindow` and `event.origin === 'https://warcraftforever.com'` before accepting a message.
