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

Actor-scoped undo/redo history projection returned by
`LivePanels.Canvas.Read.history/1`.

Applications may inspect this struct for read-only UI state such as enabling undo
and redo controls. This module also owns the socket-first and
transaction-first history command helpers.

# `command_result`

```elixir
@type command_result() :: LivePanels.Canvas.Command.result()
```

# `effect`

```elixir
@type effect() :: map()
```

Opaque versioned history effect captured while reducers build a patch entry.

# `effect_capture`

```elixir
@type effect_capture() :: map()
```

Opaque history effect capture options.

# `entry`

```elixir
@type entry() :: patch()
```

# `entry_delta`

```elixir
@type entry_delta() :: %{
  item_delta: integer(),
  item_total: non_neg_integer(),
  connector_delta: integer(),
  connector_total: non_neg_integer(),
  changed_items: non_neg_integer()
}
```

# `patch`

```elixir
@type patch() :: map()
```

Opaque versioned history patch entry.

History entries are tagged maps using internal keys such as
`:__livepanels_history_patch__`. Host code should use helper functions such as
`entry_delta/1`, `undo_entries/1`, and `redo_entries/1` instead of depending
on the serialized map shape.

# `patch_side`

```elixir
@type patch_side() :: map()
```

Opaque side of a versioned history patch entry.

# `socket`

```elixir
@type socket() :: Phoenix.LiveView.Socket.t()
```

# `t`

```elixir
@type t() :: %LivePanels.Canvas.History{future: [entry()], past: [entry()]}
```

# `target`

```elixir
@type target() :: LivePanels.Canvas.command_target()
```

First argument accepted by history command helpers.

Pass a LiveView socket for a standalone command, or a
`LivePanels.Canvas.Transaction` context inside `LivePanels.Canvas.transaction/2`.

# `can_redo?`

```elixir
@spec can_redo?(t() | term()) :: boolean()
```

Returns whether the current history projection has an entry to redo.

# `can_undo?`

```elixir
@spec can_undo?(t() | term()) :: boolean()
```

Returns whether the current history projection has an entry to undo.

# `entry_delta`

```elixir
@spec entry_delta(entry() | map()) :: entry_delta()
```

Summarizes the layout impact of one history entry for app-owned activity UI.

# `redo`

```elixir
@spec redo(target()) :: command_result()
```

Reapplies history and returns the command result.

# `redo!`

```elixir
@spec redo!(target()) :: target()
```

Reapplies the next entry in the current actor's canvas history.

# `redo_count`

```elixir
@spec redo_count(t() | term()) :: non_neg_integer()
```

Returns the number of redo entries in a history projection.

# `redo_entries`

```elixir
@spec redo_entries(t() | term()) :: [entry()]
```

Returns redo entries in next-first order.

# `undo`

```elixir
@spec undo(target()) :: command_result()
```

Rewinds history and returns the command result.

# `undo!`

```elixir
@spec undo!(target()) :: target()
```

Rewinds the current actor's canvas history.

# `undo_count`

```elixir
@spec undo_count(t() | term()) :: non_neg_integer()
```

Returns the number of undo entries in a history projection.

# `undo_entries`

```elixir
@spec undo_entries(t() | term()) :: [entry()]
```

Returns undo entries in newest-first order.

---

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