Raxol.Core.Runtime.Events.DispatcherHooks (Raxol v2.6.0)

View Source

Pure-function hooks extracted from Dispatcher for mouse hit testing, time-travel debugging, cycle profiling, and session recording.

None of these functions depend on GenServer state -- they operate on explicit arguments and return values.

Summary

Functions

Checks whether a single positioned element is clickable at (x, y).

Walk positioned elements (last drawn = topmost) looking for a clickable element whose bounding box contains (x, y).

Converts a key event data map to a printable string for session recording.

Records a cycle profiler update when the profiler PID is active. No-ops when disabled (nil or non-pid).

Records key input events to the session recorder when it is running. Only records :key type events; all others are ignored.

Records a time-travel snapshot when the time-travel debugger PID is active. No-ops when disabled (nil or non-pid).

Times the execution of fun when cycle profiling is enabled. Returns {elapsed_us, mem_before, mem_after, result}. When disabled (nil profiler), returns {0, 0, 0, result}.

Functions

clickable_at(arg1, x, y)

@spec clickable_at(map(), integer(), integer()) :: {:click, term()} | nil

Checks whether a single positioned element is clickable at (x, y).

Returns {:click, handler} when hit, nil when missed.

hit_test(x, y, elements)

@spec hit_test(integer(), integer(), list()) :: {:click, term()} | :miss

Walk positioned elements (last drawn = topmost) looking for a clickable element whose bounding box contains (x, y).

Returns {:click, handler} or :miss.

key_event_to_string(arg1)

@spec key_event_to_string(map()) :: String.t()

Converts a key event data map to a printable string for session recording.

maybe_record_cycle_update(pid, update_us, mem_before, mem_after, message)

@spec maybe_record_cycle_update(
  pid() | nil,
  non_neg_integer(),
  non_neg_integer(),
  non_neg_integer(),
  term()
) :: :ok

Records a cycle profiler update when the profiler PID is active. No-ops when disabled (nil or non-pid).

maybe_record_input(event)

@spec maybe_record_input(Raxol.Core.Events.Event.t() | term()) :: :ok

Records key input events to the session recorder when it is running. Only records :key type events; all others are ignored.

maybe_record_time_travel(pid, message, old_model, new_model)

@spec maybe_record_time_travel(pid() | nil, term(), map(), map()) :: :ok

Records a time-travel snapshot when the time-travel debugger PID is active. No-ops when disabled (nil or non-pid).

maybe_time_update(arg1, fun)

@spec maybe_time_update(pid() | nil, (-> term())) ::
  {non_neg_integer(), non_neg_integer(), non_neg_integer(), term()}

Times the execution of fun when cycle profiling is enabled. Returns {elapsed_us, mem_before, mem_after, result}. When disabled (nil profiler), returns {0, 0, 0, result}.