# `LivePanels.Canvas.State`
[🔗](https://github.com/livepanels/livepanels/blob/v0.1.0/lib/livepanels/canvas/state.ex#L1)

Canonical server-owned state for the abstract canvas model.

This module models canvas truth: items, domain models, actor selection,
stacking order, and layout serialization.
Runtime projection into LiveView sockets is wired internally by
`LivePanels.Canvas`.

# `t`

```elixir
@type t() :: %LivePanels.Canvas.State{
  clipboards: %{optional(String.t()) =&gt; map()},
  declaration_removals: %{optional(String.t()) =&gt; non_neg_integer()},
  extensions: [term()],
  histories: %{optional(String.t()) =&gt; LivePanels.Canvas.History.t()},
  id: String.t(),
  interaction_lease_timeout_ms: pos_integer(),
  items: %{optional(String.t()) =&gt; LivePanels.Item.t()},
  layout_store: module(),
  max_z_index: number(),
  mode: :local | :shared,
  plugin_state: map(),
  policy: term(),
  selections: %{optional(String.t()) =&gt; LivePanels.Canvas.Selection.t()},
  server_layout_loaded: boolean(),
  viewport_anchors: map(),
  viewport_cursors: %{optional(String.t()) =&gt; String.t()},
  viewport_sequence: [String.t()],
  z_order: [String.t()]
}
```

# `content`

```elixir
@spec content(t(), String.t()) :: LivePanels.Item.t() | nil
```

Returns a single content-bearing item by id, or `nil` when the item is
absent or does not have a `:content` capability.

# `content_items`

```elixir
@spec content_items(t()) :: %{required(String.t()) =&gt; LivePanels.Item.t()}
```

Returns the subset of items that carry a `:content` capability, keyed by id.
The compositor uses this projection to manage item content processes.

# `new`

```elixir
@spec new(String.t(), map()) :: t()
```

Creates a new canvas state from an id and a config map.

The config map is assembled from the `LivePanels.Canvas` runtime attachment.
Keys: `:canvas_mode`, `:layout_store`,
`:extensions`, `:layout_load_timeout_ms`, `:interaction_lease_timeout_ms`.

Called by `Runtime.do_mount/4` — not typically called directly.

# `persist_layout`

```elixir
@spec persist_layout(t()) :: {:ok, t()} | {:error, term(), t()}
```

Persists the current layout payload through the configured layout store.

# `serialize_layout`

```elixir
@spec serialize_layout(t()) :: [map()]
```

Serializes state to the canonical layout persistence codec.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
