AAC Beacon — Source Documentation
tts.js
speak(text)
Speaks the given text aloud using the device's speech engine. Stops any currently playing speech before starting. Does nothing if text is empty or whitespace.
- Parameters:
text—stringrepresenting the text to be spoken - Options: language
en-US, rate0.9, pitch1.0
stop()
Stops any currently playing speech immediately.
WordGrid.js
default function WordGrid({ words, activeCategoryColor, onAddWord })
A scrollable grid of word tiles. Each tile displays an emoji and a label and triggers a callback when pressed.
- Parameters:
words—Array<{ label: string, emoji: string }>list of words to display as tilesactiveCategoryColor—stringhex color used for tile background tint and borderonAddWord—(label: string) => voidcallback invoked when a tile is pressed
SentenceBar.js
default function SentenceBar({ sentence, onRemoveLastWord, onClearSentence, onSpeakSentence })
A horizontal bar displaying the currently built sentence along with action buttons for editing and speaking it. Shows a placeholder message when the sentence is empty.
- Parameters:
sentence—string[]array of words making up the current sentenceonRemoveLastWord—() => voidcallback to remove the last word in the sentenceonClearSentence—() => voidcallback to clear all words from the sentenceonSpeakSentence—() => voidcallback to speak the full sentence aloud
RoomSelector.js
default function RoomSelector({ rooms, activeRoomId, onSelectRoom })
A horizontally scrollable row of room "chips" that lets the user manually simulate entering a room. This component is a placeholder for automatic Bluetooth beacon detection. Once BLE is integrated, this selector can be hidden or shown only as a manual override / fallback.
- Parameters:
rooms—Array<{ id: string, label: string, emoji: string, color: string }>list of available roomsactiveRoomId—string | nullthe ID of the currently selected room, ornullfor GeneralonSelectRoom—(roomId: string | null) => voidcallback invoked when a chip is pressed
InteractionLogModal.js
formatTimestamp(value)
Converts a timestamp value to a human-readable locale string. Returns the original value if it cannot be parsed as a valid date.
- Parameters:
value— a date string or timestamp - Returns:
stringformatted locale date/time string
renderLogItem({ item, index })
Renders a single interaction log entry card. Displays button name, timestamp, room, device ID, and optional fields such as word, sentence length, and category.
- Parameters:
item— a log entry objectindex—numberthe position of the item in the list
default function InteractionLogModal({ visible, logs, onClose })
A full-screen modal that displays the interaction log history in reverse chronological order. Supports exporting all logs as a JSON file (download on web, native share sheet on mobile).
- Parameters:
visible—booleancontrols modal visibilitylogs—Arrayof interaction log entry objectsonClose—() => voidcallback to close the modal
handleExportJson()
Exports the current logs as a JSON payload. On web, triggers a file download. On native platforms, opens the system share sheet. Disables the export button while exporting is in progress.
CategoryTabs.js
default function CategoryTabs({ categories, activeCategory, categoryColors, onSelectCategory })
Renders a row of category tab buttons. The active tab is highlighted with its assigned category color.
- Parameters:
categories—objectwhose keys are category name stringsactiveCategory—stringthe currently selected category keycategoryColors—objectmapping category keys to hex color stringsonSelectCategory—(category: string) => voidcallback invoked when a tab is pressed
AppHeader.js
default function AppHeader({ currentRoom, onViewLogs })
Renders the top header bar showing the app title, the current room context, and a button to open the interaction logs modal.
- Parameters:
currentRoom—{ emoji: string, label: string } | nullthe active room object, ornullfor GeneralonViewLogs—() => voidcallback invoked when the "View Logs" button is pressed
useSpeech.js
useSpeech()
Custom hook that exposes TTS controls to components.
- Returns:
speakText(text: string) => void— speaks the given textstopSpeech() => void— stops any currently playing speech
useSentenceBuilder.js
default function useSentenceBuilder({ onLogPress })
Custom hook that manages sentence state and logs all sentence-related user interactions. Intended as the primary sentence-building hook when interaction logging is needed.
-
Parameters:
onLogPress—(buttonName: string, metadata?: object) => voidoptional callback used to log each action
-
Returns:
sentence—string[]the current array of wordsaddWord(word: string) => void— appends a word to the sentence and logs aword_tilepressremoveLastWord() => void— removes the last word and logs aremove_last_wordpressclearSentence() => void— clears all words and logs aclear_sentencepressspeakSentence() => void— shows an alert with the full sentence and logs aspeak_sentencepress; no-op if sentence is empty
useSentence.js
useSentence()
Custom hook that manages sentence state with integrated TTS feedback. Speaks each word immediately when added and speaks the full sentence on demand.
- Returns:
sentence—string[]the current array of wordsaddWord(word: string) => void— appends a word and immediately speaks itspeakSentence() => void— speaks the entire sentence joined by spacesclear() => void— clears all words and stops any ongoing speech
useLocationDetection.js
default function useLocationDetection()
Abstraction layer for room / location detection. Currently supports manual room selection. Designed so that future Bluetooth beacon scanning can be swapped in without changing the hook's return shape or the rest of the app.
- Returns:
currentRoom—object | nullthe active room context objectdetectionMode—'manual' | 'bluetooth'the current detection strategysetRoomManually(roomId: string | null) => void— sets the active room by ID; passnullto clearallRooms—Arrayall available room definitions
setRoomManually(roomId)
Looks up a room by ID from the full room list and sets it as the current room. Clears the current room if null is passed.
- Parameters:
roomId—string | null
useInteractionLogger.js
createDeviceId()
Generates a pseudo-unique device identifier string combining the platform OS, platform version, and a random alphanumeric suffix.
- Returns:
stringin the format{os}-{version}-{randomSuffix}
default function useInteractionLogger(currentRoom)
Custom hook that maintains a log of user interaction events. Each entry captures the button name, timestamp, device ID, room context, and any additional metadata.
-
Parameters:
currentRoom—object | nullthe currently active room, used to attach location context to each log entry -
Returns:
deviceId—stringthe stable pseudo-unique device identifier for this sessioninteractionLogs—Arraythe full list of recorded log entrieslogButtonPress(buttonName: string, metadata?: object) => void— records a new interaction entry and prints it to the console
logButtonPress(buttonName, metadata)
Creates and appends a new log entry to interactionLogs. The entry includes device ID, button name, ISO timestamp, location (derived from currentRoom), and any extra fields provided in metadata.
- Parameters:
buttonName—stringthe identifier of the button or action that was triggeredmetadata—objectoptional additional fields to merge into the log entry (e.g.{ word, sentenceLength, category })