# `AshUi.Diff`
[🔗](https://github.com/hyperbob-labs/ash_ui/blob/main/lib/ash_ui/diff.ex#L1)

The differential kernel over `AshUi.Rendered`: produces
LiveView-wire-compatible diff maps and retained fingerprint state.

This is a copied, minimal subset of `Phoenix.LiveView.Diff`
(phoenix_live_view 1.1.32, MIT © Chris McCord — see NOTICE below),
reduced to what the AshUi render algebra emits:

  * static sharing via fingerprints (`:s`, template table `:p`)
  * nil-based change tracking (nil dynamic = unchanged)
  * recursive rendered children with branch fingerprint replacement
  * keyed comprehension insertion, movement, removal, and update (`:k`,
    count `:kc`, moved entries as `[previous_index, diff]`)
  * duplicate-key rejection

LiveComponents and streams are NOT implemented: the AshUi model has
no component concept and renders collections as keyed comprehensions
over resource state, so those branches are excluded by design. Do not
extend this module's surface — wire-protocol compatibility is asserted
against LiveView as a pinned, test-only executable oracle.

Diff-map keys are a FROZEN wire protocol shared with the LiveView
client: `:s` statics/template-ref, `:r` root, `:k` keyed entries,
`:kc` keyed count, `:p` shared template table.

NOTICE: Portions derived from phoenix_live_view
(https://github.com/phoenixframework/phoenix_live_view), MIT license.

# `new_fingerprints`

Fresh fingerprint state for a new session.

# `render`

Diffs `rendered` against the retained `prints`, returning
`{diff_map, new_prints}`. A root fingerprint mismatch resets state and
re-renders fully, exactly like LiveView.

---

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