AshUi.Diff (ash_ui v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

Fresh fingerprint state for a new session.

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

Functions

new_fingerprints()

Fresh fingerprint state for a new session.

render(rendered, prints)

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