Raxol.Core.Accessibility.AccessibilityServer (Raxol Core v2.4.0)

Copy Markdown View Source

Unified GenServer implementation for accessibility features in Raxol.

This server consolidates all accessibility state management, eliminating Process dictionary usage across Accessibility, Announcements, and Metadata modules.

Features

  • Screen reader announcements with queuing and priority
  • High contrast mode management
  • Reduced motion support
  • Large text support
  • Keyboard focus indicators
  • Accessibility metadata tracking
  • User preference integration
  • Theme integration for accessibility
  • Announcement history tracking

Sub-modules

  • AnnouncementQueue -- queue, priority, history, delivery
  • PreferenceManager -- preference merge/sync/notify
  • MetadataRegistry -- element/component metadata and style registration
  • FocusManager -- focus tracking, history, and focus announcements

Summary

Functions

Makes an announcement for screen readers.

Announces with synchronous confirmation.

Returns a specification to start this module under a supervisor.

Clears all announcements from the queue.

Clears announcements for a specific user.

Disables accessibility features.

Enables accessibility features with the given options.

Checks if accessibility is enabled.

Gets component style.

Gets element metadata for a component.

Gets focus history.

Gets accessibility metadata for a component.

Gets the next announcement from the queue.

Gets an option value.

Gets all current preferences.

Gets the current state (for debugging/testing).

Gets high contrast mode status.

Gets large text mode status.

Gets reduced motion mode status.

Registers element metadata for a component.

Removes metadata for a component.

Resets the accessibility server to its default state (for test isolation).

Gets screen reader support status.

Sets the announcement callback function.

Sets keyboard focus indicators.

Sets accessibility metadata for a component.

Sets an option value.

Checks if announcements should be made.

Unregisters component style.

Unregisters element metadata.

Functions

add_announcement(announcement, user_preferences_pid_or_name \\ nil)

Adds an announcement to the queue.

add_announcement(server, announcement, user_preferences_pid_or_name)

announce(server \\ __MODULE__, message, opts \\ [])

@spec announce(GenServer.server(), String.t(), keyword()) :: :ok

Makes an announcement for screen readers.

Options

  • :priority - Priority level (:high, :medium, :low) default: :medium
  • :interrupt - Whether to interrupt current announcement default: false
  • :language - Language for the announcement

announce_sync(server \\ __MODULE__, message, opts \\ [])

@spec announce_sync(GenServer.server(), String.t(), keyword()) :: :ok

Announces with synchronous confirmation.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear_all_announcements()

Clears all announcements from the queue.

clear_all_announcements(server)

clear_announcement_history(server \\ __MODULE__)

Clears announcement history.

clear_announcements(user_preferences_pid_or_name)

Clears announcements for a specific user.

clear_announcements(server, user_preferences_pid_or_name)

disable(server \\ __MODULE__)

@spec disable(GenServer.server()) :: :ok

Disables accessibility features.

enable(server \\ __MODULE__, options \\ [], user_preferences_pid \\ nil)

@spec enable(GenServer.server(), keyword(), atom() | pid() | nil) :: :ok

Enables accessibility features with the given options.

enabled?(server \\ __MODULE__)

@spec enabled?(GenServer.server()) :: boolean()

Checks if accessibility is enabled.

get_announcement_history(server \\ __MODULE__, limit \\ nil)

Gets announcement history.

get_component_hint(component_id, hint_level \\ :normal)

Gets a component hint.

get_component_hint(server, component_id, hint_level)

get_component_style(component_type)

Gets component style.

get_component_style(server, component_type)

get_element_metadata(server \\ __MODULE__, element_id)

Gets element metadata for a component.

get_focus_history()

Gets focus history.

get_focus_history(server)

get_metadata(server \\ __MODULE__, component_id)

Gets accessibility metadata for a component.

get_next_announcement(user_preferences_pid_or_name \\ nil)

Gets the next announcement from the queue.

get_next_announcement(server, user_preferences_pid_or_name)

get_option(key, default \\ nil)

Gets an option value.

get_option(server, key, default)

get_preferences(server \\ __MODULE__)

@spec get_preferences(GenServer.server()) :: map()

Gets all current preferences.

get_state(server \\ __MODULE__)

Gets the current state (for debugging/testing).

handle_focus_change(server \\ __MODULE__, old_focus, new_focus)

Handles focus change events.

handle_focus_change_event(unexpected)

handle_focus_change_event(old, event_data)

handle_focus_change_event(event_name, measurements, metadata, config)

handle_preference_changed_event(arg)

handle_theme_changed_event(arg)

high_contrast?(server \\ __MODULE__)

@spec high_contrast?(GenServer.server()) :: boolean()

Gets high contrast mode status.

large_text?(server \\ __MODULE__)

@spec large_text?(GenServer.server()) :: boolean()

Gets large text mode status.

reduced_motion?(server \\ __MODULE__)

@spec reduced_motion?(GenServer.server()) :: boolean()

Gets reduced motion mode status.

register_component_style(component_type, style)

Registers component style.

register_component_style(server, component_type, style)

register_element_metadata(server \\ __MODULE__, element_id, metadata)

Registers element metadata for a component.

remove_metadata(server \\ __MODULE__, component_id)

Removes metadata for a component.

reset(server \\ __MODULE__)

@spec reset(GenServer.server()) :: :ok

Resets the accessibility server to its default state (for test isolation).

screen_reader?(server \\ __MODULE__)

@spec screen_reader?(GenServer.server()) :: boolean()

Gets screen reader support status.

set_announcement_callback(server \\ __MODULE__, callback)

Sets the announcement callback function.

set_high_contrast(server \\ __MODULE__, enabled)

@spec set_high_contrast(GenServer.server(), boolean()) :: :ok

Sets high contrast mode.

set_keyboard_focus(server \\ __MODULE__, enabled)

@spec set_keyboard_focus(GenServer.server(), boolean()) :: :ok

Sets keyboard focus indicators.

set_large_text(server \\ __MODULE__, enabled)

@spec set_large_text(GenServer.server(), boolean()) :: :ok

Sets large text mode.

set_large_text_with_prefs(server \\ __MODULE__, enabled, user_preferences_pid)

set_metadata(server \\ __MODULE__, component_id, metadata)

Sets accessibility metadata for a component.

set_option(key, value)

Sets an option value.

set_option(server, key, value)

set_reduced_motion(server \\ __MODULE__, enabled)

@spec set_reduced_motion(GenServer.server(), boolean()) :: :ok

Sets reduced motion mode.

set_screen_reader(server \\ __MODULE__, enabled)

@spec set_screen_reader(GenServer.server(), boolean()) :: :ok

Sets screen reader support.

should_announce?(prefs)

@spec should_announce?(atom() | pid() | nil) :: boolean()

Checks if announcements should be made.

start_link(init_opts \\ [])

unregister_component_style(component_type)

Unregisters component style.

unregister_component_style(server, component_type)

unregister_element_metadata(element_id)

Unregisters element metadata.

unregister_element_metadata(server, element_id)